Procházet zdrojové kódy

应用类型修改,展示。

S0025136190 před 5 měsíci
rodič
revize
cdc9a08c86

+ 7 - 0
src/apis/index.ts

@@ -154,6 +154,7 @@ export type FetchTakaiChatHistoryListApi = (data: FetchChatHistoryListApiParams)
 export type ExportTakaiChatHistoryApi = (id: string) => Promise<any>;
 export type FetchTakaiApplicationListApi = () => Promise<any>;
 export type addTakaiSliceLibApi = (data: addAndModifySliceApiParams) => Promise<any>;
+export type FetchTakaiAppTypeListApi = (dictType: string) => Promise<any>;
 
 // 登录
 const loginApi: LoginApi = async (data) => {
@@ -406,6 +407,11 @@ const addTakaiSliceApi: addTakaiSliceLibApi = async (data) => {
     return api.post(`/deepseek/api/add/slice/`, data);
 };
 
+// takai应用类型列表
+const fetchTakaiAppTypeListApi: FetchTakaiAppTypeListApi = async (dictType) => {
+    return api.get(`/deepseek/api/${dictType}`);
+};
+
 export const apis = {
     login: loginApi,
     logout: logoutApi,
@@ -457,4 +463,5 @@ export const apis = {
     exportTakaiChatHistory: exportTakaiChatHistoryApi,
     fetchTakaiApplicationList: fetchTakaiApplicationListApi,
     addTakaiSlice: addTakaiSliceApi,
+    fetchTakaiAppTypeList: fetchTakaiAppTypeListApi,
 };

+ 43 - 0
src/pages/takai/questionAnswer/info/index.tsx

@@ -102,6 +102,11 @@ const QuestionAnswerInfo: React.FC = () => {
         value: string,
     }[];
 
+    type AppTypeList = {
+        label: string,
+        value: string,
+    }[];
+
     const [step, setStep] = React.useState(1);
     const [pageLoading, setPageLoading] = React.useState(false);
     const [modelList, setModelList] = React.useState<ModelList>([]);
@@ -111,6 +116,7 @@ const QuestionAnswerInfo: React.FC = () => {
     const [isVisibleSlice, setIsVisibleSlice] = React.useState(false);
     const [isVisibleRerank, setIsVisibleRerank] = React.useState(false);
     const [name, setName] = React.useState('');
+    const [appTypeList, setAppTypeList] = React.useState<AppTypeList>([]);
 
     const style: React.CSSProperties = {
         display: 'flex',
@@ -124,6 +130,7 @@ const QuestionAnswerInfo: React.FC = () => {
     const init = async (id: string) => {
         await Promise.all([
             api.fetchKnowlegde(),
+            api.fetchAppType(),
             // api.fetchModelList(),
         ])
         if (id) {
@@ -248,6 +255,7 @@ const QuestionAnswerInfo: React.FC = () => {
                     questionList: sd, //问题列表
                     max_token: info.maxToken, //应用最大token
                     updateDate: info.updateDate, // 更新时间
+                    typeId: info.typeId, //应用类型
 
                     param_desc: data_info.param_desc, //回答风格
                     show_recall_result: data_info.show_recall_result, //是否展示召回结果
@@ -289,6 +297,22 @@ const QuestionAnswerInfo: React.FC = () => {
             }
         },
 
+        // 获取应用类型
+        fetchAppType: async () => {
+            try {
+                const res = await apis.fetchTakaiAppTypeList('app_type');
+                const list = res.data.map((item: any) => {
+                    return {
+                        label: item.dictLabel,
+                        value: item.dictCode,
+                    }
+                });
+                setAppTypeList(list);
+            } catch (error: any) {
+                console.error(error);
+            }
+        },
+
         // 获取模型列表
         fetchModelList: async () => {
             try {
@@ -340,6 +364,24 @@ const QuestionAnswerInfo: React.FC = () => {
                             <Input placeholder="应用名称" style={{ width: 646, padding: 8 }} />
                         </FormItem>
 
+                        <FormItem
+                            label='应用类型'
+                            name='typeId'
+                            >
+                            <Select
+                                style={{ width: '300px', height: '48px' }}
+                                placeholder='请选择知识库'
+                            >
+                                {
+                                    appTypeList.map((item, index) => {
+                                        return <Option value={item.value} key={index}>
+                                            {item.label}
+                                        </Option>
+                                    })
+                                }
+                            </Select>
+                        </FormItem>
+
                         <FormItem
                             label='问答应用描述'
                             name='desc'
@@ -454,6 +496,7 @@ const QuestionAnswerInfo: React.FC = () => {
                                                 questionList: question,
                                                 knowledge_info: JSON.stringify(data_info),
                                                 max_token: values.max_token, //应用最大token
+                                                typeId: values.typeId, // 应用类型
                                             };
                                             const id = location?.state?.id;
                                             let res = null;

+ 52 - 7
src/pages/takai/questionAnswer/list/index.tsx

@@ -1,6 +1,6 @@
 import * as React from 'react';
 import { observer } from 'mobx-react';
-import { List, Button, Divider, Flex, Layout, Empty, Image, Modal } from 'antd';
+import { List, Button, Divider, Flex, Layout, Empty, Image, Modal, Tag } from 'antd';
 import { PlusOutlined, FileOutlined, SettingOutlined, DeleteOutlined } from '@ant-design/icons';
 import { apis } from '@/apis';
 import './style.less';
@@ -49,6 +49,7 @@ const QuestionAnswerList: React.FC = () => {
         desc: string,
         appId: number,
         createBy: string,
+        typeId: string;
     };
 
     interface PageInfo {
@@ -57,6 +58,11 @@ const QuestionAnswerList: React.FC = () => {
         total: number,
     };
 
+    type AppTypeList = {
+        label: string,
+        value: string,
+    }[];
+
     const [listLoading, setListLoading] = React.useState(false);
     const [list, setList] = React.useState<Item[]>([]);
     const [page, setPage] = React.useState<PageInfo>({
@@ -67,6 +73,7 @@ const QuestionAnswerList: React.FC = () => {
     const [appCount, setAppCount] = React.useState<string>();
     const [knowCount, setKnowCount] = React.useState<string>();
     const { Header, Footer, Sider, Content } = Layout;
+    const [appTypeList, setAppTypeList] = React.useState<AppTypeList>([]);
 
     const appApi = {
         fetchList: async () => {
@@ -82,7 +89,8 @@ const QuestionAnswerList: React.FC = () => {
                         name: item.name,
                         desc: item.desc,
                         appId: item.appId,
-                        createBy: item.createBy
+                        createBy: item.createBy,
+                        typeId: item.typeId,
                     }
                 });
                 setList(list);
@@ -130,11 +138,31 @@ const QuestionAnswerList: React.FC = () => {
                 setListLoading(false);
             }
         }
-    }
+    };
+
+    // 获取应用类型
+    const appTypeApi = {
+        fetchAppType: async () => {
+            try {
+                const res = await apis.fetchTakaiAppTypeList('app_type');
+                const list = res.data.map((item: any) => {
+                    return {
+                        label: item.dictLabel,
+                        value: item.dictCode,
+                    }
+                });
+                setAppTypeList(list);
+            } catch (error: any) {
+                console.error(error);
+            }
+        },
+    };
+
 
     const init = async () => {
         await appApi.fetchList();
         await indexApi.fetchIndex();
+        await appTypeApi.fetchAppType();
     }
 
     React.useEffect(() => {
@@ -257,6 +285,23 @@ const QuestionAnswerList: React.FC = () => {
                                                         <DeleteOutlined /> 删除
                                                     </a>
                                                 </div>
+
+                                                <div>
+                                                    <Tag
+                                                        style={{
+                                                            padding: '4px 8px',
+                                                            fontSize: 14,
+                                                            fontWeight: 'bold',
+                                                            background: '#f0f0f0',
+                                                            border: '1px solid #d9d9d9'
+                                                        }}
+                                                    >
+                                                        {
+                                                            appTypeList
+                                                                .find(item1 => item1.value === item.typeId)?.label || '未分类'
+                                                        }
+                                                    </Tag>
+                                                </div>
                                             </div>
                                         </div>
                                     </List.Item>
@@ -268,10 +313,10 @@ const QuestionAnswerList: React.FC = () => {
                     :
                     <div>
                         <Button type='primary'
-                                icon={<PlusOutlined />}
-                                onClick={() => {
-                                    router.navigate({ pathname: '/deepseek/questionAnswer/create' });
-                                }}>创建问答应用</Button>
+                            icon={<PlusOutlined />}
+                            onClick={() => {
+                                router.navigate({ pathname: '/deepseek/questionAnswer/create' });
+                            }}>创建问答应用</Button>
                         <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
                     </div>