Преглед на файлове

智普接口,下拉框切换RAG.

S0025136190 преди 7 месеца
родител
ревизия
c36f6dc446

+ 2 - 1
src/apis/index.ts

@@ -213,7 +213,8 @@ const fetchModelListApi: FetchModelListApi = async () => {
 
 // 知识库列表
 const fetchKnowledgeListApi: FetchKnowledgeApiListApi = async () => {
-    return api.get('/bigmodel/api/applicationList');
+    // return api.get('/bigmodel/api/applicationList');
+    return api.get('/bigmodel/api/knowledgeList');
 };
 
 // 编辑应用

+ 22 - 19
src/pages/layout/components/Header.tsx

@@ -3,6 +3,7 @@ import { Layout, MenuProps, Modal, Dropdown, Select } from 'antd';
 import { CaretDownOutlined, PoweroffOutlined } from '@ant-design/icons';
 import logoSrc from '@/assets/public/logo.png';
 import router from '@/router';
+import { debounce, set } from 'lodash';
 
 const { Header: AntdHeader } = Layout;
 
@@ -10,6 +11,7 @@ interface Props {
     userName: string,
     onClickLogout: () => Promise<any>,
     onSelectChange: (value: number) => void; // 新增回调函数
+    currentMenuType: number;
 };
 
 const Header: React.FC<Props> = (props: Props) => {
@@ -17,13 +19,15 @@ const Header: React.FC<Props> = (props: Props) => {
         userName,
         onClickLogout,
         onSelectChange,
+        currentMenuType
     } = props;
 
     const items: MenuProps['items'] = [
         {
             key: 'logout',
             label: (
-                <a onClick={() => {
+                <a onClick={(e) => {
+                    e.preventDefault(); // 阻止默认行为
                     Modal.confirm({
                         title: '提示',
                         content: '确定退出平台吗?',
@@ -39,27 +43,22 @@ const Header: React.FC<Props> = (props: Props) => {
         }
     ];
 
-    const [selectedFruit, setSelectedFruit] = React.useState(1); // 默认选中
-
     const fruits = [
         { id: 1, name: 'DeepSeek' },
         { id: 2, name: '智普' },
     ];
-
+    const [open, setOpen] = React.useState(false); // 控制下拉框展开状态
+    const onDropdownVisibleChange = (visible: boolean) => {
+        setOpen(visible);
+      };
     const onChange = (value: number) => {
-        setSelectedFruit(value);
-        onSelectChange(value); // 调用回调函数通知父组件
+        // 只调用父组件传递的处理函数
+        onSelectChange(value);
+        if (!open) return; // 确保只在真正选择时触发
+        props.onSelectChange(value);
+        setOpen(false);
     };
 
-    React.useEffect(() => {
-        const currentPath = window.location.pathname;
-        if (currentPath.startsWith('/takai')) {
-            setSelectedFruit(1);
-        } else {
-            setSelectedFruit(2);
-        }
-    }, [window.location.pathname]);
-
     return (
         <AntdHeader className='header'>
             <div className='header-logo' onClick={() => {
@@ -70,13 +69,17 @@ const Header: React.FC<Props> = (props: Props) => {
                     建科•小智后台管理系统
                 </div>
                 <Select style={{ width: 200, marginLeft: 20 }}
-                    value={selectedFruit}
-                    onChange={onChange}
+                    open={open}
+                    value={currentMenuType}
+                    onChange={onSelectChange}
+                    placeholder="请选择"
+                    onDropdownVisibleChange={onDropdownVisibleChange}
+                    onClick={(e) => e.stopPropagation()} // 阻止事件冒泡
                 >
                     {fruits.map(fruit => (
-                        <option key={fruit.id} value={fruit.id}>
+                        <Select.Option key={fruit.id} value={fruit.id}>
                             {fruit.name}
-                        </option>
+                        </Select.Option>
                     ))}
                 </Select>
             </div>

+ 29 - 44
src/pages/layout/components/Nav.tsx

@@ -11,7 +11,6 @@ import router from '@/router';
 import { JSX } from 'react/jsx-runtime';
 
 const Sider = Layout.Sider;
-// const { Option } = Select;
 
 interface MenuItem {
     key: string;
@@ -27,6 +26,7 @@ interface Props {
     onOpenChange: (openKeys: string[]) => void,
     collapsed: boolean,
     onClickCollapsed: () => void,
+    menuType: number; // 新增 prop
 };
 
 const Nav: React.FC<Props> = (props: Props) => {
@@ -37,29 +37,30 @@ const Nav: React.FC<Props> = (props: Props) => {
         openKeys,
         onOpenChange,
         collapsed,
-        onClickCollapsed
+        onClickCollapsed,
+        menuType
     } = props;
 
-    // const dsItems: MenuItem[] = [
-    //     {
-    //         key: '/takai/questionAnswer',
-    //         icon: <RobotOutlined />,
-    //         label: 'DeepSeek问答应用',
-    //         onClick: () => { router.navigate({ pathname: '/takai/questionAnswer' }) }
-    //     },
-    //     {
-    //         key: '/takai/knowledgeLib',
-    //         icon: <ReadOutlined />,
-    //         label: 'DeepSeek知识库',
-    //         onClick: () => { router.navigate({ pathname: '/takai/knowledgeLib' }) }
-    //     },
-    //     {
-    //         key: '/takai/dataExport',
-    //         icon: <FileSearchOutlined />,
-    //         label: 'DeepSeek数据导出',
-    //         onClick: () => { router.navigate({ pathname: '/takai/dataExport' }) }
-    //     },
-    // ];
+    const dsItems: MenuItem[] = [
+        {
+            key: '/takai/questionAnswer',
+            icon: <RobotOutlined />,
+            label: 'DeepSeek问答应用',
+            onClick: () => { router.navigate({ pathname: '/takai/questionAnswer' }) }
+        },
+        {
+            key: '/takai/knowledgeLib',
+            icon: <ReadOutlined />,
+            label: 'DeepSeek知识库',
+            onClick: () => { router.navigate({ pathname: '/takai/knowledgeLib' }) }
+        },
+        {
+            key: '/takai/dataExport',
+            icon: <FileSearchOutlined />,
+            label: 'DeepSeek数据导出',
+            onClick: () => { router.navigate({ pathname: '/takai/dataExport' }) }
+        },
+    ];
 
     const zpItems: MenuItem[] = [
         {
@@ -82,31 +83,15 @@ const Nav: React.FC<Props> = (props: Props) => {
         }
     ];
 
-    const [items, setItems] = React.useState<MenuItem[]>(zpItems);
-    // const [selectedFruit, setSelectedFruit] = React.useState(2); // 默认选中
 
-    const fruits = [
-        { id: 1, name: 'DeepSeek' },
-        { id: 2, name: '智普' },
-    ];
-
-    // const onChange = (value: number) => {
-    //     console.log(value, 'value');
-    //     if (value === 1) {
-    //         setSelectedFruit(1);
-    //         setItems(dsItems);
-    //         router.navigate({ pathname: '/takai/questionAnswer' });
-    //     } else {
-    //         setSelectedFruit(2);
-    //         setItems(zpItems);
-    //         router.navigate({ pathname: '/questionAnswer' });
-    //     }
-    // };
+    const items = menuType === 1 ? dsItems : zpItems;
 
     React.useEffect(() => {
-        router.navigate({ pathname: '/questionAnswer' });
-    }, []);
-
+        // 当selectedKey变化时,确保路由同步
+        if (selectedKey && !window.location.pathname.startsWith(selectedKey)) {
+            router.navigate(selectedKey);
+        }
+    }, [selectedKey]);
 
     return (
         <Sider

+ 41 - 29
src/pages/layout/index.tsx

@@ -1,10 +1,9 @@
 import * as React from 'react';
-import { useMatches, useLocation, Outlet } from 'react-router-dom';
+import { useMatches, useLocation, Outlet, useNavigate } from 'react-router-dom';
 import { observer } from 'mobx-react';
 import { Layout } from 'antd';
 import Header from './components/Header';
 import Nav from './components/Nav';
-import NavDeepSeek from './components/NavDeepSeek';
 import Breadcrumb from './components/Breadcrumb';
 import store from './store';
 import './style.less';
@@ -13,6 +12,7 @@ import router from '@/router';
 const { Content } = Layout;
 
 const LayoutApp: React.FC = () => {
+    const navigate = useNavigate(); // 添加useNavigate hook
     const {
         state,
         onClickLogout,
@@ -48,18 +48,40 @@ const LayoutApp: React.FC = () => {
         return () => reset();
     }, []);
 
-    const [selectedValue, setSelectedValue] = React.useState(1);
+    // 统一管理菜单类型状态
+    const [menuType, setMenuType] = React.useState(() => {
+        const currentPath = window.location.pathname;
+        return currentPath.startsWith('/takai') ? 1 : 2;
+    });
 
+    // 监听路由变化,同步菜单类型
+    React.useEffect(() => {
+        const type = location.pathname.startsWith('/takai') ? 1 : 2;
+        setMenuType(type);
+    }, [location.pathname]);
+
+    // 处理菜单类型变化
     const handleSelectChange = (value: number) => {
-        setSelectedValue(value);
+        const defaultPath = value === 1 
+            ? '/takai/questionAnswer' 
+            : '/questionAnswer';
+        
+        // 使用navigate进行路由跳转
+        navigate(defaultPath);
+        
+        // 同时更新selectedKey
+        onChangeSelectedKey(defaultPath, 1);
     };
 
+    // 添加路由变化监听
     React.useEffect(() => {
-        const currentPath = location.pathname;
-        if (currentPath.startsWith('/takai')) {
-            setSelectedValue(1);
-        } else {
-            setSelectedValue(2);
+        const path = location.pathname;
+        const type = path.startsWith('/takai') ? 1 : 2;
+        setMenuType(type);
+        
+        // 确保selectedKey与当前路由同步
+        if (path !== selectedKey) {
+            onChangeSelectedKey(path, 1);
         }
     }, [location.pathname]);
 
@@ -70,32 +92,22 @@ const LayoutApp: React.FC = () => {
                     userName={userName}
                     onClickLogout={onClickLogout}
                     onSelectChange={handleSelectChange} // 传递回调函数
+                    currentMenuType={menuType}
                 />
             </div>
 
             <Layout>
                 {
-                    selectedValue === 1 ? (
-                        <NavDeepSeek
-                            selectedKey={selectedKey}
-                            onChangeSelectedKey={onChangeSelectedKey}
-                            openKeys={openKeys}
-                            onOpenChange={onOpenChange}
-                            collapsed={collapsed}
-                            onClickCollapsed={onClickCollapsed}
-                        />
-                    ) : (
-                        <Nav
-                            selectedKey={selectedKey}
-                            onChangeSelectedKey={onChangeSelectedKey}
-                            openKeys={openKeys}
-                            onOpenChange={onOpenChange}
-                            collapsed={collapsed}
-                            onClickCollapsed={onClickCollapsed}
-                        />
-                    )
+                    <Nav
+                        selectedKey={selectedKey}
+                        onChangeSelectedKey={onChangeSelectedKey}
+                        openKeys={openKeys}
+                        onOpenChange={onOpenChange}
+                        collapsed={collapsed}
+                        onClickCollapsed={onClickCollapsed}
+                        menuType={menuType} // 新增 prop
+                    />
                 }
-
                 <Layout>
                     {
                         location.pathname === '/404' ?

+ 257 - 191
src/pages/questionAnswer/info/index.tsx

@@ -39,7 +39,8 @@ const QuestionAnswerInfo: React.FC = () => {
                         min={0}
                         max={1}
                         onChange={onChange}
-                        value={typeof topPValue === 'number' ? topPValue : 0}
+                        // value={typeof topPValue === 'number' ? topPValue : 0}
+                        value={topPValue}
                         step={0.1}
                     />
                 </Col>
@@ -73,7 +74,8 @@ const QuestionAnswerInfo: React.FC = () => {
                         min={0}
                         max={1}
                         onChange={onChange}
-                        value={typeof tempValue === 'number' ? tempValue : 0}
+                        // value={typeof tempValue === 'number' ? tempValue : 0}
+                        value={tempValue}
                         step={0.01}
                     />
                 </Col>
@@ -157,21 +159,21 @@ const QuestionAnswerInfo: React.FC = () => {
     //     console.log('changed', value);
     // };
 
-    // const onChangeShow = (checked: boolean) => {
-    //     console.log(`switch to ${checked}`);
-    // };
+    const onChangeShow = (checked: boolean) => {
+        console.log(`switch to ${checked}`);
+    };
 
-    // const onChangeModel = (checked: boolean) => {
-    //     setIsVisibleRerank(!isVisibleRerank);
-    // };
+    const onChangeModel = (checked: boolean) => {
+        setIsVisibleRerank(!isVisibleRerank);
+    };
 
-    // const onChangeCount = (value: string) => {
-    //     if (value === 'fixed') {
-    //         setIsVisibleSlice(!isVisibleSlice);
-    //     } else {
-    //         setIsVisibleSlice(false);
-    //     }
-    // };
+    const onChangeCount = (value: string) => {
+        if (value === 'fixed') {
+            setIsVisibleSlice(!isVisibleSlice);
+        } else {
+            setIsVisibleSlice(false);
+        }
+    };
 
     // 召回方式
     const onChangeRecallMethod = (e: RadioChangeEvent) => {
@@ -184,60 +186,84 @@ const QuestionAnswerInfo: React.FC = () => {
             setPageLoading(true);
             try {
                 const res = await apis.fetchApplicationDetail(app_id)
+                console.log(res.data);
                 const sd = res.data.questionlist.map((item: any, index: number) => {
                     return {
                         "id": index + 1,
                         "value": item.question,
                     }
                 });
+
                 const info = res.data.detail;
-                if (info.paramDesc === 'custom') {
-                    setIsVisibleCus(!isVisibleCus);    //自定义回答风格
-                }
-                // if (jsonObj.rerank_status === 1) {
-                //     setIsVisibleRerank(!isVisibleRerank) //模型
-                // }
-                // //召回切片数量
-                // if (jsonObj.slice_config_type === 'fixed') {
-                //     setIsVisibleSlice(!isVisibleSlice);
-                // }else {
-                //     setIsVisibleSlice(false);
-                // }
-                setTopPValue(info.topP as number);
+                console.log(info, 'info-info');
+                setTopPValue(info.top_p as number);
                 setTempValue(info.temperature as number);
                 setName(info.name);
 
+                interface Item2 {
+                    index_type_id: number,
+                    knowledge_id: string
+                }
+
+                interface Item {
+                    show_recall_result: boolean,
+                    recall_method: string,
+                    rerank_status: boolean,
+                    slice_config_type: string,
+                    slice_count: number,
+                    recall_slice_splicing_method: string,
+                    param_desc: string,
+                    rerank_model_name: string,
+                    rerank_index_type_list: [Item2],
+                    recall_index_type_list: [Item2]
+                }
+                const data_info: Item = JSON.parse(info.knowledgeInfo === '' ? '{}' : info.knowledgeInfo);
+
+                if (data_info && typeof data_info === 'object' && data_info.param_desc === 'custom') {
+                    setIsVisibleCus(!isVisibleCus);    //自定义回答风格
+                }
+                if (data_info && typeof data_info === 'object' && data_info.rerank_status === true) {
+                    setIsVisibleRerank(!isVisibleRerank) //模型
+                }
+                //召回切片数量
+                if (data_info && typeof data_info === 'object' && data_info.slice_config_type === 'fixed') {
+                    setIsVisibleSlice(!isVisibleSlice);
+                } else {
+                    setIsVisibleSlice(false);
+                }
+
                 form.setFieldsValue({
                     id: info.id,
                     name: info.name,  //应用名称
                     desc: info.desc,  //应用描述
                     prompt: info.prompt, //应用提示语
-                    top_p: info.top_p, //topP
-                    temperature: info.temperature, //温度
+                    top_p: info.top_p as number, //topP
+                    temperature: info.temperature as number, //温度
                     knowledge_ids: info.knowledge_ids,
-                    slice_count: info.slice_count,
                     model: info.model,
                     icon_color: info.icon_color,
                     icon_type: info.icon_type,
                     questionList: sd, //问题列表
-                    // max_token: info.max_token, //应用最大token
-                    // updateDate: info.updateDate, // 更新时间
-                    // param_desc: info.paramDesc, //回答风格
-                    // questionList: sd, //问题列表
-                    // knowledge_ids: jsonObj.knowledge_ids, //知识库id
-                    // model: jsonObj.model, //模型名称
-                    // slice_config_type: jsonObj.slice_config_type, //切片类型
-                    // recall_method: jsonObj.recall_method, //召回方式
-                    // slice_count: jsonObj.slice_count, //切片数量
-                    // rerank_model_name: jsonObj.rerank_model_name, //模型名称
-                    // recall_slice_splicing_method: jsonObj.recall_slice_splicing_method,
-                    // rerank_status: jsonObj.rerank_status, //开启rerank
-                    // show_recall_result: jsonObj.show_recall_result, //是否展示召回结果
-                    // recall_index_type_list: jsonObj.recall_index_type_list, //知识库id
-                    // rerank_index_type_list: jsonObj.rerank_index_type_list, //知识库id
+                    max_token: info.maxToken, //应用最大token
+                    updateDate: info.updateDate, // 更新时间
+
+                    param_desc: data_info && data_info.param_desc, //回答风格
+                    show_recall_result: data_info && data_info.show_recall_result, //是否展示召回结果
+                    recall_method: data_info && data_info.recall_method, //召回方式
+                    rerank_status: data_info && data_info.rerank_status, //开启rerank
+                    rerank_model_name: data_info && data_info.rerank_model_name, //模型名称
+                    slice_config_type: data_info && data_info.slice_config_type, // 召回切片数量
+                    slice_count: data_info && data_info.slice_count, // 切片数量
+                    recall_slice_splicing_method: data_info && data_info.recall_slice_splicing_method, // 切片内容
+
+                    // rerank_status = 1 rerank_index_type_list
+                    // recall_method = 'embedding' || 'mixed'  recall_index_type_list
+                    //recall_index_type_list: info.recall_index_type_list, //知识库id
+                    //rerank_index_type_list: info.rerank_index_type_list, //知识库id
                 })
-                console.log(sd, 'sd');
-                setInputs(sd);
+                if (sd.length > 0) {
+                    setInputs(sd);
+                }
             } catch (error) {
                 console.error(error);
             } finally {
@@ -281,6 +307,16 @@ const QuestionAnswerInfo: React.FC = () => {
 
     const handleRedioClick = (value: string) => {
         setIsVisibleCus(false);
+        // if (value === 'strict') {
+        //     setTopPValue(0.5);
+        //     setTempValue(0.10);
+        // } else if (value === 'moderate') {
+        //     setTopPValue(0.7);
+        //     setTempValue(0.50);
+        // } else if (value === 'flexib') {
+        //     setTopPValue(0.9);
+        //     setTempValue(0.90);
+        // } 
     }
 
     return (
@@ -366,38 +402,61 @@ const QuestionAnswerInfo: React.FC = () => {
                                     onClick={() => {
                                         form.validateFields().then(async (values) => {
                                             const data = values;
+                                            // 问题列表
                                             const question: string[] = [];
                                             if (inputs) {
                                                 inputs.map((item, index) => {
                                                     question.push(item.value);
                                                 });
                                             }
-                                            console.log(question, 'question');
+                                            interface Item {
+                                                index_type_id: number,
+                                                knowledge_id: string
+                                            }
+                                            const indexTypeList: Item[] = [];
+                                            if (values.knowledge_ids && values.knowledge_ids.length > 0) {
+                                                values.knowledge_ids.map((item: string, index: any) => {
+                                                    console.log(item, 'item');
+                                                    const index_type: Item = {
+                                                        index_type_id: index,
+                                                        knowledge_id: item,
+                                                    };
+                                                    indexTypeList.push(index_type);
+                                                });
+                                            }
+                                            const data_info = {
+                                                param_desc: values.param_desc === undefined ? '' : values.param_desc, //回答风格
+                                                show_recall_result: values.show_recall_result === undefined ? '' : values.show_recall_result, //是否展示召回结果
+                                                recall_method: values.recall_method === undefined ? '' : values.recall_method, //召回方式
+                                                rerank_status: values.rerank_status === undefined ? 0 : values.rerank_status === true ? 1 : 0, //开启rerank
+                                                rerank_model_name: values.rerank_model_name === undefined ? '' : values.rerank_model_name, //模型名称
+                                                slice_config_type: values.slice_config_type === undefined ? '' : values.slice_config_type, // 召回切片数量
+                                                slice_count: values.slice_count === undefined ? '' : values.slice_count, // 切片数量
+                                                recall_slice_splicing_method: values.recall_slice_splicing_method === undefined ? '' : values.recall_slice_splicing_method, // 切片内容
+                                                rerank_index_type_list: values.rerank_status === true ? indexTypeList : [], //知识库id
+                                                recall_index_type_list: values.recall_method === undefined ? [] : values.recall_method === 'embedding' || 'mixed' ? indexTypeList : [],
+                                                embedding_recall_ratio: 0 //向量化检索比例
+                                                // rerank_status = 1 rerank_index_type_list
+                                                // recall_method = 'embedding' || 'embedding'  recall_index_type_list
+                                            };
+                                            // const knowledgeIds: string[] = [];
+                                            // knowledgeIds.push(values.knowledge_ids);
+                                            console.log(data_info, 'data_info');
                                             const info = {
                                                 id: values.id,
                                                 name: values.name,  //应用名称
                                                 desc: values.desc,  //应用描述
                                                 prompt: values.prompt, //应用提示语
-                                                top_p: values.top_p, //topP
-                                                temperature: values.temperature, //温度
+                                                top_p: topPValue.toString(), //topP
+                                                temperature: tempValue.toString(), //温度
                                                 knowledge_ids: values.knowledge_ids,
                                                 slice_count: values.slice_count,
                                                 model: values.model,
                                                 icon_color: values.icon_color,
                                                 icon_type: values.icon_type,
                                                 questionList: question,
-                                                // knowledge_info: {
-                                                //     model: values.model, // 默认模型名称
-                                                //     knowledge_ids: values.knowledge_ids, // 知识库id列表
-                                                //     slice_config_type: values.slice_config_type, // 切片类型,默认为 fixed
-                                                //     recall_method: values.recall_method, // 召回方式,默认为 embedding
-                                                //     recall_index_type_list: values.recall_index_type_list, // 索引配置类型列表,默认为空数组
-                                                //     slice_count: values.slice_count, // 切片数量,默认为空字符串
-                                                //     rerank_status: values.rerank_status ? 1 : 0, // 是否开启rerank,默认关闭
-                                                //     rerank_model_name: values.rerank_model_name, // 模型名称,默认为空字符串
-                                                //     show_recall_result: values.show_recall_result, // 是否展示召回结果,默认为空字符串
-                                                //     recall_slice_splicing_method: values.recall_slice_splicing_method // 召回切片拼接方式,默认为空字符串
-                                                // }
+                                                knowledge_info: data_info,
+                                                max_token: values.max_token, //应用最大token
                                             };
                                             const id = location?.state?.id;
                                             let res = null;
@@ -411,10 +470,15 @@ const QuestionAnswerInfo: React.FC = () => {
                                             if (res.data.code !== 200) {
                                                 message.error(res.data.message);
                                             } else {
+                                                message.success('修改成功');
                                                 router.navigate({ pathname: '/questionAnswer' });
                                             }
                                         }).catch((error) => {
                                             console.error(error);
+                                            error.errorFields && error.errorFields.map((item: any) => {
+                                                console.log(item, 'item');
+                                                message.error(`字段 ${item.name} ${item.errors[0]}`);
+                                            });
                                         });
                                     }}
                                 >发布应用</Button>
@@ -507,7 +571,7 @@ const QuestionAnswerInfo: React.FC = () => {
                                             </FormItem>
                                         </div>
 
-                                        {/* {
+                                        {
                                             !isVisible &&
                                             <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
                                                 <a onClick={() => {
@@ -517,152 +581,154 @@ const QuestionAnswerInfo: React.FC = () => {
                                                 </a>
                                             </div>
 
-                                        } */}
-
-                                        {/* {isVisible &&
-                                            <div>
-                                                {isVisibleCus &&
-                                                    <Space style={{ width: '100%' }} direction="vertical">
-                                                        <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
-                                                            <FormItem
-                                                                label='Top-p'
-                                                                name='topP'
-                                                                style={{ width: '300px' }}
-                                                            >
-                                                                <TopPDecimalStep />
-                                                            </FormItem>
-                                                        </div>
-                                                        <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
-                                                            <FormItem
-                                                                label='Temperature'
-                                                                name='temperature'
-                                                                style={{ width: '300px' }}
-                                                            >
-                                                                <TempDecimalStep />
-                                                            </FormItem>
-                                                        </div>
-                                                    </Space >
-                                                }
+                                        }
 
-                                                <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
-                                                    <FormItem
-                                                        label='回答风格'
-                                                        name='param_desc'
-                                                        rules={[{ required: true, message: '回答风格不能为空' }]}>
-                                                        <Radio.Group buttonStyle="solid"
-                                                            className='questionAnswerInfo-content-title'>
-                                                            <Radio.Button onClick={() => {
-                                                                handleRedioClick('')
-                                                            }} value='strict'>严谨</Radio.Button>
-                                                            <Radio.Button onClick={() => {
-                                                                handleRedioClick('')
-                                                            }} value='moderate'>适中</Radio.Button>
-                                                            <Radio.Button onClick={() => {
-                                                                handleRedioClick('')
-                                                            }} value='flexib'>发散</Radio.Button>
-                                                            <Radio.Button value='custom'
-                                                                onClick={() => {
-                                                                    setIsVisibleCus(!isVisibleCus);
-                                                                }}
-                                                            >自定义
-                                                            </Radio.Button>
-                                                        </Radio.Group>
-                                                    </FormItem>
-                                                </div>
-                                                <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
-                                                    <FormItem
-                                                        label='展示引用知识'
-                                                        name='show_recall_result'
-                                                        className='questionAnswerInfo-content-title'>
-                                                        <Switch onChange={onChangeShow} />
-                                                    </FormItem>
-                                                </div>
-                                                <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
-                                                    <FormItem
-                                                        label='召回方式'
-                                                        name='recall_method'
-                                                        rules={[{ required: true, message: '召回方式不能为空' }]}>
-
-                                                        <Radio.Group
-                                                            style={style}
-                                                            onChange={onChangeRecallMethod}
-                                                            options={[
-                                                                { value: 'embedding', label: '向量化检索' },
-                                                                { value: 'keyword', label: '关键词检索' },
-                                                                { value: 'mixed', label: '混合检索' },
-                                                            ]}
-                                                        />
-                                                    </FormItem>
-                                                </div>
-                                                <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
-                                                    <p className='questionAnswerInfo-content-title'>重排方式</p>
-
-                                                </div>
-                                                <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
-                                                    <FormItem
-                                                        label='Rerank模型'
-                                                        name='rerank_status'
-                                                        valuePropName='checked'
-                                                        className='questionAnswerInfo-content-title'
-                                                    >
-                                                        <Switch onChange={onChangeModel} />
-                                                    </FormItem>
-                                                </div>
-                                                {isVisibleRerank &&
+                                        {/* {isVisible && */}
+                                        <div style={{ display: isVisible ? 'block' : 'none', paddingTop: '20px' }}>
+                                            {isVisibleCus &&
+                                                <Space style={{ width: '100%' }} direction="vertical">
+                                                    <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
+                                                        <FormItem
+                                                            label='Top-p'
+                                                            name='topP'
+                                                            style={{ width: '300px' }}
+                                                        >
+                                                            <TopPDecimalStep />
+                                                        </FormItem>
+                                                    </div>
                                                     <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
                                                         <FormItem
-                                                            label='模型选择'
-                                                            name='rerank_model_name'
+                                                            label='Temperature'
+                                                            name='temperature'
+                                                            style={{ width: '300px' }}
                                                         >
-                                                            <Select
-                                                                style={{ width: '300px', height: '48px' }}
-                                                                placeholder='请选择模型'
-                                                                defaultValue={'默认rerank模型'}
-                                                            >
-                                                                <Option value='rerank'>默认rerank模型</Option>
-                                                            </Select>
+                                                            <TempDecimalStep />
                                                         </FormItem>
                                                     </div>
-                                                }
+                                                </Space >
+                                            }
+
+                                            <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
+                                                <FormItem
+                                                    label='回答风格'
+                                                    name='param_desc'
+                                                    rules={[{ required: true, message: '回答风格不能为空' }]}>
+                                                    <Radio.Group buttonStyle="solid"
+                                                        className='questionAnswerInfo-content-title'>
+                                                        <Radio.Button onClick={() => {
+                                                            handleRedioClick('strict')
+                                                        }} value='strict'>严谨</Radio.Button>
+                                                        <Radio.Button onClick={() => {
+                                                            handleRedioClick('moderate')
+                                                        }} value='moderate'>适中</Radio.Button>
+                                                        <Radio.Button onClick={() => {
+                                                            handleRedioClick('flexib')
+                                                        }} value='flexib'>发散</Radio.Button>
+                                                        <Radio.Button value='custom'
+                                                            onClick={() => {
+                                                                setIsVisibleCus(!isVisibleCus);
+                                                                setTopPValue(0.1);
+                                                                setTempValue(0.01);
+                                                            }}
+                                                        >自定义
+                                                        </Radio.Button>
+                                                    </Radio.Group>
+                                                </FormItem>
+                                            </div>
+                                            <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
+                                                <FormItem
+                                                    label='展示引用知识'
+                                                    name='show_recall_result'
+                                                    className='questionAnswerInfo-content-title'>
+                                                    <Switch onChange={onChangeShow} />
+                                                </FormItem>
+                                            </div>
+                                            <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
+                                                <FormItem
+                                                    label='召回方式'
+                                                    name='recall_method'
+                                                    rules={[{ required: true, message: '召回方式不能为空' }]}>
+
+                                                    <Radio.Group
+                                                        style={style}
+                                                        onChange={onChangeRecallMethod}
+                                                        options={[
+                                                            { value: 'embedding', label: '向量化检索' },
+                                                            { value: 'keyword', label: '关键词检索' },
+                                                            { value: 'mixed', label: '混合检索' },
+                                                        ]}
+                                                    />
+                                                </FormItem>
+                                            </div>
+                                            <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
+                                                <p className='questionAnswerInfo-content-title'>重排方式</p>
+
+                                            </div>
+                                            <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
+                                                <FormItem
+                                                    label='Rerank模型'
+                                                    name='rerank_status'
+                                                    valuePropName='checked'
+                                                    className='questionAnswerInfo-content-title'
+                                                >
+                                                    <Switch onChange={onChangeModel} />
+                                                </FormItem>
+                                            </div>
+                                            {isVisibleRerank &&
                                                 <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
                                                     <FormItem
-                                                        label='召回切片数量'
-                                                        name='slice_config_type'
-                                                        rules={[{ required: true, message: '召回方式不能为空' }]}>
+                                                        label='模型选择'
+                                                        name='rerank_model_name'
+                                                    >
                                                         <Select
                                                             style={{ width: '300px', height: '48px' }}
-                                                            placeholder='请选择'
-                                                            onChange={onChangeCount}>
-                                                            <Option value="fixed">手动设置</Option>
-                                                            <Option value="customized">自动设置</Option>
+                                                            placeholder='请选择模型'
+                                                            defaultValue={'默认rerank模型'}
+                                                        >
+                                                            <Option value='rerank'>默认rerank模型</Option>
                                                         </Select>
                                                     </FormItem>
                                                 </div>
+                                            }
+                                            <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
+                                                <FormItem
+                                                    label='召回切片数量'
+                                                    name='slice_config_type'
+                                                    rules={[{ required: true, message: '召回方式不能为空' }]}>
+                                                    <Select
+                                                        style={{ width: '300px', height: '48px' }}
+                                                        placeholder='请选择'
+                                                        onChange={onChangeCount}>
+                                                        <Option value="fixed">手动设置</Option>
+                                                        <Option value="customized">自动设置</Option>
+                                                    </Select>
+                                                </FormItem>
+                                            </div>
 
-                                                {isVisibleSlice &&
-                                                    <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
-                                                        <FormItem
-                                                            label='召回切片数'
-                                                            name='slice_count'
-                                                            rules={[{ required: true, message: '切片数不能为空' }]}>
-                                                            <InputNumber max={1024} changeOnWheel className='questionAnswerInfo-content-title' />
-                                                        </FormItem>
-                                                    </div>
-                                                }
+                                            {isVisibleSlice &&
                                                 <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
                                                     <FormItem
-                                                        label='召回切片拼接方式'
-                                                        name='recall_slice_splicing_method'
-                                                    >
-                                                        <TextArea
-                                                            rows={4}
-                                                            className='questionAnswerInfo-content-title'
-                                                            placeholder="请输入内容"
-                                                        />
+                                                        label='召回切片数'
+                                                        name='slice_count'
+                                                        rules={[{ required: true, message: '切片数不能为空' }]}>
+                                                        <InputNumber max={1024} changeOnWheel className='questionAnswerInfo-content-title' />
                                                     </FormItem>
                                                 </div>
+                                            }
+                                            <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
+                                                <FormItem
+                                                    label='召回切片拼接方式'
+                                                    name='recall_slice_splicing_method'
+                                                >
+                                                    <TextArea
+                                                        rows={4}
+                                                        className='questionAnswerInfo-content-title'
+                                                        placeholder="请输入内容"
+                                                    />
+                                                </FormItem>
                                             </div>
-                                        } */}
+                                        </div>
+                                        {/* } */}
                                     </div>
                                 </div>
                             </Splitter.Panel>

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

@@ -473,6 +473,10 @@ const QuestionAnswerInfo: React.FC = () => {
                                             }
                                         }).catch((error) => {
                                             console.error(error);
+                                            error.errorFields && error.errorFields.map((item: any) => {
+                                                console.log(item, 'item');
+                                                message.error(`字段 ${item.name} ${item.errors[0]}`);
+                                            });
                                         });
                                     }}
                                 >发布应用</Button>