Files
DB-GPT/web/pages/models/index.tsx
明天 d5afa6e206 Native data AI application framework based on AWEL+AGENT (#1152)
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>
2024-02-07 17:43:27 +08:00

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;