import { useState, useRef, type FC } from 'react'; import { Row, Col, Button } from 'antd' import { useTranslation } from 'react-i18next'; import clsx from 'clsx'; import ConfigModal from './components/ConfigModal' import type { Model, DescriptionItem, ConfigModalRef } from './types' import RbCard from '@/components/RbCard/Card' import SearchInput from '@/components/SearchInput' import PageScrollList, { type PageScrollListRef } from '@/components/PageScrollList' import { getModelListUrl } from '@/api/models' import { formatDateTime } from '@/utils/format'; const ModelManagement: FC = () => { const { t } = useTranslation(); const [query, setQuery] = useState({}) const configModalRef = useRef(null) const scrollListRef = useRef(null) const formatData = (data: Model) => { return [ { key: 'type', label: t(`model.type`), children: data.type || '-', }, { key: 'provider', label: t(`model.provider`), children: data.api_keys[0].provider || '-', }, { key: 'is_active', label: t(`model.status`), children: data.is_active ? t(`common.statusEnabled`) : t(`common.statusDisabled`), }, { key: 'created', label: t(`model.created`), children: data.created_at ? formatDateTime(data.created_at, 'YYYY-MM-DD HH:mm:ss') : '-', }, ] } const handleEdit = (model?: Model) => { configModalRef?.current?.handleOpen(model) } const handleSearch = (value?: string) => { setQuery({ search: value }) } return (
( {formatData(item)?.map((description: DescriptionItem) => (
{(description.label as string)} {(description.children as string)}
))}
)} /> scrollListRef?.current?.refresh()} />
) } export default ModelManagement