Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: The chat network search service is allowed to be null. (#18791)

balibabu2c19fae8f419
diff --git a/web/src/components/auto-keywords-form-field.tsx b/web/src/components/auto-keywords-form-field.tsx
index fcd64fad74..1dad0a73fd 100644
--- a/web/src/components/auto-keywords-form-field.tsx
+++ b/web/src/components/auto-keywords-form-field.tsx
@@ -39,6 +39,7 @@ export function AutoKeywordsFormField({
layout={layout}
sliderTestId="ds-settings-parser-auto-keyword-slider"
numberInputTestId="ds-settings-parser-auto-keyword-input"
+ integer
></SliderInputFormField>
);
}
@@ -59,6 +60,7 @@ export function AutoQuestionsFormField({
layout={layout}
sliderTestId="ds-settings-parser-auto-question-slider"
numberInputTestId="ds-settings-parser-auto-question-input"
+ integer
></SliderInputFormField>
);
}
diff --git a/web/src/components/ragflow-form.tsx b/web/src/components/ragflow-form.tsx
index b12dd73c0a..d1d9c3902a 100644
--- a/web/src/components/ragflow-form.tsx
+++ b/web/src/components/ragflow-form.tsx
@@ -16,6 +16,7 @@
import {
FormControl,
+ FormDescription,
FormField,
FormItem,
FormLabel,
@@ -34,6 +35,7 @@ type RAGFlowFormItemProps = {
name: string;
label?: ReactNode;
tooltip?: ReactNode;
+ description?: ReactNode;
children: ReactNode | ((field: ControllerRenderProps) => ReactNode);
horizontal?: boolean;
required?: boolean;
@@ -50,6 +52,7 @@ export function RAGFlowFormItem({
name,
label,
tooltip,
+ description,
children,
horizontal = false,
required = false,
@@ -111,6 +114,7 @@ export function RAGFlowFormItem({
? cloneElement(children, { ...field })
: children}
</FormControl>
+ {description && <FormDescription>{description}</FormDescription>}
<FormMessage />
</div>
</FormItem>
diff --git a/web/src/components/web-search-form-field.tsx b/web/src/components/web-search-form-field.tsx
index 903698ebdf..e861baa270 100644
--- a/web/src/components/web-search-form-field.tsx
+++ b/web/src/components/web-search-form-field.tsx
@@ -18,20 +18,13 @@ import queritLogo from '@/assets/querit.png';
import serplyLogo from '@/assets/serply.png';
import tavilyLogo from '@/assets/svg/tavily.svg';
import youcomLogo from '@/assets/svg/youcom.svg';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { RAGFlowFormItem } from '@/components/ragflow-form';
import { WebSearchProvider } from '@/constants/chat';
import { useTranslate } from '@/hooks/common-hooks';
import { prefixName } from '@/utils/form';
import { useFormContext, useWatch } from 'react-hook-form';
import PasswordInput from './originui/password-input';
-import {
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from './ui/form';
+import { SelectWithSearch } from './originui/select-with-search';
interface IProps {
prefix?: string;
@@ -119,55 +112,44 @@ export function WebSearchFormField({ prefix = '' }: IProps) {
return (
<>
- <FormField
- control={form.control}
+ <RAGFlowFormItem
name={providerName}
- render={({ field }) => (
- <FormItem>
- <FormLabel tooltip={t('webSearchProviderTip')}>
- {t('webSearchProvider')}
- </FormLabel>
- <FormControl>
- <RAGFlowSelect
- {...field}
- value={field.value}
- options={providerOptions}
- placeholder={t('webSearchProviderPlaceholder')}
- triggerTestId="web-search-provider"
- optionTestIdPrefix="web-search-provider-option"
- />
- </FormControl>
- <FormMessage />
- </FormItem>
+ label={t('webSearchProvider')}
+ tooltip={t('webSearchProviderTip')}
+ >
+ {(field) => (
+ <SelectWithSearch
+ value={field.value}
+ onChange={field.onChange}
+ options={providerOptions}
+ placeholder={t('webSearchProviderPlaceholder')}
+ allowClear
+ testId="web-search-provider"
+ optionTestIdPrefix="web-search-provider-option"
+ />
)}
- />
+ </RAGFlowFormItem>
{keyConfig && (
- <FormField
+ <RAGFlowFormItem
key={selectedProvider}
- control={form.control}
name={prefixName(prefix, keyConfig.name)}
- render={({ field }) => (
- <FormItem>
- <FormLabel tooltip={t(keyConfig.tip)}>
- {keyConfig.label}
- </FormLabel>
- <FormControl>
- <PasswordInput
- {...field}
- value={field.value ?? ''}
- placeholder={t(keyConfig.placeholder)}
- autoComplete="new-password"
- />
- </FormControl>
- <FormDescription>
- <a href={keyConfig.helpUrl} target="_blank" rel="noreferrer">
- {t('tavilyApiKeyHelp')}
- </a>
- </FormDescription>
- <FormMessage />
- </FormItem>
+ label={keyConfig.label}
+ tooltip={t(keyConfig.tip)}
+ description={
+ <a href={keyConfig.helpUrl} target="_blank" rel="noreferrer">
+ {t('tavilyApiKeyHelp')}
+ </a>
+ }
+ >
+ {(field) => (
+ <PasswordInput
+ {...field}
+ value={field.value ?? ''}
+ placeholder={t(keyConfig.placeholder)}
+ autoComplete="new-password"
+ />
)}
- />
+ </RAGFlowFormItem>
)}
</>
);
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 308b2b9dca..30f6c3284a 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
@@ -145,7 +145,8 @@ export function ChatSettings({ hasSingleChatBox }: ChatSettingsProps) {
...omit(data, 'top_k'),
prompt_config: {
...data.prompt_config,
- web_search_provider: getWebSearchProvider(data.prompt_config),
+ // reset() skips undefined values, so fall back to '' to clear the field
+ web_search_provider: getWebSearchProvider(data.prompt_config) ?? '',
reference_metadata: normalizedReferenceMetadata,
},
...llmSettingEnabledValues,
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 2e3cea0951..c8a09ed782 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
@@ -45,7 +45,8 @@ export function useChatSettingSchema() {
WebSearchProvider.Serply,
WebSearchProvider.YouCom,
])
- .optional(),
+ .optional()
+ .or(z.literal('')),
reasoning: z.boolean().optional(),
cross_languages: z.array(z.string()).optional(),
reference_metadata: z