Feat: Added toc enhance field to chat and retrieval operator configuration #10436 (#10470)

### What problem does this PR solve?

Feat: Added toc enhance field to chat and retrieval operator
configuration #10436

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-10-10 18:35:43 +08:00
committed by GitHub
parent a50ccf77f9
commit 198e52e990
12 changed files with 33 additions and 4 deletions

View File

@ -0,0 +1,16 @@
import { useTranslation } from 'react-i18next';
import { SwitchFormField } from './switch-fom-field';
type Props = { name: string };
export function TOCEnhanceFormField({ name }: Props) {
const { t } = useTranslation();
return (
<SwitchFormField
name={name}
label={t('chat.tocEnhance')}
tooltip={t('chat.tocEnhanceTip')}
></SwitchFormField>
);
}

View File

@ -537,10 +537,10 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s
setAnOpener: 'Opening greeting', setAnOpener: 'Opening greeting',
setAnOpenerInitial: `Hi! I'm your assistant. What can I do for you?`, setAnOpenerInitial: `Hi! I'm your assistant. What can I do for you?`,
setAnOpenerTip: 'Set an opening greeting for users.', setAnOpenerTip: 'Set an opening greeting for users.',
knowledgeBases: 'Knowledge bases', knowledgeBases: 'Datasets',
knowledgeBasesMessage: 'Please select', knowledgeBasesMessage: 'Please select',
knowledgeBasesTip: knowledgeBasesTip:
'Select the knowledge bases to associate with this chat assistant. An empty knowledge base will not appear in the dropdown list.', 'Select the datasets to associate with this chat assistant. An empty knowledge base will not appear in the dropdown list.',
system: 'System prompt', system: 'System prompt',
systemInitialValue: `You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the knowledge base!" Answers need to consider chat history. systemInitialValue: `You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the knowledge base!" Answers need to consider chat history.
Here is the knowledge base: Here is the knowledge base:
@ -668,6 +668,8 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s
}, },
cancel: 'Cancel', cancel: 'Cancel',
chatSetting: 'Chat setting', chatSetting: 'Chat setting',
tocEnhance: 'TOC enhance',
tocEnhanceTip: ` During the parsing of the document, table of contents information was generated (see the 'Enable Table of Contents Extraction' option in the General method). This allows the large model to return table of contents items relevant to the user's query, thereby using these items to retrieve related chunks and apply weighting to these chunks during the sorting process. This approach is derived from mimicking the behavioral logic of how humans search for knowledge in books.`,
}, },
setting: { setting: {
profile: 'Profile', profile: 'Profile',

View File

@ -660,6 +660,8 @@ General实体和关系提取提示来自 GitHub - microsoft/graphrag基于
chatSetting: '聊天设置', chatSetting: '聊天设置',
avatarHidden: '隐藏头像', avatarHidden: '隐藏头像',
locale: '地区', locale: '地区',
tocEnhance: '目录增强',
tocEnhanceTip: `解析文档时生成了目录信息见General方法的启用目录抽取让大模型返回和用户问题相关的目录项从而利用目录项拿到相关chunk对这些chunk在排序中进行加权。这种方法来源于模仿人类查询书本中知识的行为逻辑`,
}, },
setting: { setting: {
profile: '概要', profile: '概要',

View File

@ -254,6 +254,7 @@ export const initialRetrievalValues = {
...initialSimilarityThresholdValue, ...initialSimilarityThresholdValue,
...initialKeywordsSimilarityWeightValue, ...initialKeywordsSimilarityWeightValue,
use_kg: false, use_kg: false,
toc_enhance: false,
cross_languages: [], cross_languages: [],
outputs: { outputs: {
formalized_content: { formalized_content: {

View File

@ -5,6 +5,7 @@ import { KnowledgeBaseFormField } from '@/components/knowledge-base-item';
import { RAGFlowFormItem } from '@/components/ragflow-form'; import { RAGFlowFormItem } from '@/components/ragflow-form';
import { RerankFormFields } from '@/components/rerank'; import { RerankFormFields } from '@/components/rerank';
import { SimilaritySliderFormField } from '@/components/similarity-slider'; import { SimilaritySliderFormField } from '@/components/similarity-slider';
import { TOCEnhanceFormField } from '@/components/toc-enhance-form-field';
import { TopNFormField } from '@/components/top-n-item'; import { TopNFormField } from '@/components/top-n-item';
import { import {
Form, Form,
@ -39,6 +40,7 @@ export const RetrievalPartialSchema = {
empty_response: z.string(), empty_response: z.string(),
cross_languages: z.array(z.string()), cross_languages: z.array(z.string()),
use_kg: z.boolean(), use_kg: z.boolean(),
toc_enhance: z.boolean(),
}; };
export const FormSchema = z.object({ export const FormSchema = z.object({
@ -119,6 +121,7 @@ function RetrievalForm({ node }: INextOperatorForm) {
<EmptyResponseField></EmptyResponseField> <EmptyResponseField></EmptyResponseField>
<CrossLanguageFormField name="cross_languages"></CrossLanguageFormField> <CrossLanguageFormField name="cross_languages"></CrossLanguageFormField>
<UseKnowledgeGraphFormField name="use_kg"></UseKnowledgeGraphFormField> <UseKnowledgeGraphFormField name="use_kg"></UseKnowledgeGraphFormField>
<TOCEnhanceFormField name="toc_enhance"></TOCEnhanceFormField>
</FormContainer> </FormContainer>
</Collapse> </Collapse>
<Output list={outputList}></Output> <Output list={outputList}></Output>

View File

@ -4,6 +4,7 @@ import { FormContainer } from '@/components/form-container';
import { KnowledgeBaseFormField } from '@/components/knowledge-base-item'; import { KnowledgeBaseFormField } from '@/components/knowledge-base-item';
import { RerankFormFields } from '@/components/rerank'; import { RerankFormFields } from '@/components/rerank';
import { SimilaritySliderFormField } from '@/components/similarity-slider'; import { SimilaritySliderFormField } from '@/components/similarity-slider';
import { TOCEnhanceFormField } from '@/components/toc-enhance-form-field';
import { TopNFormField } from '@/components/top-n-item'; import { TopNFormField } from '@/components/top-n-item';
import { Form } from '@/components/ui/form'; import { Form } from '@/components/ui/form';
import { UseKnowledgeGraphFormField } from '@/components/use-knowledge-graph-item'; import { UseKnowledgeGraphFormField } from '@/components/use-knowledge-graph-item';
@ -53,6 +54,7 @@ const RetrievalForm = () => {
<EmptyResponseField></EmptyResponseField> <EmptyResponseField></EmptyResponseField>
<CrossLanguageFormField name="cross_languages"></CrossLanguageFormField> <CrossLanguageFormField name="cross_languages"></CrossLanguageFormField>
<UseKnowledgeGraphFormField name="use_kg"></UseKnowledgeGraphFormField> <UseKnowledgeGraphFormField name="use_kg"></UseKnowledgeGraphFormField>
<TOCEnhanceFormField name="toc_enhance"></TOCEnhanceFormField>
</FormContainer> </FormContainer>
</Collapse> </Collapse>
</FormWrapper> </FormWrapper>

View File

@ -7,8 +7,6 @@ import {
export function VideoFormFields({ prefix }: OutputFormatFormFieldProps) { export function VideoFormFields({ prefix }: OutputFormatFormFieldProps) {
const modelOptions = useComposeLlmOptionsByModelTypes([ const modelOptions = useComposeLlmOptionsByModelTypes([
LlmModelType.Chat,
LlmModelType.Image2text,
LlmModelType.Speech2text, LlmModelType.Speech2text,
]); ]);

View File

@ -5,6 +5,7 @@ import { KnowledgeBaseFormField } from '@/components/knowledge-base-item';
import { MetadataFilter } from '@/components/metadata-filter'; import { MetadataFilter } from '@/components/metadata-filter';
import { SwitchFormField } from '@/components/switch-fom-field'; import { SwitchFormField } from '@/components/switch-fom-field';
import { TavilyFormField } from '@/components/tavily-form-field'; import { TavilyFormField } from '@/components/tavily-form-field';
import { TOCEnhanceFormField } from '@/components/toc-enhance-form-field';
import { import {
FormControl, FormControl,
FormField, FormField,
@ -109,6 +110,7 @@ export default function ChatBasicSetting() {
label={t('tts')} label={t('tts')}
tooltip={t('ttsTip')} tooltip={t('ttsTip')}
></SwitchFormField> ></SwitchFormField>
<TOCEnhanceFormField name="prompt_config.toc_enhance"></TOCEnhanceFormField>
<TavilyFormField></TavilyFormField> <TavilyFormField></TavilyFormField>
<KnowledgeBaseFormField></KnowledgeBaseFormField> <KnowledgeBaseFormField></KnowledgeBaseFormField>
<MetadataFilter></MetadataFilter> <MetadataFilter></MetadataFilter>

View File

@ -49,6 +49,7 @@ export function ChatSettings({ switchSettingVisible }: ChatSettingsProps) {
parameters: [], parameters: [],
reasoning: false, reasoning: false,
cross_languages: [], cross_languages: [],
toc_enhance: false,
}, },
top_n: 8, top_n: 8,
similarity_threshold: 0.2, similarity_threshold: 0.2,

View File

@ -33,6 +33,7 @@ export function useChatSettingSchema() {
tavily_api_key: z.string().optional(), tavily_api_key: z.string().optional(),
reasoning: z.boolean().optional(), reasoning: z.boolean().optional(),
cross_languages: z.array(z.string()).optional(), cross_languages: z.array(z.string()).optional(),
toc_enhance: z.boolean().optional(),
}); });
const formSchema = z.object({ const formSchema = z.object({

View File

@ -34,6 +34,7 @@ export const useRenameChat = () => {
use_kg: false, use_kg: false,
reasoning: false, reasoning: false,
parameters: [{ key: 'knowledge', optional: false }], parameters: [{ key: 'knowledge', optional: false }],
toc_enhance: false,
}, },
llm_id: tenantInfo.data.llm_id, llm_id: tenantInfo.data.llm_id,
llm_setting: {}, llm_setting: {},