diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts index 1c26ef360f..a899c22161 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -56,6 +56,10 @@ export const isRagVariableVar = (valueSelector: ValueSelector) => { return valueSelector[0] === 'rag' } +export const isSpecialVar = (prefix: string): boolean => { + return ['sys', 'env', 'conversation', 'rag'].includes(prefix) +} + const inputVarTypeToVarType = (type: InputVarType): VarType => { return ({ [InputVarType.number]: VarType.number, @@ -527,7 +531,7 @@ const formatItem = ( const isCurrentMatched = filterVar(v, (() => { const variableArr = v.variable.split('.') const [first] = variableArr - if (first === 'sys' || first === 'env' || first === 'conversation' || first === 'rag') + if (isSpecialVar(first)) return variableArr return [...selector, ...variableArr] diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx index c006ebe52f..7ca334bb05 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx @@ -18,7 +18,7 @@ import { checkKeys } from '@/utils/var' import type { StructuredOutput } from '../../../llm/types' import { Type } from '../../../llm/types' import PickerStructurePanel from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/picker' -import { varTypeToStructType } from './utils' +import { isSpecialVar, varTypeToStructType } from './utils' import type { Field } from '@/app/components/workflow/nodes/llm/types' import { FILE_STRUCT } from '@/app/components/workflow/constants' import { Loop } from '@/app/components/base/icons/src/vender/workflow' @@ -286,7 +286,7 @@ const VarReferenceVars: FC = ({ } const filteredVars = vars.filter((v) => { - const children = v.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.') || v.variable.startsWith('env.') || v.variable.startsWith('conversation.') || v.variable.startsWith('rag.')) + const children = v.vars.filter(v => checkKeys([v.variable], false).isValid || isSpecialVar(v.variable.split('.')[0])) return children.length > 0 }).filter((node) => { if (!searchText) @@ -297,7 +297,7 @@ const VarReferenceVars: FC = ({ }) return children.length > 0 }).map((node) => { - let vars = node.vars.filter(v => checkKeys([v.variable], false).isValid || v.variable.startsWith('sys.') || v.variable.startsWith('env.') || v.variable.startsWith('conversation.') || v.variable.startsWith('rag.')) + let vars = node.vars.filter(v => checkKeys([v.variable], false).isValid || isSpecialVar(v.variable.split('.')[0])) if (searchText) { const searchTextLower = searchText.toLowerCase() if (!node.title.toLowerCase().includes(searchTextLower))