Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat: support select-type variables in Metadata Filtering (#17440 (#17445)

Marcelo Díazd796fcc0e720
diff --git a/web/app/components/app/configuration/dataset-config/index.tsx b/web/app/components/app/configuration/dataset-config/index.tsx
index 01ba8c606dd..6165cfdeecd 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)}
/>
</div>
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 910d7535329..398a2294e2b 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 = ({
</div>
<div className='border-t border-t-divider-subtle'>
{
- !comparisonOperatorNotRequireValue(condition.comparison_operator) && currentMetadata?.type === MetadataFilteringVariableType.string && (
+ !comparisonOperatorNotRequireValue(condition.comparison_operator)
+ && (currentMetadata?.type === MetadataFilteringVariableType.string
+ || currentMetadata?.type === MetadataFilteringVariableType.select) && (
<ConditionString
valueMethod={localValueMethod}
onValueMethodChange={handleValueMethodChange}
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/utils.ts b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/utils.ts
index fc6ae36b9ef..0e7fbeb29c2 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/utils.ts
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/utils.ts
@@ -22,6 +22,7 @@ export const isComparisonOperatorNeedTranslate = (operator?: ComparisonOperator)
export const getOperators = (type?: MetadataFilteringVariableType) => {
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 5830a1a54a9..4a3f539ef44 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) && (
<RiTextSnippet className={cn('h-3.5 w-3.5', className)} />
)
}
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/types.ts b/web/app/components/workflow/nodes/knowledge-retrieval/types.ts
index 5f8b39e02bf..1cae4ecd3ba 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 = {