Browse Source

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

tags/1.2.0
Marcelo Díaz 6 months ago
parent
commit
d796fcc0e7
No account linked to committer's email address

+ 1
- 1
web/app/components/app/configuration/dataset-config/index.tsx View File

handleMetadataModelChange={handleMetadataModelChange} handleMetadataModelChange={handleMetadataModelChange}
handleMetadataCompletionParamsChange={handleMetadataCompletionParamsChange} handleMetadataCompletionParamsChange={handleMetadataCompletionParamsChange}
isCommonVariable 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)} availableCommonNumberVars={promptVariablesToSelect.filter(item => item.type === MetadataFilteringVariableType.number)}
/> />
</div> </div>

+ 6
- 2
web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-item.tsx View File



const valueAndValueMethod = useMemo(() => { const valueAndValueMethod = useMemo(() => {
if ( 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' && typeof condition.value === 'string'
) { ) {
const regex = isCommonVariable ? COMMON_VARIABLE_REGEX : VARIABLE_REGEX const regex = isCommonVariable ? COMMON_VARIABLE_REGEX : VARIABLE_REGEX
</div> </div>
<div className='border-t border-t-divider-subtle'> <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 <ConditionString
valueMethod={localValueMethod} valueMethod={localValueMethod}
onValueMethodChange={handleValueMethodChange} onValueMethodChange={handleValueMethodChange}

+ 1
- 0
web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/utils.ts View File

export const getOperators = (type?: MetadataFilteringVariableType) => { export const getOperators = (type?: MetadataFilteringVariableType) => {
switch (type) { switch (type) {
case MetadataFilteringVariableType.string: case MetadataFilteringVariableType.string:
case MetadataFilteringVariableType.select:
return [ return [
ComparisonOperator.is, ComparisonOperator.is,
ComparisonOperator.isNot, ComparisonOperator.isNot,

+ 1
- 1
web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/metadata-icon.tsx View File

return ( return (
<> <>
{ {
type === MetadataFilteringVariableType.string && (
(type === MetadataFilteringVariableType.string || type === MetadataFilteringVariableType.select) && (
<RiTextSnippet className={cn('h-3.5 w-3.5', className)} /> <RiTextSnippet className={cn('h-3.5 w-3.5', className)} />
) )
} }

+ 1
- 0
web/app/components/workflow/nodes/knowledge-retrieval/types.ts View File

string = 'string', string = 'string',
number = 'number', number = 'number',
time = 'time', time = 'time',
select = 'select',
} }


export type MetadataFilteringCondition = { export type MetadataFilteringCondition = {

Loading…
Cancel
Save