/* * @Author: ZhaoYing * @Date: 2026-02-03 16:50:10 * @Last Modified by: ZhaoYing * @Last Modified time: 2026-02-03 16:50:10 */ /** * Model List View * Displays models grouped by provider with key configuration * Shows model tags and allows viewing model details */ import { useRef, useState, useEffect, type FC } from 'react'; import { Button, Flex, Row, Col } from 'antd' import { useTranslation } from 'react-i18next'; import type { ProviderModelItem, KeyConfigModalRef, ModelListDetailRef } from './types' import RbCard from '@/components/RbCard/Card' import { getModelNewList } from '@/api/models' import PageEmpty from '@/components/Empty/PageEmpty'; import Tag from '@/components/Tag'; import KeyConfigModal from './components/KeyConfigModal' import ModelListDetail from './components/ModelListDetail' import { getLogoUrl } from './utils' /** * Model list component */ const ModelList: FC<{ query: any }> = ({ query }) => { const { t } = useTranslation(); const keyConfigModalRef = useRef(null) const modelListDetailRef = useRef(null) const [list, setList] = useState([]) useEffect(() => { getList() }, [query]) /** Fetch model list grouped by provider */ const getList = () => { getModelNewList({ ...query, is_composite: false, }) .then(res => { setList((res || []) as ProviderModelItem[]) }) } /** Open model detail drawer */ const handleShowModel = (vo: ProviderModelItem) => { modelListDetailRef.current?.handleOpen(vo) } /** Open key configuration modal */ const handleKeyConfig = (vo: ProviderModelItem) => { keyConfigModalRef.current?.handleOpen(vo) } return ( <> {list.length === 0 ? :(
{list.map(item => ( {item.provider[0].toUpperCase()}
} bodyClassName="rb:relative rb:pb-[64px]! rb:h-[calc(100%-64px)]!" > {item.tags.map(tag => {t(`modelNew.${tag}`)})}
))} ) } ) } export default ModelList