mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### 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:
16
web/src/components/toc-enhance-form-field.tsx
Normal file
16
web/src/components/toc-enhance-form-field.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
@ -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',
|
||||
|
||||
@ -660,6 +660,8 @@ General:实体和关系提取提示来自 GitHub - microsoft/graphrag:基于
|
||||
chatSetting: '聊天设置',
|
||||
avatarHidden: '隐藏头像',
|
||||
locale: '地区',
|
||||
tocEnhance: '目录增强',
|
||||
tocEnhanceTip: `解析文档时生成了目录信息(见General方法的‘启用目录抽取’),让大模型返回和用户问题相关的目录项,从而利用目录项拿到相关chunk,对这些chunk在排序中进行加权。这种方法来源于模仿人类查询书本中知识的行为逻辑`,
|
||||
},
|
||||
setting: {
|
||||
profile: '概要',
|
||||
|
||||
@ -254,6 +254,7 @@ export const initialRetrievalValues = {
|
||||
...initialSimilarityThresholdValue,
|
||||
...initialKeywordsSimilarityWeightValue,
|
||||
use_kg: false,
|
||||
toc_enhance: false,
|
||||
cross_languages: [],
|
||||
outputs: {
|
||||
formalized_content: {
|
||||
|
||||
@ -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) {
|
||||
<EmptyResponseField></EmptyResponseField>
|
||||
<CrossLanguageFormField name="cross_languages"></CrossLanguageFormField>
|
||||
<UseKnowledgeGraphFormField name="use_kg"></UseKnowledgeGraphFormField>
|
||||
<TOCEnhanceFormField name="toc_enhance"></TOCEnhanceFormField>
|
||||
</FormContainer>
|
||||
</Collapse>
|
||||
<Output list={outputList}></Output>
|
||||
|
||||
@ -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 = () => {
|
||||
<EmptyResponseField></EmptyResponseField>
|
||||
<CrossLanguageFormField name="cross_languages"></CrossLanguageFormField>
|
||||
<UseKnowledgeGraphFormField name="use_kg"></UseKnowledgeGraphFormField>
|
||||
<TOCEnhanceFormField name="toc_enhance"></TOCEnhanceFormField>
|
||||
</FormContainer>
|
||||
</Collapse>
|
||||
</FormWrapper>
|
||||
|
||||
@ -7,8 +7,6 @@ import {
|
||||
|
||||
export function VideoFormFields({ prefix }: OutputFormatFormFieldProps) {
|
||||
const modelOptions = useComposeLlmOptionsByModelTypes([
|
||||
LlmModelType.Chat,
|
||||
LlmModelType.Image2text,
|
||||
LlmModelType.Speech2text,
|
||||
]);
|
||||
|
||||
|
||||
@ -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')}
|
||||
></SwitchFormField>
|
||||
<TOCEnhanceFormField name="prompt_config.toc_enhance"></TOCEnhanceFormField>
|
||||
<TavilyFormField></TavilyFormField>
|
||||
<KnowledgeBaseFormField></KnowledgeBaseFormField>
|
||||
<MetadataFilter></MetadataFilter>
|
||||
|
||||
@ -49,6 +49,7 @@ export function ChatSettings({ switchSettingVisible }: ChatSettingsProps) {
|
||||
parameters: [],
|
||||
reasoning: false,
|
||||
cross_languages: [],
|
||||
toc_enhance: false,
|
||||
},
|
||||
top_n: 8,
|
||||
similarity_threshold: 0.2,
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -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: {},
|
||||
|
||||
Reference in New Issue
Block a user