From d796fcc0e720487c37a51850c942eab74d70c05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20D=C3=ADaz?= <40875838+marcelodiaz558@users.noreply.github.com> Date: Mon, 7 Apr 2025 23:15:07 -0400 Subject: [PATCH] feat: support select-type variables in Metadata Filtering (#17440 (#17445) --- .../components/app/configuration/dataset-config/index.tsx | 2 +- .../components/metadata/condition-list/condition-item.tsx | 8 ++++++-- .../components/metadata/condition-list/utils.ts | 1 + .../components/metadata/metadata-icon.tsx | 2 +- .../workflow/nodes/knowledge-retrieval/types.ts | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/web/app/components/app/configuration/dataset-config/index.tsx b/web/app/components/app/configuration/dataset-config/index.tsx index 01ba8c606d..6165cfdeec 100644 --- a/web/app/components/app/configuration/dataset-config/index.tsx +++ b/web/app/components/app/configuration/dataset-config/index.tsx @@ -270,7 +270,7 @@ const DatasetConfig: FC = () => { handleMetadataModelChange={handleMetadataModelChange} handleMetadataCompletionParamsChange={handleMetadataCompletionParamsChange} isCommonVariable - availableCommonStringVars={promptVariablesToSelect.filter(item => item.type === MetadataFilteringVariableType.string)} + availableCommonStringVars={promptVariablesToSelect.filter(item => item.type === MetadataFilteringVariableType.string || item.type === MetadataFilteringVariableType.select)} availableCommonNumberVars={promptVariablesToSelect.filter(item => item.type === MetadataFilteringVariableType.number)} /> diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-item.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-item.tsx index 910d753532..398a2294e2 100644 --- a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-item.tsx +++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-item.tsx @@ -77,7 +77,9 @@ const ConditionItem = ({ const valueAndValueMethod = useMemo(() => { if ( - (currentMetadata?.type === MetadataFilteringVariableType.string || currentMetadata?.type === MetadataFilteringVariableType.number) + (currentMetadata?.type === MetadataFilteringVariableType.string + || currentMetadata?.type === MetadataFilteringVariableType.number + || currentMetadata?.type === MetadataFilteringVariableType.select) && typeof condition.value === 'string' ) { const regex = isCommonVariable ? COMMON_VARIABLE_REGEX : VARIABLE_REGEX @@ -140,7 +142,9 @@ const ConditionItem = ({
{ - !comparisonOperatorNotRequireValue(condition.comparison_operator) && currentMetadata?.type === MetadataFilteringVariableType.string && ( + !comparisonOperatorNotRequireValue(condition.comparison_operator) + && (currentMetadata?.type === MetadataFilteringVariableType.string + || currentMetadata?.type === MetadataFilteringVariableType.select) && ( { switch (type) { case MetadataFilteringVariableType.string: + case MetadataFilteringVariableType.select: return [ ComparisonOperator.is, ComparisonOperator.isNot, diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/metadata-icon.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/metadata-icon.tsx index 5830a1a54a..4a3f539ef4 100644 --- a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/metadata-icon.tsx +++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/metadata-icon.tsx @@ -18,7 +18,7 @@ const MetadataIcon = ({ return ( <> { - type === MetadataFilteringVariableType.string && ( + (type === MetadataFilteringVariableType.string || type === MetadataFilteringVariableType.select) && ( ) } diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/types.ts b/web/app/components/workflow/nodes/knowledge-retrieval/types.ts index 5f8b39e02b..1cae4ecd3b 100644 --- a/web/app/components/workflow/nodes/knowledge-retrieval/types.ts +++ b/web/app/components/workflow/nodes/knowledge-retrieval/types.ts @@ -80,6 +80,7 @@ export enum MetadataFilteringVariableType { string = 'string', number = 'number', time = 'time', + select = 'select', } export type MetadataFilteringCondition = {