Skip to content

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

Refactor: Replace RAGFlowSelect with SelectWithSearch. (#19795)

balibabufdee18ed46c0
diff --git a/web/src/components/logical-operator.tsx b/web/src/components/logical-operator.tsx
index 69ddb08dcd..3dc9f4fc4e 100644
--- a/web/src/components/logical-operator.tsx
+++ b/web/src/components/logical-operator.tsx
@@ -16,7 +16,7 @@
import { useBuildSwitchLogicOperatorOptions } from '@/hooks/logic-hooks/use-build-options';
import { RAGFlowFormItem } from './ragflow-form';
-import { RAGFlowSelect } from './ui/select';
+import { SelectWithSearch } from './originui/select-with-search';
type LogicalOperatorProps = { name: string };
@@ -29,10 +29,10 @@ export function LogicalOperator({ name }: LogicalOperatorProps) {
name={name}
className="absolute top-1/2 -translate-y-1/2 right-1 left-0 z-10 bg-bg-base"
>
- <RAGFlowSelect
+ <SelectWithSearch
options={switchLogicOperatorOptions}
triggerClassName="w-full text-xs px-1 py-0 h-6"
- ></RAGFlowSelect>
+ ></SelectWithSearch>
</RAGFlowFormItem>
<div className="absolute border-l border-y w-5 right-0 top-4 bottom-4 rounded-l-lg"></div>
</div>
diff --git a/web/src/components/metadata-filter/metadata-filter-conditions.tsx b/web/src/components/metadata-filter/metadata-filter-conditions.tsx
index 314224695a..1233b26933 100644
--- a/web/src/components/metadata-filter/metadata-filter-conditions.tsx
+++ b/web/src/components/metadata-filter/metadata-filter-conditions.tsx
@@ -40,9 +40,9 @@ import { useCallback, useMemo } from 'react';
import { useFieldArray, useFormContext, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { LogicalOperator } from '../logical-operator';
+import { SelectWithSearch } from '../originui/select-with-search';
import { Card, CardContent } from '../ui/card';
import { InputSelect } from '../ui/input-select';
-import { RAGFlowSelect } from '../ui/select';
type ConditionCardsProps = {
fieldName: string;
@@ -124,7 +124,7 @@ function ConditionCards({
render={({ field }) => (
<FormItem>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
{...field}
onChange={(value) => {
handleChangeOp(value);
diff --git a/web/src/components/mineru-options-form-field.tsx b/web/src/components/mineru-options-form-field.tsx
index e0d98056b5..ebca4e3ab2 100644
--- a/web/src/components/mineru-options-form-field.tsx
+++ b/web/src/components/mineru-options-form-field.tsx
@@ -15,7 +15,7 @@
*/
import { RAGFlowFormItem } from '@/components/ragflow-form';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from './originui/select-with-search';
import { Switch } from '@/components/ui/switch';
import { LLMFactory } from '@/constants/llm';
import { buildOptions } from '@/utils/form';
@@ -86,7 +86,7 @@ export function MinerUOptionsFormField({
horizontal={true}
>
{(field) => (
- <RAGFlowSelect
+ <SelectWithSearch
value={field.value || 'auto'}
onChange={field.onChange}
options={parseMethodOptions}
@@ -105,7 +105,7 @@ export function MinerUOptionsFormField({
horizontal={true}
>
{(field) => (
- <RAGFlowSelect
+ <SelectWithSearch
value={field.value || 'English'}
onChange={field.onChange}
options={languageOptions}
diff --git a/web/src/components/originui/select-with-search.tsx b/web/src/components/originui/select-with-search.tsx
index 87df74230a..e16077c101 100644
--- a/web/src/components/originui/select-with-search.tsx
+++ b/web/src/components/originui/select-with-search.tsx
@@ -28,11 +28,14 @@ import {
PopoverTrigger,
} from '@/components/ui/popover';
import { cn } from '@/lib/utils';
-import { RAGFlowSelectOptionType } from '../ui/select';
import { Separator } from '../ui/separator';
import { useTranslation } from 'react-i18next';
-export type SelectWithSearchOptionType = RAGFlowSelectOptionType & {
+export type SelectWithSearchOptionType = {
+ label: ReactNode;
+ value: string;
+ disabled?: boolean;
+ icon?: ReactNode;
description?: ReactNode;
};
@@ -40,6 +43,7 @@ export type SelectWithSearchFlagOptionType = {
label: ReactNode;
value?: string;
disabled?: boolean;
+ icon?: ReactNode;
options?: SelectWithSearchOptionType[];
keywords?: string[];
description?: ReactNode;
@@ -57,6 +61,8 @@ export type SelectWithSearchFlagProps = {
allowCustomValue?: boolean;
// Always show the search input even with few options
alwaysShowSearch?: boolean;
+ // Show only the selected option's icon in the trigger instead of its label
+ onlyShowSelectedIcon?: boolean;
// Return false to veto selecting the custom value on Enter
onNoMatchEnter?(searchValue: string): boolean | void;
disableAutoSelectOnEnter?: boolean;
@@ -71,20 +77,20 @@ function filterFn(value: string, search: string, keywords?: string[]) {
return 0;
}
-function findLabelWithoutOptions(
+function findOptionWithoutOptions(
options: SelectWithSearchFlagOptionType[],
value: string,
) {
- return options.find((opt) => opt.value === value)?.label || '';
+ return options.find((opt) => opt.value === value);
}
-function findLabelWithOptions(
+function findOptionWithOptions(
options: SelectWithSearchFlagOptionType[],
value: string,
) {
return options
.map((group) => group?.options?.find((item) => item.value === value))
- .filter(Boolean)[0]?.label;
+ .filter(Boolean)[0];
}
function hasMatchingOptions(
@@ -133,6 +139,7 @@ export const SelectWithSearch = forwardRef<
emptyData,
allowCustomValue = false,
alwaysShowSearch = false,
+ onlyShowSelectedIcon = false,
onNoMatchEnter,
disableAutoSelectOnEnter = false,
testId,
@@ -148,11 +155,11 @@ export const SelectWithSearch = forwardRef<
const [value, setValue] = useState<string>('');
const [searchValue, setSearchValue] = useState<string>('');
- const selectLabel = useMemo(() => {
+ const selectedOption = useMemo(() => {
if (options.every((x) => x.options === undefined)) {
- return findLabelWithoutOptions(options, value);
+ return findOptionWithoutOptions(options, value);
} else if (options.every((x) => Array.isArray(x.options))) {
- return findLabelWithOptions(options, value);
+ return findOptionWithOptions(options, value);
} else {
// Some have options, some don't
const optionsWithOptions = options.filter((x) =>
@@ -162,14 +169,16 @@ export const SelectWithSearch = forwardRef<
(x) => x.options === undefined,
);
- const label = findLabelWithOptions(optionsWithOptions, value);
- if (label) {
- return label;
+ const option = findOptionWithOptions(optionsWithOptions, value);
+ if (option) {
+ return option;
}
- return findLabelWithoutOptions(optionsWithoutOptions, value);
+ return findOptionWithoutOptions(optionsWithoutOptions, value);
}
}, [options, value]);
+ const selectLabel = selectedOption?.label;
+
const showSearch = useMemo(() => {
if (allowCustomValue || alwaysShowSearch) {
return true;
@@ -260,7 +269,9 @@ export const SelectWithSearch = forwardRef<
>
{selectLabel || value ? (
<span className="flex min-w-0 options-center gap-2 truncate text-text-primary">
- {selectLabel || value}
+ {onlyShowSelectedIcon && selectedOption?.icon
+ ? selectedOption.icon
+ : selectLabel || value}
</span>
) : (
<span className="text-text-disabled">{resolvedPlaceholder}</span>
@@ -354,7 +365,10 @@ export const SelectWithSearch = forwardRef<
value === option.value ? 'bg-bg-card' : '',
)}
>
- <span className="leading-none">{option.label}</span>
+ <span className="flex items-center gap-2 leading-none">
+ {option.icon}
+ {option.label}
+ </span>
{option.description && (
<span className="text-text-secondary text-xs leading-none">
{option.description}
@@ -396,7 +410,10 @@ export const SelectWithSearch = forwardRef<
},
)}
>
- <span className="leading-none">{group.label}</span>
+ <span className="flex items-center gap-2 leading-none">
+ {group.icon}
+ {group.label}
+ </span>
{group.description && (
<span className="text-text-secondary text-xs leading-none">
{group.description}
diff --git a/web/src/components/paddleocr-options-form-field.tsx b/web/src/components/paddleocr-options-form-field.tsx
index 0baae8fb32..4eec2824cc 100644
--- a/web/src/components/paddleocr-options-form-field.tsx
+++ b/web/src/components/paddleocr-options-form-field.tsx
@@ -16,7 +16,7 @@
import { RAGFlowFormItem } from '@/components/ragflow-form';
import { Input } from '@/components/ui/input';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from './originui/select-with-search';
import { LLMFactory } from '@/constants/llm';
import { buildOptions } from '@/utils/form';
import { useFormContext, useWatch } from 'react-hook-form';
@@ -113,7 +113,7 @@ export function PaddleOCROptionsFormField({
horizontal={true}
>
{(field) => (
- <RAGFlowSelect
+ <SelectWithSearch
value={field.value || undefined}
onChange={field.onChange}
options={algorithmOptions}
diff --git a/web/src/components/parse-configuration/graph-rag-form-fields.tsx b/web/src/components/parse-configuration/graph-rag-form-fields.tsx
deleted file mode 100644
index 649b5e099a..0000000000
--- a/web/src/components/parse-configuration/graph-rag-form-fields.tsx
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { FormLayout } from '@/constants/form';
-import { DocumentParserType, GenerateType } from '@/constants/knowledge';
-import { useTranslate } from '@/hooks/common-hooks';
-import { cn } from '@/lib/utils';
-import { useOwnerTenantId } from '@/pages/dataset/contexts/knowledge-base-context';
-import { LLMModelItem } from '@/pages/dataset/setting/python/configuration/common-item';
-import { upperFirst } from 'lodash';
-import { useCallback, useMemo } from 'react';
-import { useFormContext, useWatch } from 'react-hook-form';
-import { EntityTypesFormField } from '../entity-types-form-field';
-import { FormContainer } from '../form-container';
-import {
- GenerateLogButton,
- IGenerateLogButtonProps,
-} from '../generate-log-button';
-import { SliderInputFormField } from '../slider-input-form-field';
-import {
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from '../ui/form';
-import { RAGFlowSelect } from '../ui/select';
-import { Switch } from '../ui/switch';
-
-const excludedTagParseMethods = [
- DocumentParserType.Table,
- DocumentParserType.KnowledgeGraph,
- DocumentParserType.Tag,
-];
-
-export const showTagItems = (parserId: DocumentParserType) => {
- return !excludedTagParseMethods.includes(parserId);
-};
-
-const enum MethodValue {
- General = 'general',
- Light = 'light',
- NER = 'ner',
-}
-
-export const excludedParseMethods = [
- DocumentParserType.Table,
- DocumentParserType.Resume,
- DocumentParserType.Picture,
- DocumentParserType.KnowledgeGraph,
- DocumentParserType.Qa,
- DocumentParserType.Tag,
-];
-
-export const showGraphRagItems = (parserId: DocumentParserType | undefined) => {
- return !excludedParseMethods.some((x) => x === parserId);
-};
-
-type GraphRagItemsProps = {
- marginBottom?: boolean;
- className?: string;
- data: IGenerateLogButtonProps;
- onDelete?: () => void;
-};
-
-export function UseGraphRagFormField({
- data,
- onDelete,
-}: {
- data: IGenerateLogButtonProps;
- onDelete?: () => void;
-}) {
- const form = useFormContext();
- const { t } = useTranslate('knowledgeConfiguration');
-
- return (
- <FormField
- control={form.control}
- name="parser_config.graphrag.use_graphrag"
- render={() => (
- <FormItem defaultChecked={false} className=" items-center space-y-0 ">
- <div className="flex items-center gap-1">
- <FormLabel
- tooltip={t('useGraphRagTip')}
- className="text-sm whitespace-break-spaces w-1/4"
- >
- {t('useGraphRag')}
- </FormLabel>
- <div className="w-3/4">
- <FormControl>
- {/* <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- ></Switch> */}
- <GenerateLogButton
- {...data}
- onDelete={onDelete}
- className="w-full text-text-secondary"
- status={1}
- type={GenerateType.KnowledgeGraph}
- />
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- );
-}
-
-// The three types "table", "resume" and "one" do not display this configuration.
-const GraphRagItems = function GraphRagItems({
- marginBottom = false,
- className = 'p-10',
- data,
- onDelete,
-}: GraphRagItemsProps) {
- const { t } = useTranslate('knowledgeConfiguration');
- const form = useFormContext();
- const ownerTenantId = useOwnerTenantId();
-
- const useRaptor = useWatch({
- control: form.control,
- name: 'parser_config.graphrag.use_graphrag',
- });
-
- const methodOptions = useMemo(() => {
- return [MethodValue.Light, MethodValue.General /*, MethodValue.NER*/].map(
- (x) => ({
- value: x,
- label: x === MethodValue.NER ? 'NER' : upperFirst(x),
- }),
- );
- }, []);
-
- const renderWideTooltip = useCallback(
- (title: React.ReactNode | string) => {
- return typeof title === 'string' ? t(title) : title;
- },
- [t],
- );
-
- return (
- <FormContainer className={cn({ 'mb-4': marginBottom }, className)}>
- <LLMModelItem
- label={t('globalIndexModel')}
- name={'parser_config.llm_id'}
- ownerTenantId={ownerTenantId}
- />
- <UseGraphRagFormField
- data={data}
- onDelete={onDelete}
- ></UseGraphRagFormField>
- {useRaptor && (
- <>
- <EntityTypesFormField
- name="parser_config.graphrag.entity_types"
- addButtonTestId="ds-settings-graph-entity-types-add-btn"
- inputTestId="ds-settings-graph-entity-types-input"
- ></EntityTypesFormField>
- <FormField
- control={form.control}
- name="parser_config.graphrag.method"
- render={({ field }) => (
- <FormItem className=" items-center space-y-0 ">
- <div className="flex items-center">
- <FormLabel
- className="text-sm whitespace-nowrap w-1/4"
- tooltip={renderWideTooltip(
- <div
- dangerouslySetInnerHTML={{
- __html: t('graphRagMethodTip'),
- }}
- ></div>,
- )}
- >
- {t('graphRagMethod')}
- </FormLabel>
- <div className="w-3/4">
- <FormControl>
- <RAGFlowSelect
- {...field}
- options={methodOptions}
- triggerTestId="ds-settings-graph-method-select"
- ></RAGFlowSelect>
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
-
- <SliderInputFormField
- name="parser_config.graphrag.batch_chunk_token_size"
- label={t('graphRagBatchChunkTokenSize')}
- tooltip={t('graphRagBatchChunkTokenSizeTip')}
- max={8196}
- min={512}
- step={1}
- defaultValue={4096}
- layout={FormLayout.Horizontal}
- sliderTestId="ds-settings-graph-batch-chunk-token-size-slider"
- numberInputTestId="ds-settings-graph-batch-chunk-token-size-input"
- ></SliderInputFormField>
-
- <FormField
- control={form.control}
- name="parser_config.graphrag.resolution"
- render={({ field }) => (
- <FormItem className=" items-center space-y-0 ">
- <div className="flex items-center">
- <FormLabel
- tooltip={renderWideTooltip('resolutionTip')}
- className="text-sm whitespace-nowrap w-1/4"
- >
- {t('resolution')}
- </FormLabel>
- <div className="w-3/4">
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- data-testid="ds-settings-graph-entity-resolution-switch"
- ></Switch>
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="parser_config.graphrag.community"
- render={({ field }) => (
- <FormItem className=" items-center space-y-0 ">
- <div className="flex items-center">
- <FormLabel
- tooltip={renderWideTooltip('communityTip')}
- className="text-sm whitespace-nowrap w-1/4"
- >
- {t('community')}
- </FormLabel>
- <div className="w-3/4">
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- data-testid="ds-settings-graph-community-reports-switch"
- ></Switch>
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- {/* {showGenerateItem && (
- <div className="w-full flex items-center">
- <div className="text-sm whitespace-nowrap w-1/4">
- {t('extractKnowledgeGraph')}
- </div>
- <GenerateLogButton
- className="w-3/4 text-text-secondary"
- status={1}
- type={GenerateType.KnowledgeGraph}
- />
- </div>
- )} */}
- </>
- )}
- </FormContainer>
- );
-};
-
-export default GraphRagItems;
diff --git a/web/src/components/parse-configuration/raptor-form-fields.tsx b/web/src/components/parse-configuration/raptor-form-fields.tsx
deleted file mode 100644
index 9de2f7dbd9..0000000000
--- a/web/src/components/parse-configuration/raptor-form-fields.tsx
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { FormLayout } from '@/constants/form';
-import { DocumentParserType, GenerateType } from '@/constants/knowledge';
-import { useTranslate } from '@/hooks/common-hooks';
-import random from 'lodash/random';
-import { Shuffle } from 'lucide-react';
-import { useCallback, useEffect, useMemo } from 'react';
-import { useFormContext, useWatch } from 'react-hook-form';
-import {
- GenerateLogButton,
- IGenerateLogButtonProps,
-} from '../generate-log-button';
-import { SliderInputFormField } from '../slider-input-form-field';
-import {
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from '../ui/form';
-import { ExpandedInput } from '../ui/input';
-import { Radio } from '../ui/radio';
-import { Textarea } from '../ui/textarea';
-
-export const excludedParseMethods = [
- DocumentParserType.Table,
- DocumentParserType.Resume,
- DocumentParserType.One,
- DocumentParserType.Picture,
- DocumentParserType.KnowledgeGraph,
- DocumentParserType.Qa,
- DocumentParserType.Tag,
-];
-
-export const showRaptorParseConfiguration = (
- parserId: DocumentParserType | undefined,
-) => {
- return !excludedParseMethods.some((x) => x === parserId);
-};
-
-export const excludedTagParseMethods = [
- DocumentParserType.Table,
- DocumentParserType.KnowledgeGraph,
- DocumentParserType.Tag,
-];
-
-export const showTagItems = (parserId: DocumentParserType) => {
- return !excludedTagParseMethods.includes(parserId);
-};
-
-const UseRaptorField = 'parser_config.raptor.use_raptor';
-const RandomSeedField = 'parser_config.raptor.random_seed';
-const ClusteringMethodField = 'parser_config.raptor.clustering_method';
-const TreeBuilderField = 'parser_config.raptor.tree_builder';
-const MaxClusterMax = 1024;
-
-// The three types "table", "resume" and "one" do not display this configuration.
-
-const RaptorFormFields = ({
- data,
- onDelete,
-}: {
- data: IGenerateLogButtonProps;
- onDelete: () => void;
-}) => {
- const form = useFormContext();
- const { t } = useTranslate('knowledgeConfiguration');
- const useRaptor = useWatch({ name: UseRaptorField });
- const clusteringMethod = useWatch({ name: ClusteringMethodField });
- const selectedClusteringMethod = useMemo(
- () =>
- (clusteringMethod ?? form.getValues(ClusteringMethodField) ?? 'gmm') as
- | 'gmm'
- | 'ahc',
- [clusteringMethod, form],
- );
-
- const handleGenerate = useCallback(() => {
- form.setValue(RandomSeedField, random(10000));
- }, [form]);
-
- const handleClusteringMethodChange = useCallback(
- (method: 'gmm' | 'ahc') => {
- form.setValue(ClusteringMethodField, method, {
- shouldDirty: true,
- shouldValidate: true,
- });
- form.setValue(TreeBuilderField, 'raptor', {
- shouldDirty: true,
- shouldValidate: true,
- });
- },
- [form],
- );
-
- useEffect(() => {
- if (!clusteringMethod) {
- handleClusteringMethodChange('gmm');
- }
- }, [clusteringMethod, handleClusteringMethodChange]);
-
- return (
- <>
- <FormField
- control={form.control}
- name={UseRaptorField}
- render={() => {
- return (
- <FormItem
- defaultChecked={false}
- className="items-center space-y-0 "
- >
- <div className="flex items-center gap-1">
- <FormLabel
- tooltip={t('useRaptorTip')}
- className="text-sm w-1/4 whitespace-break-spaces"
- >
- {t('useRaptor')}
- </FormLabel>
- <div className="w-3/4">
- <FormControl>
- <GenerateLogButton
- {...data}
- onDelete={onDelete}
- className="w-full text-text-secondary"
- status={1}
- type={GenerateType.Raptor}
- />
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- );
- }}
- />
- <FormField
- control={form.control}
- name={'parser_config.raptor.scope'}
- render={({ field }) => {
- return (
- <FormItem className=" items-center space-y-0 ">
- <div className="flex items-start">
- <FormLabel
- tooltip={t('generationScopeTip')}
- className="text-sm whitespace-nowrap w-1/4"
- >
- {t('generationScope')}
- </FormLabel>
- <div className="w-3/4">
- <FormControl>
- <Radio.Group {...field} disabled={!!data?.finish_at}>
- <div className={'flex gap-4 w-full text-text-secondary '}>
- <Radio
- value="dataset"
- testId="ds-settings-raptor-generation-scope-option-dataset"
- >
- {t('scopeDataset')}
- </Radio>
- <Radio
- value="file"
- testId="ds-settings-raptor-generation-scope-option-document"
- >
- {t('scopeSingleFile')}
- </Radio>
- </div>
- </Radio.Group>
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- );
- }}
- />
- {useRaptor && (
- <div className="space-y-3">
- <FormField
- control={form.control}
- name={'parser_config.raptor.prompt'}
- render={({ field }) => {
- return (
- <FormItem className=" items-center space-y-0 ">
- <div className="flex items-start">
- <FormLabel
- tooltip={t('promptTip')}
- className="text-sm whitespace-nowrap w-1/4"
- >
- {t('prompt')}
- </FormLabel>
- <div className="w-3/4">
- <FormControl>
- <Textarea
- {...field}
- rows={8}
- onChange={(e) => {
- field.onChange(e?.target?.value);
- }}
- data-testid="ds-settings-raptor-prompt-textarea"
- />
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- );
- }}
- />
- <SliderInputFormField
- name={'parser_config.raptor.max_token'}
- label={t('maxToken')}
- tooltip={t('maxTokenTip')}
- max={2048}
- min={0}
- layout={FormLayout.Horizontal}
- sliderTestId="ds-settings-raptor-max-token-slider"
- numberInputTestId="ds-settings-raptor-max-token-input"
- ></SliderInputFormField>
- <SliderInputFormField
- name={'parser_config.raptor.threshold'}
- label={t('threshold')}
- tooltip={t('thresholdTip')}
- step={0.01}
- max={1}
- min={0}
- layout={FormLayout.Horizontal}
- sliderTestId="ds-settings-raptor-threshold-slider"
- numberInputTestId="ds-settings-raptor-threshold-input"
- ></SliderInputFormField>
- <FormField
- control={form.control}
- name={ClusteringMethodField}
- render={({ field }) => {
- return (
- <FormItem className=" items-center space-y-0 ">
- <div className="flex items-start">
- <FormLabel
- tooltip={t('clusteringMethodTip')}
- className="text-sm whitespace-nowrap w-1/4"
- >
- {t('clusteringMethod')}
- </FormLabel>
- <div className="w-3/4">
- <FormControl>
- <Radio.Group
- {...field}
- value={selectedClusteringMethod}
- onChange={(value) =>
- handleClusteringMethodChange(value as 'gmm' | 'ahc')
- }
- >
- <div
- className={'flex gap-4 w-full text-text-secondary '}
- >
- <Radio
- value="gmm"
- testId="ds-settings-raptor-clustering-method-option-gmm"
- >
- {t('clusteringMethodGmm')}
- </Radio>
- <Radio
- value="ahc"
- testId="ds-settings-raptor-clustering-method-option-ahc"
- >
- {t('clusteringMethodAhc')}
- </Radio>
- </div>
- </Radio.Group>
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- );
- }}
- />
- <SliderInputFormField
- name={'parser_config.raptor.max_cluster'}
- label={t('maxCluster')}
- tooltip={t('maxClusterTip')}
- max={MaxClusterMax}
- min={1}
- layout={FormLayout.Horizontal}
- sliderTestId="ds-settings-raptor-max-cluster-slider"
- numberInputTestId="ds-settings-raptor-max-cluster-input"
- ></SliderInputFormField>
- <FormField
- control={form.control}
- name={'parser_config.raptor.random_seed'}
- render={({ field }) => (
- <FormItem className=" items-center space-y-0 ">
- <div className="flex items-center">
- <FormLabel
- className="text-sm whitespace-wrap w-1/4"
- tooltip={t('randomSeedTip')}
- >
- {t('randomSeed')}
- </FormLabel>
- <div className="w-3/4">
- <FormControl defaultValue={0}>
- <ExpandedInput
- {...field}
- className="w-full"
- defaultValue={0}
- type="number"
- data-testid="ds-settings-raptor-seed-input"
- suffix={
- <div className="w-7 flex justify-center items-center">
- <Shuffle
- className="size-3.5 cursor-pointer"
- onClick={handleGenerate}
- data-testid="ds-settings-raptor-seed-randomize-btn"
- />
- </div>
- }
- />
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- </div>
- )}
- </>
- );
-};
-
-export default RaptorFormFields;
diff --git a/web/src/components/ui/ragflow-pagination.tsx b/web/src/components/ui/ragflow-pagination.tsx
index 6e1446560a..dc20a0ccbd 100644
--- a/web/src/components/ui/ragflow-pagination.tsx
+++ b/web/src/components/ui/ragflow-pagination.tsx
@@ -7,7 +7,10 @@ import {
PaginationNext,
PaginationPrevious,
} from '@/components/ui/pagination';
-import { RAGFlowSelect, RAGFlowSelectOptionType } from '@/components/ui/select';
+import {
+ SelectWithSearch,
+ SelectWithSearchOptionType,
+} from '../originui/select-with-search';
import { cn } from '@/lib/utils';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -32,7 +35,7 @@ export function RAGFlowPagination({
const [currentPage, setCurrentPage] = useState(1);
const [currentPageSize, setCurrentPageSize] = useState('10');
- const sizeChangerOptions: RAGFlowSelectOptionType[] = useMemo(() => {
+ const sizeChangerOptions: SelectWithSearchOptionType[] = useMemo(() => {
return [10, 20, 50, 100].map((x) => ({
label: <span>{t('pagination.page', { page: x })}</span>,
value: x.toString(),
@@ -175,11 +178,11 @@ export function RAGFlowPagination({
</Pagination>
{showSizeChanger && (
- <RAGFlowSelect
+ <SelectWithSearch
options={sizeChangerOptions}
value={currentPageSize}
onChange={handlePageSizeChange}
- triggerClassName="bg-bg-card border-transparent"
+ triggerClassName="w-fit bg-bg-card border-transparent"
/>
)}
</div>
diff --git a/web/src/components/ui/select.tsx b/web/src/components/ui/select.tsx
index 4b34df1a94..5075cdcde9 100644
--- a/web/src/components/ui/select.tsx
+++ b/web/src/components/ui/select.tsx
@@ -1,14 +1,10 @@
'use client';
import * as SelectPrimitive from '@radix-ui/react-select';
-import { Check, ChevronDown, ChevronUp, X } from 'lucide-react';
+import { Check, ChevronDown, ChevronUp } from 'lucide-react';
import * as React from 'react';
import { cn } from '@/lib/utils';
-import { ControllerRenderProps } from 'react-hook-form';
-
-import { FormControl } from '@/components/ui/form';
-import { forwardRef, useCallback, useEffect } from 'react';
const Select = SelectPrimitive.Root;
@@ -24,11 +20,8 @@ const SelectValue = SelectPrimitive.Value;
const SelectTrigger = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Trigger>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> & {
- onReset?: () => void;
- allowClear?: boolean;
- }
->(({ className, children, value, onReset, allowClear, ...props }, ref) => (
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
+>(({ className, children, ...props }, ref) => (
<SelectPrimitive.Trigger
ref={ref}
className={cn(
@@ -42,17 +35,8 @@ const SelectTrigger = React.forwardRef<
{...props}
>
{children}
- <SelectPrimitive.Icon
- asChild
- onPointerDown={(event) => {
- event.stopPropagation();
- }}
- >
- {value && allowClear ? (
- <X className="h-4 w-4 opacity-50 cursor-pointer" onClick={onReset} />
- ) : (
- <ChevronDown className="h-4 w-4 opacity-50" />
- )}
+ <SelectPrimitive.Icon asChild>
+ <ChevronDown className="h-4 w-4 opacity-50" />
</SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
));
@@ -188,179 +172,3 @@ export {
SelectTrigger,
SelectValue,
};
-
-export type RAGFlowSelectOptionType = {
- label: React.ReactNode;
- value: string;
- disabled?: boolean;
- icon?: React.ReactNode;
-};
-
-export type RAGFlowSelectGroupOptionType = {
- label: React.ReactNode;
- options: RAGFlowSelectOptionType[];
-};
-
-export type RAGFlowSelectProps = Partial<ControllerRenderProps> & {
- FormControlComponent?: typeof FormControl;
- options?: (RAGFlowSelectOptionType | RAGFlowSelectGroupOptionType)[];
- allowClear?: boolean;
- placeholder?: React.ReactNode;
- contentProps?: React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>;
- triggerClassName?: string;
- onlyShowSelectedIcon?: boolean;
- triggerTestId?: string;
- optionTestIdPrefix?: string;
-} & SelectPrimitive.SelectProps;
-
-/**
- *
- * Reference:
- * https://github.com/shadcn-ui/ui/discussions/638
- * https://github.com/radix-ui/primitives/discussions/2645#discussioncomment-8343397
- *
- * @export
- * @param {(Partial<ControllerRenderProps> & {
- * FormControlComponent?: typeof FormControl;
- * })} {
- * value: initialValue,
- * onChange,
- * FormControlComponent,
- * }
- * @return {*}
- */
-export const RAGFlowSelect = forwardRef<
- React.ElementRef<typeof SelectPrimitive.Trigger>,
- RAGFlowSelectProps
->(function (
- {
- value: initialValue,
- onChange,
- FormControlComponent,
- options = [],
- allowClear,
- placeholder,
- contentProps = {},
- disabled = false,
- // defaultValue,
- triggerClassName,
- onlyShowSelectedIcon = false,
- triggerTestId,
- optionTestIdPrefix,
- },
- ref,
-) {
- const [key, setKey] = React.useState(+new Date());
- const [value, setValue] = React.useState<string | undefined>(initialValue);
-
- const FormControlWidget = FormControlComponent
- ? FormControlComponent
- : ({ children }: React.PropsWithChildren) => <div>{children}</div>;
-
- const handleChange = useCallback(
- (val?: string) => {
- setValue(val);
- onChange?.(val);
- },
- [onChange],
- );
-
- const handleReset = useCallback(() => {
- handleChange(undefined);
- setKey(+new Date());
- }, [handleChange]);
-
- useEffect(() => {
- setValue((preValue) => {
- if (preValue !== initialValue) {
- return initialValue;
- }
- return preValue;
- });
- }, [initialValue]);
-
- // The value selected in the drop-down box only displays the icon
- const label = React.useMemo(() => {
- let nextOptions = options;
- if (options.some((x) => !('value' in x))) {
- nextOptions = (options as RAGFlowSelectGroupOptionType[]).reduce<
- RAGFlowSelectOptionType[]
- >((pre, cur) => {
- return pre.concat(cur?.options ?? []);
- }, []);
- }
-
- const option = (nextOptions as RAGFlowSelectOptionType[]).find(
- (x) => x.value === value,
- );
-
- return onlyShowSelectedIcon ? option?.icon : option?.label;
- }, [onlyShowSelectedIcon, options, value]);
-
- return (
- <Select
- onValueChange={handleChange}
- value={value}
- key={key}
- disabled={disabled}
- >
- <FormControlWidget>
- <SelectTrigger
- value={value}
- onReset={handleReset}
- allowClear={allowClear}
- ref={ref}
- className={triggerClassName}
- data-testid={triggerTestId}
- >
- <SelectValue placeholder={placeholder}>{label}</SelectValue>
- </SelectTrigger>
- </FormControlWidget>
- <SelectContent {...contentProps}>
- {options.map((o, idx) => {
- if ('value' in o) {
- return (
- <SelectItem
- value={o.value as RAGFlowSelectOptionType['value']}
- key={o.value}
- disabled={o.disabled}
- data-testid={
- optionTestIdPrefix
- ? `${optionTestIdPrefix}-${o.value}`
- : undefined
- }
- >
- <div className="flex items-center gap-1">
- {o.icon}
- {o.label}
- </div>
- </SelectItem>
- );
- }
-
- return (
- <SelectGroup key={idx}>
- <SelectLabel className="pl-2">{o.label}</SelectLabel>
- {o.options.map((x) => (
- <SelectItem
- value={x.value}
- key={x.value}
- disabled={x.disabled}
- data-testid={
- optionTestIdPrefix
- ? `${optionTestIdPrefix}-${x.value}`
- : undefined
- }
- >
- {x.label}
- </SelectItem>
- ))}
- </SelectGroup>
- );
- })}
- </SelectContent>
- </Select>
- );
-});
-
-RAGFlowSelect.displayName = 'RAGFlowSelect';
diff --git a/web/src/pages/agent/form/agent-form/dynamic-prompt.tsx b/web/src/pages/agent/form/agent-form/dynamic-prompt.tsx
index 1cda9fbd50..446271026d 100644
--- a/web/src/pages/agent/form/agent-form/dynamic-prompt.tsx
+++ b/web/src/pages/agent/form/agent-form/dynamic-prompt.tsx
@@ -6,7 +6,7 @@ import {
FormLabel,
FormMessage,
} from '@/components/ui/form';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { X } from 'lucide-react';
import { memo } from 'react';
import { useFieldArray, useFormContext } from 'react-hook-form';
@@ -43,10 +43,10 @@ const DynamicPrompt = () => {
<FormItem className="w-1/3">
<FormLabel />
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
{...field}
options={options}
- ></RAGFlowSelect>
+ ></SelectWithSearch>
</FormControl>
<FormMessage />
</FormItem>
diff --git a/web/src/pages/agent/form/begin-form/index.tsx b/web/src/pages/agent/form/begin-form/index.tsx
index 7895bb2d5f..38360590a0 100644
--- a/web/src/pages/agent/form/begin-form/index.tsx
+++ b/web/src/pages/agent/form/begin-form/index.tsx
@@ -4,7 +4,7 @@ import { RAGFlowFormItem } from '@/components/ragflow-form';
import { SwitchFormField } from '@/components/switch-fom-field';
import { Button } from '@/components/ui/button';
import { Form, FormField } from '@/components/ui/form';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { Textarea } from '@/components/ui/textarea';
import { FormTooltip } from '@/components/ui/tooltip';
import { zodResolver } from '@hookform/resolvers/zod';
@@ -101,15 +101,15 @@ function BeginForm({ node }: INextOperatorForm) {
tooltip={t('flow.modeTip')}
>
{(field) => (
- <RAGFlowSelect
+ <SelectWithSearch
placeholder={t('common.pleaseSelect')}
options={ModeOptions}
{...field}
onChange={(val) => {
- handleModeChange(val);
+ handleModeChange(val as AgentDialogueMode);
field.onChange(val);
}}
- ></RAGFlowSelect>
+ ></SelectWithSearch>
)}
</RAGFlowFormItem>
{mode === AgentDialogueMode.Conversational && (
diff --git a/web/src/pages/agent/form/begin-form/parameter-dialog.tsx b/web/src/pages/agent/form/begin-form/parameter-dialog.tsx
index c1f64926cf..1928c45bbe 100644
--- a/web/src/pages/agent/form/begin-form/parameter-dialog.tsx
+++ b/web/src/pages/agent/form/begin-form/parameter-dialog.tsx
@@ -16,7 +16,10 @@ import {
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
-import { RAGFlowSelect, RAGFlowSelectOptionType } from '@/components/ui/select';
+import {
+ SelectWithSearch,
+ SelectWithSearchOptionType,
+} from '@/components/originui/select-with-search';
import { Switch } from '@/components/ui/switch';
import { useTranslate } from '@/hooks/common-hooks';
import { IModalProps } from '@/interfaces/common';
@@ -75,7 +78,7 @@ function ParameterForm({
});
const options = useMemo(() => {
- return Object.values(BeginQueryType).reduce<RAGFlowSelectOptionType[]>(
+ return Object.values(BeginQueryType).reduce<SelectWithSearchOptionType[]>(
(pre, cur) => {
const Icon = BeginQueryTypeIconMap[cur];
@@ -140,7 +143,7 @@ function ParameterForm({
<FormItem>
<FormLabel>{t('type')}</FormLabel>
<FormControl>
- <RAGFlowSelect {...field} options={options} />
+ <SelectWithSearch {...field} options={options} />
</FormControl>
<FormMessage />
</FormItem>
diff --git a/web/src/pages/agent/form/code-form/index.tsx b/web/src/pages/agent/form/code-form/index.tsx
index b2f954e386..964c6d38b8 100644
--- a/web/src/pages/agent/form/code-form/index.tsx
+++ b/web/src/pages/agent/form/code-form/index.tsx
@@ -13,7 +13,7 @@ import {
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { ProgrammingLanguage } from '@/constants/agent';
import { ICodeForm } from '@/interfaces/database/agent';
import { zodResolver } from '@hookform/resolvers/zod';
@@ -103,7 +103,7 @@ function CodeForm({ node }: INextOperatorForm) {
render={({ field }) => (
<FormItem>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
{...field}
onChange={(val) => {
field.onChange(val);
@@ -184,11 +184,11 @@ function CodeForm({ node }: INextOperatorForm) {
<FormItem className="flex-1">
<FormLabel>Type</FormLabel>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
placeholder={t('common.pleaseSelect')}
options={TypeOptions}
{...field}
- ></RAGFlowSelect>
+ ></SelectWithSearch>
</FormControl>
<FormMessage />
</FormItem>
diff --git a/web/src/pages/agent/form/code-form/next-variable.tsx b/web/src/pages/agent/form/code-form/next-variable.tsx
index b6174a1055..1e205149b2 100644
--- a/web/src/pages/agent/form/code-form/next-variable.tsx
+++ b/web/src/pages/agent/form/code-form/next-variable.tsx
@@ -10,7 +10,6 @@ import {
FormMessage,
} from '@/components/ui/form';
import { BlurInput } from '@/components/ui/input';
-import { RAGFlowSelect } from '@/components/ui/select';
import { Separator } from '@/components/ui/separator';
import { RAGFlowNodeType } from '@/interfaces/database/agent';
import { X } from 'lucide-react';
@@ -77,11 +76,11 @@ export function DynamicVariableForm({ name = 'arguments', isOutputs }: IProps) {
<FormItem className="flex-1 overflow-hidden">
<FormControl>
{isOutputs ? (
- <RAGFlowSelect
+ <SelectWithSearch
placeholder={t('common.pleaseSelect')}
options={TypeOptions}
{...field}
- ></RAGFlowSelect>
+ ></SelectWithSearch>
) : (
<SelectWithSearch
options={nextOptions}
diff --git a/web/src/pages/agent/form/doc-generator-form/index.tsx b/web/src/pages/agent/form/doc-generator-form/index.tsx
index 7ec137f6ec..341a3b4428 100644
--- a/web/src/pages/agent/form/doc-generator-form/index.tsx
+++ b/web/src/pages/agent/form/doc-generator-form/index.tsx
@@ -8,7 +8,7 @@ import {
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { Switch } from '@/components/ui/switch';
import { zodResolver } from '@hookform/resolvers/zod';
import { memo, useEffect, useMemo } from 'react';
@@ -85,7 +85,7 @@ function DocGeneratorForm({ node }: INextOperatorForm) {
<FormItem>
<FormLabel>Output Format</FormLabel>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
{...field}
options={[
{ label: 'PDF', value: 'pdf' },
@@ -94,7 +94,7 @@ function DocGeneratorForm({ node }: INextOperatorForm) {
{ label: 'Markdown', value: 'markdown' },
{ label: 'HTML', value: 'html' },
]}
- ></RAGFlowSelect>
+ ></SelectWithSearch>
</FormControl>
<FormMessage />
</FormItem>
diff --git a/web/src/pages/agent/form/duckduckgo-form/index.tsx b/web/src/pages/agent/form/duckduckgo-form/index.tsx
index 776635d3cd..2d0d1daef1 100644
--- a/web/src/pages/agent/form/duckduckgo-form/index.tsx
+++ b/web/src/pages/agent/form/duckduckgo-form/index.tsx
@@ -8,7 +8,7 @@ import {
FormLabel,
FormMessage,
} from '@/components/ui/form';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { useTranslate } from '@/hooks/common-hooks';
import { zodResolver } from '@hookform/resolvers/zod';
import { memo, useMemo } from 'react';
@@ -51,7 +51,7 @@ export function DuckDuckGoWidgets() {
<FormItem>
<FormLabel tooltip={t('channelTip')}>{t('channel')}</FormLabel>
<FormControl>
- <RAGFlowSelect {...field} options={options} />
+ <SelectWithSearch {...field} options={options} />
</FormControl>
<FormMessage />
</FormItem>
diff --git a/web/src/pages/agent/form/keenable-form/index.tsx b/web/src/pages/agent/form/keenable-form/index.tsx
index 4ba3fcdd61..fa46005075 100644
--- a/web/src/pages/agent/form/keenable-form/index.tsx
+++ b/web/src/pages/agent/form/keenable-form/index.tsx
@@ -9,7 +9,7 @@ import {
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { useTranslate } from '@/hooks/common-hooks';
import { zodResolver } from '@hookform/resolvers/zod';
import { memo, useMemo } from 'react';
@@ -60,7 +60,7 @@ export function KeenableWidgets() {
<FormItem>
<FormLabel>{t('keenableMode')}</FormLabel>
<FormControl>
- <RAGFlowSelect {...field} options={modeOptions} />
+ <SelectWithSearch {...field} options={modeOptions} />
</FormControl>
<FormMessage />
</FormItem>
diff --git a/web/src/pages/agent/form/message-form/index.tsx b/web/src/pages/agent/form/message-form/index.tsx
index ddc8a09ca7..5e3d73e1c3 100644
--- a/web/src/pages/agent/form/message-form/index.tsx
+++ b/web/src/pages/agent/form/message-form/index.tsx
@@ -8,7 +8,7 @@ import {
FormLabel,
FormMessage,
} from '@/components/ui/form';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { Switch } from '@/components/ui/switch';
import { WebHookResponseStatusFormField } from '@/components/webhook-response-status';
import { zodResolver } from '@hookform/resolvers/zod';
@@ -123,7 +123,7 @@ function MessageForm({ node }: INextOperatorForm) {
render={({ field }) => (
<FormItem className="flex-1">
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
options={Object.keys(ExportFileType).map(
(key: string) => {
return {
@@ -136,10 +136,9 @@ function MessageForm({ node }: INextOperatorForm) {
},
)}
{...field}
- onValueChange={field.onChange}
placeholder={t('common.selectPlaceholder')}
allowClear
- ></RAGFlowSelect>
+ ></SelectWithSearch>
</FormControl>
</FormItem>
)}
diff --git a/web/src/pages/agent/form/querit-contents-form/index.tsx b/web/src/pages/agent/form/querit-contents-form/index.tsx
index 6db655c308..d69c6de90c 100644
--- a/web/src/pages/agent/form/querit-contents-form/index.tsx
+++ b/web/src/pages/agent/form/querit-contents-form/index.tsx
@@ -8,7 +8,7 @@ import {
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { Switch } from '@/components/ui/switch';
import { useTranslate } from '@/hooks/common-hooks';
import { buildOptions } from '@/utils/form';
@@ -85,7 +85,7 @@ function QueritContentsForm({ node }: INextOperatorForm) {
<FormItem>
<FormLabel>{t('format')}</FormLabel>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
{...field}
options={buildOptions(QueritContentFormat)}
/>
diff --git a/web/src/pages/agent/form/rewrite-question-form/index.tsx b/web/src/pages/agent/form/rewrite-question-form/index.tsx
index 336d60b4d8..da543d79d5 100644
--- a/web/src/pages/agent/form/rewrite-question-form/index.tsx
+++ b/web/src/pages/agent/form/rewrite-question-form/index.tsx
@@ -8,7 +8,7 @@ import {
FormLabel,
FormMessage,
} from '@/components/ui/form';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { useTranslation } from 'react-i18next';
import { INextOperatorForm } from '../../interface';
import { useOwnerTenantId } from '../../context';
@@ -41,11 +41,11 @@ const RewriteQuestionForm = ({ form }: INextOperatorForm) => {
{t('chat.language')}
</FormLabel>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
options={GoogleLanguageOptions}
allowClear={true}
{...field}
- ></RAGFlowSelect>
+ ></SelectWithSearch>
</FormControl>
<FormMessage />
</FormItem>
diff --git a/web/src/pages/agent/form/sofya-form/index.tsx b/web/src/pages/agent/form/sofya-form/index.tsx
index 68090f0b96..421dc00bf5 100644
--- a/web/src/pages/agent/form/sofya-form/index.tsx
+++ b/web/src/pages/agent/form/sofya-form/index.tsx
@@ -8,7 +8,7 @@ import {
FormLabel,
FormMessage,
} from '@/components/ui/form';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { useTranslate } from '@/hooks/common-hooks';
import { zodResolver } from '@hookform/resolvers/zod';
import { memo, useMemo } from 'react';
@@ -67,7 +67,7 @@ export function SofyaWidgets() {
{t('sofyaSearchDepth')}
</FormLabel>
<FormControl>
- <RAGFlowSelect {...field} options={searchDepthOptions} />
+ <SelectWithSearch {...field} options={searchDepthOptions} />
</FormControl>
<FormMessage />
</FormItem>
diff --git a/web/src/pages/agent/form/string-transform-form/index.tsx b/web/src/pages/agent/form/string-transform-form/index.tsx
index dc9258a183..6c0d5ff70e 100644
--- a/web/src/pages/agent/form/string-transform-form/index.tsx
+++ b/web/src/pages/agent/form/string-transform-form/index.tsx
@@ -8,7 +8,7 @@ import {
FormMessage,
} from '@/components/ui/form';
import { MultiSelect } from '@/components/ui/multi-select';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { zodResolver } from '@hookform/resolvers/zod';
import { t } from 'i18next';
import { toLower } from 'lodash';
@@ -87,16 +87,16 @@ function StringTransformForm({ node }: INextOperatorForm) {
<FormItem>
<FormLabel>{t('flow.method')}</FormLabel>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
{...field}
options={Object.values(StringTransformMethod).map(
(val) => ({ label: t('flow.' + val), value: val }),
)}
onChange={(value) => {
- handleMethodChange(value);
+ handleMethodChange(value as StringTransformMethod);
field.onChange(value);
}}
- ></RAGFlowSelect>
+ ></SelectWithSearch>
</FormControl>
<FormMessage />
</FormItem>
@@ -139,10 +139,11 @@ function StringTransformForm({ node }: INextOperatorForm) {
// {...field}
/>
) : (
- <RAGFlowSelect
+ <SelectWithSearch
{...field}
+ value={field.value as string}
options={DelimiterOptions}
- ></RAGFlowSelect>
+ ></SelectWithSearch>
)}
</FormControl>
<FormMessage />
diff --git a/web/src/pages/agent/form/switch-form/index.tsx b/web/src/pages/agent/form/switch-form/index.tsx
index 744a03088e..a590bc90f0 100644
--- a/web/src/pages/agent/form/switch-form/index.tsx
+++ b/web/src/pages/agent/form/switch-form/index.tsx
@@ -1,3 +1,4 @@
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { BlockButton, Button } from '@/components/ui/button';
import { Card, CardContent } from '@/components/ui/card';
import {
@@ -8,7 +9,6 @@ import {
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
-import { RAGFlowSelect } from '@/components/ui/select';
import { Separator } from '@/components/ui/separator';
import { Textarea } from '@/components/ui/textarea';
import { SwitchLogicOperator } from '@/constants/agent';
@@ -77,8 +77,7 @@ type VariableWithPathProps = {
function VariableWithPath({ name }: VariableWithPathProps) {
const { t: translate } = useTranslation();
const form = useFormContext();
- const fullValue: string =
- useWatch({ control: form.control, name }) ?? '';
+ const fullValue: string = useWatch({ control: form.control, name }) ?? '';
const { base, suffix } = useMemo(
() => splitBaseAndPath(fullValue),
@@ -184,9 +183,7 @@ function ConditionCards({
render={() => (
<FormItem className="flex-1 min-w-0">
<FormControl>
- <VariableWithPath
- name={`${name}.${index}.cpn_id`}
- />
+ <VariableWithPath name={`${name}.${index}.cpn_id`} />
</FormControl>
<FormMessage />
</FormItem>
@@ -200,7 +197,7 @@ function ConditionCards({
render={({ field }) => (
<FormItem>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
{...field}
options={switchOperatorOptions}
onlyShowSelectedIcon
@@ -319,7 +316,7 @@ function SwitchForm({ node }: IOperatorForm) {
render={({ field }) => (
<FormItem>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
{...field}
options={switchLogicOperatorOptions}
/>
diff --git a/web/src/pages/agent/form/tavily-extract-form/index.tsx b/web/src/pages/agent/form/tavily-extract-form/index.tsx
index 45a9e0fe71..dafb56e2dc 100644
--- a/web/src/pages/agent/form/tavily-extract-form/index.tsx
+++ b/web/src/pages/agent/form/tavily-extract-form/index.tsx
@@ -7,7 +7,7 @@ import {
FormLabel,
FormMessage,
} from '@/components/ui/form';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { buildOptions } from '@/utils/form';
import { zodResolver } from '@hookform/resolvers/zod';
import { t } from 'i18next';
@@ -82,7 +82,7 @@ function TavilyExtractForm({ node }: INextOperatorForm) {
<FormItem>
<FormLabel>{t('flow.extractDepth')}</FormLabel>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
placeholder="shadcn"
{...field}
options={buildOptions(TavilyExtractDepth, t, 'flow')}
@@ -99,7 +99,7 @@ function TavilyExtractForm({ node }: INextOperatorForm) {
<FormItem>
<FormLabel>{t('flow.format')}</FormLabel>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
placeholder="shadcn"
{...field}
options={buildOptions(TavilyExtractFormat)}
diff --git a/web/src/pages/agent/form/tavily-form/index.tsx b/web/src/pages/agent/form/tavily-form/index.tsx
index afa8d859b4..f75f96712d 100644
--- a/web/src/pages/agent/form/tavily-form/index.tsx
+++ b/web/src/pages/agent/form/tavily-form/index.tsx
@@ -8,7 +8,7 @@ import {
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { Switch } from '@/components/ui/switch';
import { buildOptions } from '@/utils/form';
import { zodResolver } from '@hookform/resolvers/zod';
@@ -77,7 +77,7 @@ function TavilyForm({ node }: INextOperatorForm) {
<FormItem>
<FormLabel>{t('flow.searchDepth')}</FormLabel>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
placeholder="shadcn"
{...field}
options={buildOptions(TavilySearchDepth, t, 'flow')}
@@ -94,7 +94,7 @@ function TavilyForm({ node }: INextOperatorForm) {
<FormItem>
<FormLabel>{t('flow.tavilyTopic')}</FormLabel>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
placeholder="shadcn"
{...field}
options={buildOptions(TavilyTopic, t, 'flow')}
diff --git a/web/src/pages/agent/form/wencai-form/index.tsx b/web/src/pages/agent/form/wencai-form/index.tsx
index a4e668ed97..5fd5e873ec 100644
--- a/web/src/pages/agent/form/wencai-form/index.tsx
+++ b/web/src/pages/agent/form/wencai-form/index.tsx
@@ -8,7 +8,7 @@ import {
FormLabel,
FormMessage,
} from '@/components/ui/form';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { zodResolver } from '@hookform/resolvers/zod';
import { memo, useMemo } from 'react';
import { useForm, useFormContext } from 'react-hook-form';
@@ -55,7 +55,7 @@ export function WenCaiFormWidgets() {
<FormItem>
<FormLabel>{t('flow.queryType')}</FormLabel>
<FormControl>
- <RAGFlowSelect {...field} options={wenCaiQueryTypeOptions} />
+ <SelectWithSearch {...field} options={wenCaiQueryTypeOptions} />
</FormControl>
<FormMessage />
</FormItem>
diff --git a/web/src/pages/agent/form/youcom-form/index.tsx b/web/src/pages/agent/form/youcom-form/index.tsx
index a9e809b42f..341dd40b7d 100644
--- a/web/src/pages/agent/form/youcom-form/index.tsx
+++ b/web/src/pages/agent/form/youcom-form/index.tsx
@@ -8,7 +8,7 @@ import {
FormLabel,
FormMessage,
} from '@/components/ui/form';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { useTranslate } from '@/hooks/common-hooks';
import { zodResolver } from '@hookform/resolvers/zod';
import { memo, useMemo } from 'react';
@@ -70,7 +70,7 @@ export function YouComWidgets() {
{t('youComFreshness')}
</FormLabel>
<FormControl>
- <RAGFlowSelect {...field} options={freshnessOptions} />
+ <SelectWithSearch {...field} options={freshnessOptions} />
</FormControl>
<FormMessage />
</FormItem>
diff --git a/web/src/pages/next-search/embed-app-modal.tsx b/web/src/pages/next-search/embed-app-modal.tsx
index 6166c2d7ff..4c517bdad0 100644
--- a/web/src/pages/next-search/embed-app-modal.tsx
+++ b/web/src/pages/next-search/embed-app-modal.tsx
@@ -17,7 +17,7 @@
import HighLightMarkdown from '@/components/highlight-markdown';
import { Button } from '@/components/ui/button';
import { Modal } from '@/components/ui/modal/modal';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { Switch } from '@/components/ui/switch';
import {
LanguageAbbreviation,
@@ -112,12 +112,12 @@ const EmbedAppModal = (props: IEmbedAppModalProps) => {
<label className="block text-sm font-medium mb-2">
{t('locale')}
</label>
- <RAGFlowSelect
+ <SelectWithSearch
placeholder={t('selectLocalePlaceholder')}
value={locale}
onChange={(value) => setLocale(value)}
options={languageOptions}
- ></RAGFlowSelect>
+ ></SelectWithSearch>
</div>
{/* Embed Code */}
<div className="mb-6">
diff --git a/web/src/pages/user-setting/chat-channel/component/connect-dialog-modal.tsx b/web/src/pages/user-setting/chat-channel/component/connect-dialog-modal.tsx
index 33937a9b07..bd0296580e 100644
--- a/web/src/pages/user-setting/chat-channel/component/connect-dialog-modal.tsx
+++ b/web/src/pages/user-setting/chat-channel/component/connect-dialog-modal.tsx
@@ -16,7 +16,7 @@
import { Button } from '@/components/ui/button';
import { Modal } from '@/components/ui/modal/modal';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { useFetchAllAgentList } from '@/hooks/use-agent-request';
import { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -101,7 +101,7 @@ const ConnectDialogModal = ({
<label className="text-sm text-text-secondary">
{t('setting.selectDialog')}
</label>
- <RAGFlowSelect
+ <SelectWithSearch
value={targetValue}
onChange={(val: string) => setTargetValue(val || undefined)}
options={options}
diff --git a/web/src/pages/user-setting/mcp/edit-mcp-form.tsx b/web/src/pages/user-setting/mcp/edit-mcp-form.tsx
index 626a1e0120..299f078868 100644
--- a/web/src/pages/user-setting/mcp/edit-mcp-form.tsx
+++ b/web/src/pages/user-setting/mcp/edit-mcp-form.tsx
@@ -28,7 +28,7 @@ import {
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
-import { RAGFlowSelect } from '@/components/ui/select';
+import { SelectWithSearch } from '@/components/originui/select-with-search';
import { IModalProps } from '@/interfaces/common';
import { buildOptions } from '@/utils/form';
import { loader } from '@monaco-editor/react';
@@ -145,9 +145,8 @@ export function EditMcpForm({
<FormItem>
<FormLabel required>{t('mcp.serverType')}</FormLabel>
<FormControl>
- <RAGFlowSelect
+ <SelectWithSearch
{...field}
- autoComplete="off"
options={ServerTypeOptions}
onChange={(value) => {
field.onChange(value);