mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: Fixed the issue where clicking the SQL tool test button did not request the interface #9541 (#9542)
### What problem does this PR solve? Fix: Fixed the issue where clicking the SQL tool test button did not request the interface #9541 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
72
web/src/components/metadata-filter/index.tsx
Normal file
72
web/src/components/metadata-filter/index.tsx
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
import { DatasetMetadata } from '@/constants/chat';
|
||||||
|
import { useTranslate } from '@/hooks/common-hooks';
|
||||||
|
import { useFormContext, useWatch } from 'react-hook-form';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import { SelectWithSearch } from '../originui/select-with-search';
|
||||||
|
import { RAGFlowFormItem } from '../ragflow-form';
|
||||||
|
import { MetadataFilterConditions } from './metadata-filter-conditions';
|
||||||
|
|
||||||
|
type MetadataFilterProps = {
|
||||||
|
prefix?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const MetadataFilterSchema = {
|
||||||
|
meta_data_filter: z
|
||||||
|
.object({
|
||||||
|
method: z.string().optional(),
|
||||||
|
manual: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
|
key: z.string(),
|
||||||
|
op: z.string(),
|
||||||
|
value: z.string(),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.optional(),
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
};
|
||||||
|
|
||||||
|
export function MetadataFilter({ prefix = '' }: MetadataFilterProps) {
|
||||||
|
const { t } = useTranslate('chat');
|
||||||
|
const form = useFormContext();
|
||||||
|
|
||||||
|
const methodName = prefix + 'meta_data_filter.method';
|
||||||
|
|
||||||
|
const kbIds: string[] = useWatch({
|
||||||
|
control: form.control,
|
||||||
|
name: prefix + 'kb_ids',
|
||||||
|
});
|
||||||
|
const metadata = useWatch({
|
||||||
|
control: form.control,
|
||||||
|
name: methodName,
|
||||||
|
});
|
||||||
|
const hasKnowledge = Array.isArray(kbIds) && kbIds.length > 0;
|
||||||
|
|
||||||
|
const MetadataOptions = Object.values(DatasetMetadata).map((x) => {
|
||||||
|
return {
|
||||||
|
value: x,
|
||||||
|
label: t(`meta.${x}`),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{hasKnowledge && (
|
||||||
|
<RAGFlowFormItem
|
||||||
|
label={t('metadata')}
|
||||||
|
name={methodName}
|
||||||
|
tooltip={t('metadataTip')}
|
||||||
|
>
|
||||||
|
<SelectWithSearch options={MetadataOptions} />
|
||||||
|
</RAGFlowFormItem>
|
||||||
|
)}
|
||||||
|
{hasKnowledge && metadata === DatasetMetadata.Manual && (
|
||||||
|
<MetadataFilterConditions
|
||||||
|
kbIds={kbIds}
|
||||||
|
prefix={prefix}
|
||||||
|
></MetadataFilterConditions>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -0,0 +1,135 @@
|
|||||||
|
import { SelectWithSearch } from '@/components/originui/select-with-search';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from '@/components/ui/dropdown-menu';
|
||||||
|
import {
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormLabel,
|
||||||
|
FormMessage,
|
||||||
|
} from '@/components/ui/form';
|
||||||
|
import { Input } from '@/components/ui/input';
|
||||||
|
import { Separator } from '@/components/ui/separator';
|
||||||
|
import { useFetchKnowledgeMetadata } from '@/hooks/use-knowledge-request';
|
||||||
|
import { SwitchOperatorOptions } from '@/pages/agent/constant';
|
||||||
|
import { useBuildSwitchOperatorOptions } from '@/pages/agent/form/switch-form';
|
||||||
|
import { Plus, X } from 'lucide-react';
|
||||||
|
import { useCallback } from 'react';
|
||||||
|
import { useFieldArray, useFormContext } from 'react-hook-form';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
export function MetadataFilterConditions({
|
||||||
|
kbIds,
|
||||||
|
prefix = '',
|
||||||
|
}: {
|
||||||
|
kbIds: string[];
|
||||||
|
prefix?: string;
|
||||||
|
}) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const form = useFormContext();
|
||||||
|
const name = prefix + 'meta_data_filter.manual';
|
||||||
|
const metadata = useFetchKnowledgeMetadata(kbIds);
|
||||||
|
|
||||||
|
const switchOperatorOptions = useBuildSwitchOperatorOptions();
|
||||||
|
|
||||||
|
const { fields, remove, append } = useFieldArray({
|
||||||
|
name,
|
||||||
|
control: form.control,
|
||||||
|
});
|
||||||
|
|
||||||
|
const add = useCallback(
|
||||||
|
(key: string) => () => {
|
||||||
|
append({
|
||||||
|
key,
|
||||||
|
value: '',
|
||||||
|
op: SwitchOperatorOptions[0].value,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[append],
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="flex flex-col gap-2">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<FormLabel>{t('chat.conditions')}</FormLabel>
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger>
|
||||||
|
<Button variant={'ghost'} type="button">
|
||||||
|
<Plus />
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent>
|
||||||
|
{Object.keys(metadata.data).map((key, idx) => {
|
||||||
|
return (
|
||||||
|
<DropdownMenuItem key={idx} onClick={add(key)}>
|
||||||
|
{key}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-5">
|
||||||
|
{fields.map((field, index) => {
|
||||||
|
const typeField = `${name}.${index}.key`;
|
||||||
|
return (
|
||||||
|
<div key={field.id} className="flex w-full items-center gap-2">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name={typeField}
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="flex-1 overflow-hidden">
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
placeholder={t('common.pleaseInput')}
|
||||||
|
></Input>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Separator className="w-3 text-text-secondary" />
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name={`${name}.${index}.op`}
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="flex-1 overflow-hidden">
|
||||||
|
<FormControl>
|
||||||
|
<SelectWithSearch
|
||||||
|
{...field}
|
||||||
|
options={switchOperatorOptions}
|
||||||
|
></SelectWithSearch>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Separator className="w-3 text-text-secondary" />
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name={`${name}.${index}.value`}
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="flex-1 overflow-hidden">
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder={t('common.pleaseInput')} {...field} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Button variant={'ghost'} onClick={() => remove(index)}>
|
||||||
|
<X className="text-text-sub-title-invert " />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -32,3 +32,9 @@ export enum ChatSearchParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const EmptyConversationId = 'empty';
|
export const EmptyConversationId = 'empty';
|
||||||
|
|
||||||
|
export enum DatasetMetadata {
|
||||||
|
Disabled = 'disabled',
|
||||||
|
Automatic = 'automatic',
|
||||||
|
Manual = 'manual',
|
||||||
|
}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ export function Header() {
|
|||||||
const tagsData = useMemo(
|
const tagsData = useMemo(
|
||||||
() => [
|
() => [
|
||||||
{ path: Routes.Home, name: t('header.home'), icon: House },
|
{ path: Routes.Home, name: t('header.home'), icon: House },
|
||||||
{ path: Routes.Datasets, name: t('header.knowledgeBase'), icon: Library },
|
{ path: Routes.Datasets, name: t('header.dataset'), icon: Library },
|
||||||
{ path: Routes.Chats, name: t('header.chat'), icon: MessageSquareText },
|
{ path: Routes.Chats, name: t('header.chat'), icon: MessageSquareText },
|
||||||
{ path: Routes.Searches, name: t('header.search'), icon: Search },
|
{ path: Routes.Searches, name: t('header.search'), icon: Search },
|
||||||
{ path: Routes.Agents, name: t('header.flow'), icon: Cpu },
|
{ path: Routes.Agents, name: t('header.flow'), icon: Cpu },
|
||||||
|
|||||||
@ -81,6 +81,7 @@ export default {
|
|||||||
flow: 'Agent',
|
flow: 'Agent',
|
||||||
search: 'Search',
|
search: 'Search',
|
||||||
welcome: 'Welcome to',
|
welcome: 'Welcome to',
|
||||||
|
dataset: 'Dataset',
|
||||||
},
|
},
|
||||||
knowledgeList: {
|
knowledgeList: {
|
||||||
welcome: 'Welcome back',
|
welcome: 'Welcome back',
|
||||||
|
|||||||
@ -73,6 +73,7 @@ export default {
|
|||||||
flow: 'Agent',
|
flow: 'Agent',
|
||||||
search: '搜索',
|
search: '搜索',
|
||||||
welcome: '欢迎来到',
|
welcome: '欢迎来到',
|
||||||
|
dataset: '数据集',
|
||||||
},
|
},
|
||||||
knowledgeList: {
|
knowledgeList: {
|
||||||
welcome: '欢迎回来',
|
welcome: '欢迎回来',
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import { useCallback } from 'react';
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
export const ExeSQLFormSchema = {
|
export const ExeSQLFormSchema = {
|
||||||
sql: z.string(),
|
|
||||||
db_type: z.string().min(1),
|
db_type: z.string().min(1),
|
||||||
database: z.string().min(1),
|
database: z.string().min(1),
|
||||||
username: z.string().min(1),
|
username: z.string().min(1),
|
||||||
@ -14,7 +13,7 @@ export const ExeSQLFormSchema = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const FormSchema = z.object({
|
export const FormSchema = z.object({
|
||||||
query: z.string().optional(),
|
sql: z.string().optional(),
|
||||||
...ExeSQLFormSchema,
|
...ExeSQLFormSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -25,11 +25,13 @@ const ExeSQLForm = () => {
|
|||||||
defaultValues: defaultValues as FormType,
|
defaultValues: defaultValues as FormType,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const onError = (error: any) => console.log(error);
|
||||||
|
|
||||||
useWatchFormChange(form);
|
useWatchFormChange(form);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<FormWrapper onSubmit={form.handleSubmit(onSubmit)}>
|
<FormWrapper onSubmit={form.handleSubmit(onSubmit, onError)}>
|
||||||
<ExeSQLFormWidgets loading={loading}></ExeSQLFormWidgets>
|
<ExeSQLFormWidgets loading={loading}></ExeSQLFormWidgets>
|
||||||
</FormWrapper>
|
</FormWrapper>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
import { FileUploader } from '@/components/file-uploader';
|
import { FileUploader } from '@/components/file-uploader';
|
||||||
import { KnowledgeBaseFormField } from '@/components/knowledge-base-item';
|
import { KnowledgeBaseFormField } from '@/components/knowledge-base-item';
|
||||||
import { SelectWithSearch } from '@/components/originui/select-with-search';
|
import { MetadataFilter } from '@/components/metadata-filter';
|
||||||
import { RAGFlowFormItem } from '@/components/ragflow-form';
|
|
||||||
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 {
|
import {
|
||||||
@ -16,26 +15,11 @@ import {
|
|||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Textarea } from '@/components/ui/textarea';
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { useTranslate } from '@/hooks/common-hooks';
|
||||||
import { useFormContext, useWatch } from 'react-hook-form';
|
import { useFormContext } from 'react-hook-form';
|
||||||
import { DatasetMetadata } from '../../constants';
|
|
||||||
import { MetadataFilterConditions } from './metadata-filter-conditions';
|
|
||||||
|
|
||||||
export default function ChatBasicSetting() {
|
export default function ChatBasicSetting() {
|
||||||
const { t } = useTranslate('chat');
|
const { t } = useTranslate('chat');
|
||||||
const form = useFormContext();
|
const form = useFormContext();
|
||||||
const kbIds: string[] = useWatch({ control: form.control, name: 'kb_ids' });
|
|
||||||
const metadata = useWatch({
|
|
||||||
control: form.control,
|
|
||||||
name: 'meta_data_filter.method',
|
|
||||||
});
|
|
||||||
const hasKnowledge = Array.isArray(kbIds) && kbIds.length > 0;
|
|
||||||
|
|
||||||
const MetadataOptions = Object.values(DatasetMetadata).map((x) => {
|
|
||||||
return {
|
|
||||||
value: x,
|
|
||||||
label: t(`meta.${x}`),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
@ -125,18 +109,7 @@ export default function ChatBasicSetting() {
|
|||||||
></SwitchFormField>
|
></SwitchFormField>
|
||||||
<TavilyFormField></TavilyFormField>
|
<TavilyFormField></TavilyFormField>
|
||||||
<KnowledgeBaseFormField></KnowledgeBaseFormField>
|
<KnowledgeBaseFormField></KnowledgeBaseFormField>
|
||||||
{hasKnowledge && (
|
<MetadataFilter></MetadataFilter>
|
||||||
<RAGFlowFormItem
|
|
||||||
label={t('metadata')}
|
|
||||||
name={'meta_data_filter.method'}
|
|
||||||
tooltip={t('metadataTip')}
|
|
||||||
>
|
|
||||||
<SelectWithSearch options={MetadataOptions} />
|
|
||||||
</RAGFlowFormItem>
|
|
||||||
)}
|
|
||||||
{hasKnowledge && metadata === DatasetMetadata.Manual && (
|
|
||||||
<MetadataFilterConditions kbIds={kbIds}></MetadataFilterConditions>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import {
|
|||||||
LlmSettingEnabledSchema,
|
LlmSettingEnabledSchema,
|
||||||
LlmSettingFieldSchema,
|
LlmSettingFieldSchema,
|
||||||
} from '@/components/llm-setting-items/next';
|
} from '@/components/llm-setting-items/next';
|
||||||
|
import { MetadataFilterSchema } from '@/components/metadata-filter';
|
||||||
import { rerankFormSchema } from '@/components/rerank';
|
import { rerankFormSchema } from '@/components/rerank';
|
||||||
import { vectorSimilarityWeightSchema } from '@/components/similarity-slider';
|
import { vectorSimilarityWeightSchema } from '@/components/similarity-slider';
|
||||||
import { topnSchema } from '@/components/top-n-item';
|
import { topnSchema } from '@/components/top-n-item';
|
||||||
@ -46,20 +47,7 @@ export function useChatSettingSchema() {
|
|||||||
llm_id: z.string().optional(),
|
llm_id: z.string().optional(),
|
||||||
...vectorSimilarityWeightSchema,
|
...vectorSimilarityWeightSchema,
|
||||||
...topnSchema,
|
...topnSchema,
|
||||||
meta_data_filter: z
|
...MetadataFilterSchema,
|
||||||
.object({
|
|
||||||
method: z.string().optional(),
|
|
||||||
manual: z
|
|
||||||
.array(
|
|
||||||
z.object({
|
|
||||||
key: z.string(),
|
|
||||||
op: z.string(),
|
|
||||||
value: z.string(),
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.optional(),
|
|
||||||
})
|
|
||||||
.optional(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return formSchema;
|
return formSchema;
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { removeUselessFieldsFromValues } from '@/utils/form';
|
||||||
import { isEmpty } from 'lodash';
|
import { isEmpty } from 'lodash';
|
||||||
import { useCallback, useEffect, useRef } from 'react';
|
import { useCallback, useEffect, useRef } from 'react';
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ export function useBuildFormRefs(chatBoxIds: string[]) {
|
|||||||
? formRefs.current[chatBoxId].getFormData()
|
? formRefs.current[chatBoxId].getFormData()
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
return llmConfig;
|
return removeUselessFieldsFromValues(llmConfig, '');
|
||||||
},
|
},
|
||||||
[formRefs],
|
[formRefs],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -2,20 +2,31 @@ import { useSetModalState } from '@/hooks/common-hooks';
|
|||||||
import { useSetDialog } from '@/hooks/use-chat-request';
|
import { useSetDialog } from '@/hooks/use-chat-request';
|
||||||
import { IDialog } from '@/interfaces/database/chat';
|
import { IDialog } from '@/interfaces/database/chat';
|
||||||
import { isEmpty } from 'lodash';
|
import { isEmpty } from 'lodash';
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
const InitialData = {
|
export const useRenameChat = () => {
|
||||||
|
const [chat, setChat] = useState<IDialog>({} as IDialog);
|
||||||
|
const {
|
||||||
|
visible: chatRenameVisible,
|
||||||
|
hideModal: hideChatRenameModal,
|
||||||
|
showModal: showChatRenameModal,
|
||||||
|
} = useSetModalState();
|
||||||
|
const { setDialog, loading } = useSetDialog();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const InitialData = useMemo(
|
||||||
|
() => ({
|
||||||
name: '',
|
name: '',
|
||||||
icon: '',
|
icon: '',
|
||||||
language: 'English',
|
language: 'English',
|
||||||
prompt_config: {
|
prompt_config: {
|
||||||
empty_response: '',
|
empty_response: '',
|
||||||
prologue: '你好! 我是你的助理,有什么可以帮到你的吗?',
|
prologue: t('chat.setAnOpenerInitial'),
|
||||||
quote: true,
|
quote: true,
|
||||||
keyword: false,
|
keyword: false,
|
||||||
tts: false,
|
tts: false,
|
||||||
system:
|
system: t('chat.systemInitialValue'),
|
||||||
'你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史。\n 以下是知识库:\n {knowledge}\n 以上是知识库。',
|
|
||||||
refine_multiturn: false,
|
refine_multiturn: false,
|
||||||
use_kg: false,
|
use_kg: false,
|
||||||
reasoning: false,
|
reasoning: false,
|
||||||
@ -26,16 +37,9 @@ const InitialData = {
|
|||||||
similarity_threshold: 0.2,
|
similarity_threshold: 0.2,
|
||||||
vector_similarity_weight: 0.30000000000000004,
|
vector_similarity_weight: 0.30000000000000004,
|
||||||
top_n: 8,
|
top_n: 8,
|
||||||
};
|
}),
|
||||||
|
[t],
|
||||||
export const useRenameChat = () => {
|
);
|
||||||
const [chat, setChat] = useState<IDialog>({} as IDialog);
|
|
||||||
const {
|
|
||||||
visible: chatRenameVisible,
|
|
||||||
hideModal: hideChatRenameModal,
|
|
||||||
showModal: showChatRenameModal,
|
|
||||||
} = useSetModalState();
|
|
||||||
const { setDialog, loading } = useSetDialog();
|
|
||||||
|
|
||||||
const onChatRenameOk = useCallback(
|
const onChatRenameOk = useCallback(
|
||||||
async (name: string) => {
|
async (name: string) => {
|
||||||
@ -49,7 +53,7 @@ export const useRenameChat = () => {
|
|||||||
hideChatRenameModal();
|
hideChatRenameModal();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[setDialog, chat, hideChatRenameModal],
|
[chat, InitialData, setDialog, hideChatRenameModal],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleShowChatRenameModal = useCallback(
|
const handleShowChatRenameModal = useCallback(
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
// src/pages/next-search/search-setting.tsx
|
// src/pages/next-search/search-setting.tsx
|
||||||
|
|
||||||
|
import {
|
||||||
|
MetadataFilter,
|
||||||
|
MetadataFilterSchema,
|
||||||
|
} from '@/components/metadata-filter';
|
||||||
import { Input } from '@/components/originui/input';
|
import { Input } from '@/components/originui/input';
|
||||||
import { RAGFlowAvatar } from '@/components/ragflow-avatar';
|
import { RAGFlowAvatar } from '@/components/ragflow-avatar';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
@ -76,6 +80,7 @@ const SearchSettingFormSchema = z
|
|||||||
llm_setting: z.object(LlmSettingSchema),
|
llm_setting: z.object(LlmSettingSchema),
|
||||||
related_search: z.boolean(),
|
related_search: z.boolean(),
|
||||||
query_mindmap: z.boolean(),
|
query_mindmap: z.boolean(),
|
||||||
|
...MetadataFilterSchema,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.superRefine((data, ctx) => {
|
.superRefine((data, ctx) => {
|
||||||
@ -165,6 +170,7 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
keyword: false,
|
keyword: false,
|
||||||
related_search: search_config?.related_search || false,
|
related_search: search_config?.related_search || false,
|
||||||
query_mindmap: search_config?.query_mindmap || false,
|
query_mindmap: search_config?.query_mindmap || false,
|
||||||
|
meta_data_filter: search_config?.meta_data_filter,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}, [data, search_config, llm_setting, formMethods]);
|
}, [data, search_config, llm_setting, formMethods]);
|
||||||
@ -346,7 +352,6 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Avatar */}
|
{/* Avatar */}
|
||||||
<FormField
|
<FormField
|
||||||
control={formMethods.control}
|
control={formMethods.control}
|
||||||
@ -409,7 +414,6 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Description */}
|
{/* Description */}
|
||||||
<FormField
|
<FormField
|
||||||
control={formMethods.control}
|
control={formMethods.control}
|
||||||
@ -437,7 +441,6 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Datasets */}
|
{/* Datasets */}
|
||||||
<FormField
|
<FormField
|
||||||
control={formMethods.control}
|
control={formMethods.control}
|
||||||
@ -467,6 +470,7 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<MetadataFilter prefix="search_config."></MetadataFilter>
|
||||||
<FormField
|
<FormField
|
||||||
control={formMethods.control}
|
control={formMethods.control}
|
||||||
name="search_config.similarity_threshold"
|
name="search_config.similarity_threshold"
|
||||||
@ -541,7 +545,6 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Rerank Model */}
|
{/* Rerank Model */}
|
||||||
<FormField
|
<FormField
|
||||||
control={formMethods.control}
|
control={formMethods.control}
|
||||||
@ -617,7 +620,6 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* AI Summary */}
|
{/* AI Summary */}
|
||||||
<FormField
|
<FormField
|
||||||
control={formMethods.control}
|
control={formMethods.control}
|
||||||
@ -634,14 +636,12 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{aiSummaryDisabled && (
|
{aiSummaryDisabled && (
|
||||||
<LlmSettingFieldItems
|
<LlmSettingFieldItems
|
||||||
prefix="search_config.llm_setting"
|
prefix="search_config.llm_setting"
|
||||||
options={aiSummeryModelOptions}
|
options={aiSummeryModelOptions}
|
||||||
></LlmSettingFieldItems>
|
></LlmSettingFieldItems>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Feature Controls */}
|
{/* Feature Controls */}
|
||||||
{/* <FormField
|
{/* <FormField
|
||||||
control={formMethods.control}
|
control={formMethods.control}
|
||||||
@ -658,7 +658,6 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/> */}
|
/> */}
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
control={formMethods.control}
|
control={formMethods.control}
|
||||||
name="search_config.related_search"
|
name="search_config.related_search"
|
||||||
@ -674,7 +673,6 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
control={formMethods.control}
|
control={formMethods.control}
|
||||||
name="search_config.query_mindmap"
|
name="search_config.query_mindmap"
|
||||||
|
|||||||
@ -158,6 +158,10 @@ export interface ISearchAppDetailProps {
|
|||||||
vector_similarity_weight: number;
|
vector_similarity_weight: number;
|
||||||
web_search: boolean;
|
web_search: boolean;
|
||||||
chat_settingcross_languages: string[];
|
chat_settingcross_languages: string[];
|
||||||
|
meta_data_filter?: {
|
||||||
|
method: string;
|
||||||
|
manual: { key: string; op: string; value: string }[];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
tenant_id: string;
|
tenant_id: string;
|
||||||
update_time: number;
|
update_time: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user