| 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> |
| 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} |
| 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, |
| 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)} /> | ||||
| ) | ) | ||||
| } | } |
| string = 'string', | string = 'string', | ||||
| number = 'number', | number = 'number', | ||||
| time = 'time', | time = 'time', | ||||
| select = 'select', | |||||
| } | } | ||||
| export type MetadataFilteringCondition = { | export type MetadataFilteringCondition = { |