Explorar o código

提示词添加默认值,知识设置增加table切分。

S0025136190 hai 7 meses
pai
achega
91e06aea45

+ 1 - 0
src/apis/index.ts

@@ -85,6 +85,7 @@ export type ModifyDocumentSettingApiParams = {
     documentId: string,
     setSlice: string,
     setAnalyze: string,
+    setTabel: string,
 };
 
 export type FetchSliceListApiParams = {

+ 23 - 2
src/pages/questionAnswer/info/index.tsx

@@ -513,10 +513,31 @@ const QuestionAnswerInfo: React.FC = () => {
                                     </div>
                                     <Divider plain></Divider>
                                     <div >
-                                        <FormItem name='prompt' >
+                                        <FormItem name='prompt' 
+                                        initialValue={`你是一位知识检索助手,你必须并且只能从我发送的众多知识片段中寻找能够解决用户输入问题的最优答案,并且在执行任务的过程中严格执行规定的要求。
+
+知识片段如下:
+{{知识}}
+
+规定要求:
+- 找到答案就仅使用知识片段中的原文回答用户的提问;
+- 找不到答案就用自身知识并且告诉用户该信息不是来自文档;
+- 所引用的文本片段中所包含的示意图占位符必须进行返回,占位符格式参考:【示意图序号_编号】
+    - 严禁输出任何知识片段中不存在的示意图占位符;
+    - 输出的内容必须删除其中包含的任何图注、序号等信息。例如:“进入登录页面(图1.1)”需要从文字中删除图序,回复效果为:“进入登录页面”;“如图所示1.1”,回复效果为:“如图所示”;
+- 格式规范
+    - 文档中会出现包含表格的情况,表格是以图片标识符的形式呈现,表格中缺失数据时候返回空单元格;
+    - 如果需要用到表格中的数据,以markdown格式输出表格中的数据;
+    - 避免使用代码块语法回复信息;
+    - 回复的开头语不要输出诸如:“我想”,“我认为”,“think”等相关语义的文本。
+
+严格执行规定要求,不要复述问题,直接开始回答。
+
+用户输入问题:
+{{用户}}`}>
                                             <TextArea
                                                 placeholder="提示词"
-                                                rows={20}
+                                                rows={50}
                                             />
                                         </FormItem>
                                     </div>

+ 26 - 18
src/pages/takai/knowledgeLib/detail/components/InfoModalSetting.tsx

@@ -32,15 +32,15 @@ const InfoModalSetting: React.FC<Props> = (props: Props) => {
         { label: '手机号', value: 'Phone' },
         { label: '银行卡', value: 'Car' },
         { label: '自定义', value: 'Custom' },
-      ];
+    ];
 
     // 获取知识设置详情
     const fetchDetail = async () => {
         try {
             const res = await apis.fetchTakaiDocumentSettingLibApi(props.id);
             console.log(res.data, 'res.data');
-            const { knowledgeId, documentId, setSlice, setAnalyze, sliceValue } = res.data;
-            if(res.data.setSlice === '3'){
+            const { knowledgeId, documentId, setSlice, setAnalyze, sliceValue, setTable } = res.data;
+            if (res.data.setSlice === '3') {
                 setIsVisibleSlice(!isVisibleSlice);
             }
             form.setFieldsValue({
@@ -49,6 +49,7 @@ const InfoModalSetting: React.FC<Props> = (props: Props) => {
                 setSlice: setSlice,
                 setAnalyze: setAnalyze,
                 sliceValue: sliceValue,
+                setTable: setTable,
             });
         } catch (error: any) {
             message.error(error.msg);
@@ -79,13 +80,6 @@ const InfoModalSetting: React.FC<Props> = (props: Props) => {
     const handleClickConfirm = () => {
         form.validateFields().then(async (values) => {
             const data = { ...values };
-            // if (values.knowledge_type === '5') {
-            //     data.custom_separator = ['"\\n"'];
-            //     data.sentence_size = 300;
-            // } else {
-            //     data.sentence_size = 20;
-            //     data.custom_separator = ['"\\n"'];
-            // }
             console.log(data, 'data');
             await onClickConfirm(props.id, data);
         }).catch((error) => {
@@ -126,13 +120,13 @@ const InfoModalSetting: React.FC<Props> = (props: Props) => {
 
                     {isVisibleSlice &&
                         <FormItem
-                        label='分隔符'
-                        name='sliceValue'
-                        rules={[{ required: true, message: '自定义切片设置不能为空' }]}
-                    >
-                        <Input max={1024} 
-                        />
-                    </FormItem>
+                            label='分隔符'
+                            name='sliceValue'
+                            rules={[{ required: true, message: '自定义切片设置不能为空' }]}
+                        >
+                            <Input max={1024}
+                            />
+                        </FormItem>
                     }
 
                     <FormItem
@@ -149,7 +143,21 @@ const InfoModalSetting: React.FC<Props> = (props: Props) => {
                             {/* <Option value='2'>多模态图片理解</Option> */}
                         </Select>
                     </FormItem>
-                    
+
+                    <FormItem
+                        label='table切分'
+                        name='setTable'
+                    >
+                        <Select
+                            style={{ width: '100%' }}
+                            placeholder='请选择解析设置'
+                            allowClear={true}
+                        >
+                            <Option value='0'>table转图片</Option>
+                            <Option value='1'>table转html</Option>
+                        </Select>
+                    </FormItem>
+
                     {/* <FormItem
                         label='隐藏敏感信息'
                         name=''

+ 149 - 128
src/pages/takai/questionAnswer/info/index.tsx

@@ -40,7 +40,7 @@ const QuestionAnswerInfo: React.FC = () => {
                         max={1}
                         onChange={onChange}
                         // value={typeof topPValue === 'number' ? topPValue : 0}
-                        value = {topPValue}
+                        value={topPValue}
                         step={0.1}
                     />
                 </Col>
@@ -318,7 +318,7 @@ const QuestionAnswerInfo: React.FC = () => {
         } else if (value === 'flexib') {
             setTopPValue(0.9);
             setTempValue(0.90);
-        } 
+        }
     }
 
     return (
@@ -497,6 +497,27 @@ const QuestionAnswerInfo: React.FC = () => {
                                     <Divider plain></Divider>
                                     <div >
                                         <FormItem name='prompt'
+                                            initialValue={`你是一位知识检索助手,你必须并且只能从我发送的众多知识片段中寻找能够解决用户输入问题的最优答案,并且在执行任务的过程中严格执行规定的要求。
+
+知识片段如下:
+{{知识}}
+
+规定要求:
+- 找到答案就仅使用知识片段中的原文回答用户的提问;
+- 找不到答案就用自身知识并且告诉用户该信息不是来自文档;
+- 所引用的文本片段中所包含的示意图占位符必须进行返回,占位符格式参考:【示意图序号_编号】
+  - 严禁输出任何知识片段中不存在的示意图占位符;
+  - 输出的内容必须删除其中包含的任何图注、序号等信息。例如:“进入登录页面(图1.1)”需要从文字中删除图序,回复效果为:“进入登录页面”;“如图所示1.1”,回复效果为:“如图所示”;
+- 格式规范
+  - 文档中会出现包含表格的情况,表格是以图片标识符的形式呈现,表格中缺失数据时候返回空单元格;
+  - 如果需要用到表格中的数据,以markdown格式输出表格中的数据;
+  - 避免使用代码块语法回复信息;
+  - 回复的开头语不要输出诸如:“我想”,“我认为”,“think”等相关语义的文本。
+
+严格执行规定要求,不要复述问题,直接开始回答。
+
+用户输入问题:
+{{用户}}`}
                                             rules={[{ required: true, message: '提示词不能为空' }]}>
                                             <TextArea
                                                 placeholder="提示词"
@@ -585,149 +606,149 @@ const QuestionAnswerInfo: React.FC = () => {
                                         }
 
                                         {/* {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='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('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' }}>
-                                                    <div className='questionAnswerInfo-content-title'>重排方式</div>
-                                                </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: isVisible ? 'block' : 'none', paddingTop: '20px' }}>
+                                            {isVisibleCus &&
+                                                <Space style={{ width: '100%' }} direction="vertical">
                                                     <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
                                                         <FormItem
-                                                            label='模型选择'
-                                                            name='rerank_model_name'
+                                                            label='Top-p'
+                                                            name='topP'
+                                                            style={{ width: '300px' }}
                                                         >
-                                                            <Select
-                                                                style={{ width: '300px', height: '48px' }}
-                                                                placeholder='请选择模型'
-                                                            // defaultValue={'rerank'}
-                                                            >
-                                                                <Option value='rerank'>默认rerank模型</Option>
-                                                            </Select>
+                                                            <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('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' }}>
+                                                <div className='questionAnswerInfo-content-title'>重排方式</div>
+                                            </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>
@@ -736,7 +757,7 @@ const QuestionAnswerInfo: React.FC = () => {
                     </div>
                 </Form>
             </Spin>
-        </div>
+        </div >
     );
 };