import { apiInterceptors, getModelList } from '@/client/api'; import ModelForm from '@/components/model/model-form'; import BlurredCard from '@/new-components/common/blurredCard'; import ConstructLayout from '@/new-components/layout/Construct'; import { IModelData } from '@/types/model'; import { MODEL_ICON_DICT } from '@/utils/constants'; import { PlusOutlined } from '@ant-design/icons'; import { Button, Modal, Tag } from 'antd'; import moment from 'moment'; import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; function Models() { const { t } = useTranslation(); const [models, setModels] = useState>([]); const [isModalOpen, setIsModalOpen] = useState(false); // const [loading, setLoading] = useState(false); async function getModels() { const [, res] = await apiInterceptors(getModelList()); setModels(res ?? []); } // TODO: delete unuesed function // async function stopTheModel(info: IModelData) { // if (loading) { // return; // } // setLoading(true); // const [, res] = await apiInterceptors( // stopModel({ // host: info.host, // port: info.port, // model: info.model_name, // worker_type: info.model_type, // params: {}, // }), // ); // setLoading(false); // if (res === true) { // message.success(t('stop_model_success')); // } // } useEffect(() => { getModels(); }, []); // TODO: unuesed function // const onSearch = useDebounceFn( // async (e: any) => { // const v = e.target.value; // await modelSearch({ model_name: v }); // }, // { wait: 500 }, // ).run; const returnLogo = (name: string) => { const formatterModal = name?.replaceAll('-', '_').split('_')[0]; const dict = Object.keys(MODEL_ICON_DICT); for (let i = 0; i < dict.length; i++) { const element = dict[i]; if (formatterModal?.includes(element)) { return MODEL_ICON_DICT[element]; } } return '/pictures/model.png'; }; return (
{/* } placeholder={t('please_enter_the_keywords')} onChange={onSearch} onPressEnter={onSearch} allowClear className="w-[230px] h-[40px] border-1 border-white backdrop-filter backdrop-blur-lg bg-white bg-opacity-30 dark:border-[#6f7f95] dark:bg-[#6f7f95] dark:bg-opacity-60" /> */}
{models.map(item => (

Host:

{item.host}

Manage Host:

{item.manager_host}:{item.manager_port}

Last Heart Beat:

{moment(item.last_heartbeat).format('YYYY-MM-DD')}

} name={item.model_name} key={item.model_name} rightTopHover={false} Tags={
{item.healthy ? 'Healthy' : 'Unhealthy'} {item.model_type}
} /> ))}
{ setIsModalOpen(false); }} footer={null} > { setIsModalOpen(false); }} onSuccess={() => { setIsModalOpen(false); getModels(); }} />
); } export default Models;