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:
balibabu
2025-08-19 16:41:32 +08:00
committed by GitHub
parent 787e0c6786
commit a41a646909
14 changed files with 268 additions and 84 deletions

View File

@ -2,8 +2,7 @@
import { FileUploader } from '@/components/file-uploader';
import { KnowledgeBaseFormField } from '@/components/knowledge-base-item';
import { SelectWithSearch } from '@/components/originui/select-with-search';
import { RAGFlowFormItem } from '@/components/ragflow-form';
import { MetadataFilter } from '@/components/metadata-filter';
import { SwitchFormField } from '@/components/switch-fom-field';
import { TavilyFormField } from '@/components/tavily-form-field';
import {
@ -16,26 +15,11 @@ import {
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
import { useTranslate } from '@/hooks/common-hooks';
import { useFormContext, useWatch } from 'react-hook-form';
import { DatasetMetadata } from '../../constants';
import { MetadataFilterConditions } from './metadata-filter-conditions';
import { useFormContext } from 'react-hook-form';
export default function ChatBasicSetting() {
const { t } = useTranslate('chat');
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 (
<div className="space-y-8">
@ -125,18 +109,7 @@ export default function ChatBasicSetting() {
></SwitchFormField>
<TavilyFormField></TavilyFormField>
<KnowledgeBaseFormField></KnowledgeBaseFormField>
{hasKnowledge && (
<RAGFlowFormItem
label={t('metadata')}
name={'meta_data_filter.method'}
tooltip={t('metadataTip')}
>
<SelectWithSearch options={MetadataOptions} />
</RAGFlowFormItem>
)}
{hasKnowledge && metadata === DatasetMetadata.Manual && (
<MetadataFilterConditions kbIds={kbIds}></MetadataFilterConditions>
)}
<MetadataFilter></MetadataFilter>
</div>
);
}

View File

@ -2,6 +2,7 @@ import {
LlmSettingEnabledSchema,
LlmSettingFieldSchema,
} from '@/components/llm-setting-items/next';
import { MetadataFilterSchema } from '@/components/metadata-filter';
import { rerankFormSchema } from '@/components/rerank';
import { vectorSimilarityWeightSchema } from '@/components/similarity-slider';
import { topnSchema } from '@/components/top-n-item';
@ -46,20 +47,7 @@ export function useChatSettingSchema() {
llm_id: z.string().optional(),
...vectorSimilarityWeightSchema,
...topnSchema,
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(),
...MetadataFilterSchema,
});
return formSchema;

View File

@ -1,3 +1,4 @@
import { removeUselessFieldsFromValues } from '@/utils/form';
import { isEmpty } from 'lodash';
import { useCallback, useEffect, useRef } from 'react';
@ -23,7 +24,7 @@ export function useBuildFormRefs(chatBoxIds: string[]) {
? formRefs.current[chatBoxId].getFormData()
: {};
return llmConfig;
return removeUselessFieldsFromValues(llmConfig, '');
},
[formRefs],
);

View File

@ -2,31 +2,8 @@ import { useSetModalState } from '@/hooks/common-hooks';
import { useSetDialog } from '@/hooks/use-chat-request';
import { IDialog } from '@/interfaces/database/chat';
import { isEmpty } from 'lodash';
import { useCallback, useState } from 'react';
const InitialData = {
name: '',
icon: '',
language: 'English',
prompt_config: {
empty_response: '',
prologue: '你好! 我是你的助理,有什么可以帮到你的吗?',
quote: true,
keyword: false,
tts: false,
system:
'你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史。\n 以下是知识库:\n {knowledge}\n 以上是知识库。',
refine_multiturn: false,
use_kg: false,
reasoning: false,
parameters: [{ key: 'knowledge', optional: false }],
},
llm_id: '',
llm_setting: {},
similarity_threshold: 0.2,
vector_similarity_weight: 0.30000000000000004,
top_n: 8,
};
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
export const useRenameChat = () => {
const [chat, setChat] = useState<IDialog>({} as IDialog);
@ -36,6 +13,33 @@ export const useRenameChat = () => {
showModal: showChatRenameModal,
} = useSetModalState();
const { setDialog, loading } = useSetDialog();
const { t } = useTranslation();
const InitialData = useMemo(
() => ({
name: '',
icon: '',
language: 'English',
prompt_config: {
empty_response: '',
prologue: t('chat.setAnOpenerInitial'),
quote: true,
keyword: false,
tts: false,
system: t('chat.systemInitialValue'),
refine_multiturn: false,
use_kg: false,
reasoning: false,
parameters: [{ key: 'knowledge', optional: false }],
},
llm_id: '',
llm_setting: {},
similarity_threshold: 0.2,
vector_similarity_weight: 0.30000000000000004,
top_n: 8,
}),
[t],
);
const onChatRenameOk = useCallback(
async (name: string) => {
@ -49,7 +53,7 @@ export const useRenameChat = () => {
hideChatRenameModal();
}
},
[setDialog, chat, hideChatRenameModal],
[chat, InitialData, setDialog, hideChatRenameModal],
);
const handleShowChatRenameModal = useCallback(