Skip to content

Commit 232c84d

Browse files
feat: support select-type variables in Metadata Filtering (langgenius#17440)
1 parent 296e2ef commit 232c84d

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

web/app/components/app/configuration/dataset-config/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ const DatasetConfig: FC = () => {
270270
handleMetadataModelChange={handleMetadataModelChange}
271271
handleMetadataCompletionParamsChange={handleMetadataCompletionParamsChange}
272272
isCommonVariable
273-
availableCommonStringVars={promptVariablesToSelect.filter(item => item.type === MetadataFilteringVariableType.string)}
273+
availableCommonStringVars={promptVariablesToSelect.filter(item => item.type === MetadataFilteringVariableType.string || item.type === MetadataFilteringVariableType.select)}
274274
availableCommonNumberVars={promptVariablesToSelect.filter(item => item.type === MetadataFilteringVariableType.number)}
275275
/>
276276
</div>

web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-item.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ const ConditionItem = ({
7777

7878
const valueAndValueMethod = useMemo(() => {
7979
if (
80-
(currentMetadata?.type === MetadataFilteringVariableType.string || currentMetadata?.type === MetadataFilteringVariableType.number)
80+
(currentMetadata?.type === MetadataFilteringVariableType.string ||
81+
currentMetadata?.type === MetadataFilteringVariableType.number ||
82+
currentMetadata?.type === MetadataFilteringVariableType.select)
8183
&& typeof condition.value === 'string'
8284
) {
8385
const regex = isCommonVariable ? COMMON_VARIABLE_REGEX : VARIABLE_REGEX
@@ -140,7 +142,9 @@ const ConditionItem = ({
140142
</div>
141143
<div className='border-t border-t-divider-subtle'>
142144
{
143-
!comparisonOperatorNotRequireValue(condition.comparison_operator) && currentMetadata?.type === MetadataFilteringVariableType.string && (
145+
!comparisonOperatorNotRequireValue(condition.comparison_operator) &&
146+
(currentMetadata?.type === MetadataFilteringVariableType.string ||
147+
currentMetadata?.type === MetadataFilteringVariableType.select) && (
144148
<ConditionString
145149
valueMethod={localValueMethod}
146150
onValueMethodChange={handleValueMethodChange}

web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const isComparisonOperatorNeedTranslate = (operator?: ComparisonOperator)
2222
export const getOperators = (type?: MetadataFilteringVariableType) => {
2323
switch (type) {
2424
case MetadataFilteringVariableType.string:
25+
case MetadataFilteringVariableType.select:
2526
return [
2627
ComparisonOperator.is,
2728
ComparisonOperator.isNot,

web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/metadata-icon.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const MetadataIcon = ({
1818
return (
1919
<>
2020
{
21-
type === MetadataFilteringVariableType.string && (
21+
(type === MetadataFilteringVariableType.string || type === MetadataFilteringVariableType.select) && (
2222
<RiTextSnippet className={cn('h-3.5 w-3.5', className)} />
2323
)
2424
}

web/app/components/workflow/nodes/knowledge-retrieval/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export enum MetadataFilteringVariableType {
8080
string = 'string',
8181
number = 'number',
8282
time = 'time',
83+
select = 'select',
8384
}
8485

8586
export type MetadataFilteringCondition = {

0 commit comments

Comments
 (0)