mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-13 13:10:29 +00:00
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com> Co-authored-by: lcx01800250 <lcx01800250@alibaba-inc.com> Co-authored-by: licunxing <864255598@qq.com> Co-authored-by: Aralhi <xiaoping0501@gmail.com> Co-authored-by: xuyuan23 <643854343@qq.com> Co-authored-by: aries_ckt <916701291@qq.com> Co-authored-by: hzh97 <2976151305@qq.com>
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import { apiInterceptors, getModelList } from '@/client/api';
|
|
import ModelCard from '@/components/model/model-card';
|
|
import ModelForm from '@/components/model/model-form';
|
|
import { IModelData } from '@/types/model';
|
|
import { Button, Modal } from 'antd';
|
|
import { useEffect, useState } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
function Models() {
|
|
const { t } = useTranslation();
|
|
const [models, setModels] = useState<Array<IModelData>>([]);
|
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
|
|
async function getModels() {
|
|
const [, res] = await apiInterceptors(getModelList());
|
|
setModels(res ?? []);
|
|
}
|
|
|
|
useEffect(() => {
|
|
getModels();
|
|
}, []);
|
|
|
|
return (
|
|
<div className="p-4 md:p-6 overflow-y-auto">
|
|
<Button
|
|
className="mb-4"
|
|
type="primary"
|
|
onClick={() => {
|
|
setIsModalOpen(true);
|
|
}}
|
|
>
|
|
{t('create_model')}
|
|
</Button>
|
|
<div className="flex flex-wrap gap-2 md:gap-4">
|
|
{models.map((item) => (
|
|
<ModelCard info={item} key={item.model_name} />
|
|
))}
|
|
</div>
|
|
<Modal
|
|
width={800}
|
|
open={isModalOpen}
|
|
title={t('create_model')}
|
|
onCancel={() => {
|
|
setIsModalOpen(false);
|
|
}}
|
|
footer={null}
|
|
>
|
|
<ModelForm
|
|
onCancel={() => {
|
|
setIsModalOpen(false);
|
|
}}
|
|
onSuccess={() => {
|
|
setIsModalOpen(false);
|
|
getModels();
|
|
}}
|
|
/>
|
|
</Modal>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default Models;
|