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' const ModelList: FC<{ query: any }> = ({ query }) => { const { t } = useTranslation(); const keyConfigModalRef = useRef(null) const modelListDetailRef = useRef(null) const [list, setList] = useState([]) useEffect(() => { getList() }, [query]) const getList = () => { getModelNewList({ ...query, is_composite: false, }) .then(res => { setList((res || []) as ProviderModelItem[]) }) } const handleShowModel = (vo: ProviderModelItem) => { modelListDetailRef.current?.handleOpen(vo) } 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