balibabu
commited on
Commit
·
477a90e
1
Parent(s):
95da4bf
feat: Added auto_keywords and auto_questions fields to the parsing configuration page #2687 (#2987)
Browse files### What problem does this PR solve?
feat: Added auto_keywords and auto_questions fields to the parsing
configuration page #2687
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- web/src/components/auto-keywords-item.tsx +36 -0
- web/src/components/chunk-method-modal/hooks.ts +11 -1
- web/src/components/chunk-method-modal/index.tsx +10 -1
- web/src/locales/en.ts +4 -0
- web/src/locales/zh-traditional.ts +4 -0
- web/src/locales/zh.ts +4 -0
- web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx +13 -0
web/src/components/auto-keywords-item.tsx
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { useTranslate } from '@/hooks/common-hooks';
|
2 |
+
import { Form, InputNumber } from 'antd';
|
3 |
+
|
4 |
+
const style = {
|
5 |
+
width: '100%',
|
6 |
+
};
|
7 |
+
|
8 |
+
export const AutoKeywordsItem = () => {
|
9 |
+
const { t } = useTranslate('knowledgeDetails');
|
10 |
+
|
11 |
+
return (
|
12 |
+
<Form.Item
|
13 |
+
label={t('autoKeywords')}
|
14 |
+
name={['parser_config', 'auto_keywords']}
|
15 |
+
tooltip={t('autoKeywordsTip')}
|
16 |
+
initialValue={0}
|
17 |
+
>
|
18 |
+
<InputNumber style={style}></InputNumber>
|
19 |
+
</Form.Item>
|
20 |
+
);
|
21 |
+
};
|
22 |
+
|
23 |
+
export const AutoQuestionsItem = () => {
|
24 |
+
const { t } = useTranslate('knowledgeDetails');
|
25 |
+
|
26 |
+
return (
|
27 |
+
<Form.Item
|
28 |
+
label={t('autoQuestions')}
|
29 |
+
name={['parser_config', 'auto_questions']}
|
30 |
+
tooltip={t('autoQuestionsTip')}
|
31 |
+
initialValue={0}
|
32 |
+
>
|
33 |
+
<InputNumber style={style}></InputNumber>
|
34 |
+
</Form.Item>
|
35 |
+
);
|
36 |
+
};
|
web/src/components/chunk-method-modal/hooks.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import { useHandleChunkMethodSelectChange } from '@/hooks/logic-hooks';
|
2 |
import { useSelectParserList } from '@/hooks/user-setting-hooks';
|
3 |
import { FormInstance } from 'antd';
|
4 |
-
import { useEffect, useMemo, useState } from 'react';
|
5 |
|
6 |
const ParserListMap = new Map([
|
7 |
[
|
@@ -118,3 +118,13 @@ export const useFetchParserListOnMount = (
|
|
118 |
|
119 |
return { parserList: nextParserList, handleChange, selectedTag };
|
120 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import { useHandleChunkMethodSelectChange } from '@/hooks/logic-hooks';
|
2 |
import { useSelectParserList } from '@/hooks/user-setting-hooks';
|
3 |
import { FormInstance } from 'antd';
|
4 |
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
5 |
|
6 |
const ParserListMap = new Map([
|
7 |
[
|
|
|
118 |
|
119 |
return { parserList: nextParserList, handleChange, selectedTag };
|
120 |
};
|
121 |
+
|
122 |
+
const hideAutoKeywords = ['qa', 'table', 'resume', 'knowledge_graph'];
|
123 |
+
|
124 |
+
export const useShowAutoKeywords = () => {
|
125 |
+
const showAutoKeywords = useCallback((selectedTag: string) => {
|
126 |
+
return hideAutoKeywords.every((x) => selectedTag !== x);
|
127 |
+
}, []);
|
128 |
+
|
129 |
+
return showAutoKeywords;
|
130 |
+
};
|
web/src/components/chunk-method-modal/index.tsx
CHANGED
@@ -17,11 +17,12 @@ import {
|
|
17 |
} from 'antd';
|
18 |
import omit from 'lodash/omit';
|
19 |
import React, { useEffect, useMemo } from 'react';
|
20 |
-
import { useFetchParserListOnMount } from './hooks';
|
21 |
|
22 |
import { useTranslate } from '@/hooks/common-hooks';
|
23 |
import { IParserConfig } from '@/interfaces/database/document';
|
24 |
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
|
|
25 |
import Delimiter from '../delimiter';
|
26 |
import EntityTypesItem from '../entity-types-item';
|
27 |
import ExcelToHtml from '../excel-to-html';
|
@@ -108,6 +109,8 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
|
108 |
const showExcelToHtml =
|
109 |
selectedTag === 'naive' && documentExtension === 'xlsx';
|
110 |
|
|
|
|
|
111 |
const afterClose = () => {
|
112 |
form.resetFields();
|
113 |
};
|
@@ -283,6 +286,12 @@ const ChunkMethodModal: React.FC<IProps> = ({
|
|
283 |
<Delimiter></Delimiter>
|
284 |
</>
|
285 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
{showExcelToHtml && <ExcelToHtml></ExcelToHtml>}
|
287 |
{showRaptorParseConfiguration(selectedTag) && (
|
288 |
<ParseConfiguration></ParseConfiguration>
|
|
|
17 |
} from 'antd';
|
18 |
import omit from 'lodash/omit';
|
19 |
import React, { useEffect, useMemo } from 'react';
|
20 |
+
import { useFetchParserListOnMount, useShowAutoKeywords } from './hooks';
|
21 |
|
22 |
import { useTranslate } from '@/hooks/common-hooks';
|
23 |
import { IParserConfig } from '@/interfaces/database/document';
|
24 |
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
25 |
+
import { AutoKeywordsItem, AutoQuestionsItem } from '../auto-keywords-item';
|
26 |
import Delimiter from '../delimiter';
|
27 |
import EntityTypesItem from '../entity-types-item';
|
28 |
import ExcelToHtml from '../excel-to-html';
|
|
|
109 |
const showExcelToHtml =
|
110 |
selectedTag === 'naive' && documentExtension === 'xlsx';
|
111 |
|
112 |
+
const showAutoKeywords = useShowAutoKeywords();
|
113 |
+
|
114 |
const afterClose = () => {
|
115 |
form.resetFields();
|
116 |
};
|
|
|
286 |
<Delimiter></Delimiter>
|
287 |
</>
|
288 |
)}
|
289 |
+
{showAutoKeywords(selectedTag) && (
|
290 |
+
<>
|
291 |
+
<AutoKeywordsItem></AutoKeywordsItem>
|
292 |
+
<AutoQuestionsItem></AutoQuestionsItem>
|
293 |
+
</>
|
294 |
+
)}
|
295 |
{showExcelToHtml && <ExcelToHtml></ExcelToHtml>}
|
296 |
{showRaptorParseConfiguration(selectedTag) && (
|
297 |
<ParseConfiguration></ParseConfiguration>
|
web/src/locales/en.ts
CHANGED
@@ -154,6 +154,10 @@ export default {
|
|
154 |
delimiter: `Delimiter`,
|
155 |
html4excel: 'Excel to HTML',
|
156 |
html4excelTip: `Excel will be parsed into HTML table or not. If it's FALSE, every row in Excel will be formed as a chunk.`,
|
|
|
|
|
|
|
|
|
157 |
},
|
158 |
knowledgeConfiguration: {
|
159 |
titleDescription:
|
|
|
154 |
delimiter: `Delimiter`,
|
155 |
html4excel: 'Excel to HTML',
|
156 |
html4excelTip: `Excel will be parsed into HTML table or not. If it's FALSE, every row in Excel will be formed as a chunk.`,
|
157 |
+
autoKeywords: 'Auto keywords',
|
158 |
+
autoKeywordsTip: `Extract N keywords for every chunk to boost their rank score while querying such keywords. Extra tokens will be comsumed for LLM that you set in 'System model settings'. You can check the result in the chunk list.`,
|
159 |
+
autoQuestions: 'Auto questions',
|
160 |
+
autoQuestionsTip: `Extract N questions for every chunk to boost their rank score while querying such questions. Extra tokens will be comsumed for LLM that you set in 'System model settings'. You can check the result in the chunk list. This function will not destroy the entire chunking process if errors occur except adding empty result to the original chunk.`,
|
161 |
},
|
162 |
knowledgeConfiguration: {
|
163 |
titleDescription:
|
web/src/locales/zh-traditional.ts
CHANGED
@@ -150,6 +150,10 @@ export default {
|
|
150 |
delimiter: `分段標識符`,
|
151 |
html4excel: '表格轉HTML',
|
152 |
html4excelTip: `Excel 是否會被解析為 HTML 表格。如果為 FALSE,Excel 中的每一行都會形成一個區塊。`,
|
|
|
|
|
|
|
|
|
153 |
},
|
154 |
knowledgeConfiguration: {
|
155 |
titleDescription: '在這裡更新您的知識庫詳細信息,尤其是解析方法。',
|
|
|
150 |
delimiter: `分段標識符`,
|
151 |
html4excel: '表格轉HTML',
|
152 |
html4excelTip: `Excel 是否會被解析為 HTML 表格。如果為 FALSE,Excel 中的每一行都會形成一個區塊。`,
|
153 |
+
autoKeywords: '自動關鍵字',
|
154 |
+
autoKeywordsTip: `在查詢此類關鍵字時,為每個區塊提取 N 個關鍵字以提高其排名分數。在「系統模型設定」中設定的 LLM 將消耗額外的 token。您可以在區塊清單中查看結果。 `,
|
155 |
+
autoQuestions: '自動問題',
|
156 |
+
autoQuestionsTip: `在查詢此類問題時,為每個區塊提取 N 個問題以提高其排名分數。在「系統模型設定」中設定的 LLM 將消耗額外的 token。您可以在區塊清單中查看結果。如果發生錯誤,此功能不會破壞整個分塊過程,除了將空結果新增至原始區塊。 `,
|
157 |
},
|
158 |
knowledgeConfiguration: {
|
159 |
titleDescription: '在這裡更新您的知識庫詳細信息,尤其是解析方法。',
|
web/src/locales/zh.ts
CHANGED
@@ -151,6 +151,10 @@ export default {
|
|
151 |
delimiter: `分段标识符`,
|
152 |
html4excel: '表格转HTML',
|
153 |
html4excelTip: `Excel 是否将被解析为 HTML 表。如果为 FALSE,Excel 中的每一行都将形成一个块。`,
|
|
|
|
|
|
|
|
|
154 |
},
|
155 |
knowledgeConfiguration: {
|
156 |
titleDescription: '在这里更新您的知识库详细信息,尤其是解析方法。',
|
|
|
151 |
delimiter: `分段标识符`,
|
152 |
html4excel: '表格转HTML',
|
153 |
html4excelTip: `Excel 是否将被解析为 HTML 表。如果为 FALSE,Excel 中的每一行都将形成一个块。`,
|
154 |
+
autoKeywords: '自动关键词',
|
155 |
+
autoKeywordsTip: `在查询此类关键词时,为每个块提取 N 个关键词以提高其排名得分。在“系统模型设置”中设置的 LLM 将消耗额外的 token。您可以在块列表中查看结果。`,
|
156 |
+
autoQuestions: '自动问题',
|
157 |
+
autoQuestionsTip: `在查询此类问题时,为每个块提取 N 个问题以提高其排名得分。在“系统模型设置”中设置的 LLM 将消耗额外的 token。您可以在块列表中查看结果。如果发生错误,此功能不会破坏整个分块过程,除了将空结果添加到原始块。`,
|
158 |
},
|
159 |
knowledgeConfiguration: {
|
160 |
titleDescription: '在这里更新您的知识库详细信息,尤其是解析方法。',
|
web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx
CHANGED
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import Delimiter from '@/components/delimiter';
|
2 |
import EntityTypesItem from '@/components/entity-types-item';
|
3 |
import ExcelToHtml from '@/components/excel-to-html';
|
@@ -27,6 +32,7 @@ const ConfigurationForm = ({ form }: { form: FormInstance }) => {
|
|
27 |
useFetchKnowledgeConfigurationOnMount(form);
|
28 |
const { t } = useTranslate('knowledgeConfiguration');
|
29 |
const handleChunkMethodSelectChange = useHandleChunkMethodSelectChange(form);
|
|
|
30 |
|
31 |
return (
|
32 |
<Form form={form} name="validateOnly" layout="vertical" autoComplete="off">
|
@@ -120,6 +126,12 @@ const ConfigurationForm = ({ form }: { form: FormInstance }) => {
|
|
120 |
<Delimiter></Delimiter>
|
121 |
</>
|
122 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
{parserId === 'naive' && (
|
124 |
<>
|
125 |
<MaxTokenNumber></MaxTokenNumber>
|
@@ -128,6 +140,7 @@ const ConfigurationForm = ({ form }: { form: FormInstance }) => {
|
|
128 |
<ExcelToHtml></ExcelToHtml>
|
129 |
</>
|
130 |
)}
|
|
|
131 |
{showRaptorParseConfiguration(parserId) && (
|
132 |
<ParseConfiguration></ParseConfiguration>
|
133 |
)}
|
|
|
1 |
+
import {
|
2 |
+
AutoKeywordsItem,
|
3 |
+
AutoQuestionsItem,
|
4 |
+
} from '@/components/auto-keywords-item';
|
5 |
+
import { useShowAutoKeywords } from '@/components/chunk-method-modal/hooks';
|
6 |
import Delimiter from '@/components/delimiter';
|
7 |
import EntityTypesItem from '@/components/entity-types-item';
|
8 |
import ExcelToHtml from '@/components/excel-to-html';
|
|
|
32 |
useFetchKnowledgeConfigurationOnMount(form);
|
33 |
const { t } = useTranslate('knowledgeConfiguration');
|
34 |
const handleChunkMethodSelectChange = useHandleChunkMethodSelectChange(form);
|
35 |
+
const showAutoKeywords = useShowAutoKeywords();
|
36 |
|
37 |
return (
|
38 |
<Form form={form} name="validateOnly" layout="vertical" autoComplete="off">
|
|
|
126 |
<Delimiter></Delimiter>
|
127 |
</>
|
128 |
)}
|
129 |
+
{showAutoKeywords(parserId) && (
|
130 |
+
<>
|
131 |
+
<AutoKeywordsItem></AutoKeywordsItem>
|
132 |
+
<AutoQuestionsItem></AutoQuestionsItem>
|
133 |
+
</>
|
134 |
+
)}
|
135 |
{parserId === 'naive' && (
|
136 |
<>
|
137 |
<MaxTokenNumber></MaxTokenNumber>
|
|
|
140 |
<ExcelToHtml></ExcelToHtml>
|
141 |
</>
|
142 |
)}
|
143 |
+
|
144 |
{showRaptorParseConfiguration(parserId) && (
|
145 |
<ParseConfiguration></ParseConfiguration>
|
146 |
)}
|