From 198e52e990a8f6b49fcf1b97327df18b2d30f2a3 Mon Sep 17 00:00:00 2001 From: balibabu Date: Fri, 10 Oct 2025 18:35:43 +0800 Subject: [PATCH] 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) --- web/src/components/toc-enhance-form-field.tsx | 16 ++++++++++++++++ web/src/locales/en.ts | 6 ++++-- web/src/locales/zh.ts | 2 ++ web/src/pages/agent/constant.tsx | 1 + web/src/pages/agent/form/retrieval-form/next.tsx | 3 +++ .../form/tool-form/retrieval-form/index.tsx | 2 ++ .../form/parser-form/video-form-fields.tsx | 2 -- .../pages/data-flow/form/retrieval-form/next.tsx | 0 .../chat/app-settings/chat-basic-settings.tsx | 2 ++ .../chat/app-settings/chat-settings.tsx | 1 + .../app-settings/use-chat-setting-schema.tsx | 1 + .../pages/next-chats/hooks/use-rename-chat.ts | 1 + 12 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 web/src/components/toc-enhance-form-field.tsx delete mode 100644 web/src/pages/data-flow/form/retrieval-form/next.tsx diff --git a/web/src/components/toc-enhance-form-field.tsx b/web/src/components/toc-enhance-form-field.tsx new file mode 100644 index 000000000..174d76a1d --- /dev/null +++ b/web/src/components/toc-enhance-form-field.tsx @@ -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 ( + + ); +} diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index 549dd5dfb..e0628433a 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -537,10 +537,10 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s setAnOpener: 'Opening greeting', setAnOpenerInitial: `Hi! I'm your assistant. What can I do for you?`, setAnOpenerTip: 'Set an opening greeting for users.', - knowledgeBases: 'Knowledge bases', + knowledgeBases: 'Datasets', knowledgeBasesMessage: 'Please select', 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', 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: @@ -668,6 +668,8 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s }, cancel: 'Cancel', 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: { profile: 'Profile', diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index d13f3db6c..3c15e2df7 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -660,6 +660,8 @@ General:实体和关系提取提示来自 GitHub - microsoft/graphrag:基于 chatSetting: '聊天设置', avatarHidden: '隐藏头像', locale: '地区', + tocEnhance: '目录增强', + tocEnhanceTip: `解析文档时生成了目录信息(见General方法的‘启用目录抽取’),让大模型返回和用户问题相关的目录项,从而利用目录项拿到相关chunk,对这些chunk在排序中进行加权。这种方法来源于模仿人类查询书本中知识的行为逻辑`, }, setting: { profile: '概要', diff --git a/web/src/pages/agent/constant.tsx b/web/src/pages/agent/constant.tsx index b40b42e17..3079f3b1a 100644 --- a/web/src/pages/agent/constant.tsx +++ b/web/src/pages/agent/constant.tsx @@ -254,6 +254,7 @@ export const initialRetrievalValues = { ...initialSimilarityThresholdValue, ...initialKeywordsSimilarityWeightValue, use_kg: false, + toc_enhance: false, cross_languages: [], outputs: { formalized_content: { diff --git a/web/src/pages/agent/form/retrieval-form/next.tsx b/web/src/pages/agent/form/retrieval-form/next.tsx index 69204d4da..67322b2b5 100644 --- a/web/src/pages/agent/form/retrieval-form/next.tsx +++ b/web/src/pages/agent/form/retrieval-form/next.tsx @@ -5,6 +5,7 @@ import { KnowledgeBaseFormField } from '@/components/knowledge-base-item'; import { RAGFlowFormItem } from '@/components/ragflow-form'; import { RerankFormFields } from '@/components/rerank'; import { SimilaritySliderFormField } from '@/components/similarity-slider'; +import { TOCEnhanceFormField } from '@/components/toc-enhance-form-field'; import { TopNFormField } from '@/components/top-n-item'; import { Form, @@ -39,6 +40,7 @@ export const RetrievalPartialSchema = { empty_response: z.string(), cross_languages: z.array(z.string()), use_kg: z.boolean(), + toc_enhance: z.boolean(), }; export const FormSchema = z.object({ @@ -119,6 +121,7 @@ function RetrievalForm({ node }: INextOperatorForm) { + diff --git a/web/src/pages/agent/form/tool-form/retrieval-form/index.tsx b/web/src/pages/agent/form/tool-form/retrieval-form/index.tsx index bf187a6bf..c1031081e 100644 --- a/web/src/pages/agent/form/tool-form/retrieval-form/index.tsx +++ b/web/src/pages/agent/form/tool-form/retrieval-form/index.tsx @@ -4,6 +4,7 @@ import { FormContainer } from '@/components/form-container'; import { KnowledgeBaseFormField } from '@/components/knowledge-base-item'; import { RerankFormFields } from '@/components/rerank'; import { SimilaritySliderFormField } from '@/components/similarity-slider'; +import { TOCEnhanceFormField } from '@/components/toc-enhance-form-field'; import { TopNFormField } from '@/components/top-n-item'; import { Form } from '@/components/ui/form'; import { UseKnowledgeGraphFormField } from '@/components/use-knowledge-graph-item'; @@ -53,6 +54,7 @@ const RetrievalForm = () => { + diff --git a/web/src/pages/data-flow/form/parser-form/video-form-fields.tsx b/web/src/pages/data-flow/form/parser-form/video-form-fields.tsx index d1ca8c68d..352958867 100644 --- a/web/src/pages/data-flow/form/parser-form/video-form-fields.tsx +++ b/web/src/pages/data-flow/form/parser-form/video-form-fields.tsx @@ -7,8 +7,6 @@ import { export function VideoFormFields({ prefix }: OutputFormatFormFieldProps) { const modelOptions = useComposeLlmOptionsByModelTypes([ - LlmModelType.Chat, - LlmModelType.Image2text, LlmModelType.Speech2text, ]); diff --git a/web/src/pages/data-flow/form/retrieval-form/next.tsx b/web/src/pages/data-flow/form/retrieval-form/next.tsx deleted file mode 100644 index e69de29bb..000000000 diff --git a/web/src/pages/next-chats/chat/app-settings/chat-basic-settings.tsx b/web/src/pages/next-chats/chat/app-settings/chat-basic-settings.tsx index d945f7841..3f06e1818 100644 --- a/web/src/pages/next-chats/chat/app-settings/chat-basic-settings.tsx +++ b/web/src/pages/next-chats/chat/app-settings/chat-basic-settings.tsx @@ -5,6 +5,7 @@ import { KnowledgeBaseFormField } from '@/components/knowledge-base-item'; import { MetadataFilter } from '@/components/metadata-filter'; import { SwitchFormField } from '@/components/switch-fom-field'; import { TavilyFormField } from '@/components/tavily-form-field'; +import { TOCEnhanceFormField } from '@/components/toc-enhance-form-field'; import { FormControl, FormField, @@ -109,6 +110,7 @@ export default function ChatBasicSetting() { label={t('tts')} tooltip={t('ttsTip')} > + diff --git a/web/src/pages/next-chats/chat/app-settings/chat-settings.tsx b/web/src/pages/next-chats/chat/app-settings/chat-settings.tsx index 50fe9dd85..215285e5d 100644 --- a/web/src/pages/next-chats/chat/app-settings/chat-settings.tsx +++ b/web/src/pages/next-chats/chat/app-settings/chat-settings.tsx @@ -49,6 +49,7 @@ export function ChatSettings({ switchSettingVisible }: ChatSettingsProps) { parameters: [], reasoning: false, cross_languages: [], + toc_enhance: false, }, top_n: 8, similarity_threshold: 0.2, diff --git a/web/src/pages/next-chats/chat/app-settings/use-chat-setting-schema.tsx b/web/src/pages/next-chats/chat/app-settings/use-chat-setting-schema.tsx index 105b880b0..226400775 100644 --- a/web/src/pages/next-chats/chat/app-settings/use-chat-setting-schema.tsx +++ b/web/src/pages/next-chats/chat/app-settings/use-chat-setting-schema.tsx @@ -33,6 +33,7 @@ export function useChatSettingSchema() { tavily_api_key: z.string().optional(), reasoning: z.boolean().optional(), cross_languages: z.array(z.string()).optional(), + toc_enhance: z.boolean().optional(), }); const formSchema = z.object({ diff --git a/web/src/pages/next-chats/hooks/use-rename-chat.ts b/web/src/pages/next-chats/hooks/use-rename-chat.ts index 41f81232d..bf8fc2fe6 100644 --- a/web/src/pages/next-chats/hooks/use-rename-chat.ts +++ b/web/src/pages/next-chats/hooks/use-rename-chat.ts @@ -34,6 +34,7 @@ export const useRenameChat = () => { use_kg: false, reasoning: false, parameters: [{ key: 'knowledge', optional: false }], + toc_enhance: false, }, llm_id: tenantInfo.data.llm_id, llm_setting: {},