diff --git a/web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx b/web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx index 06b583543a..de2d675b89 100644 --- a/web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx +++ b/web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx @@ -63,7 +63,8 @@ const WorkflowVariableBlockComponent = ({ const [localWorkflowNodesMap, setLocalWorkflowNodesMap] = useState(workflowNodesMap) const node = localWorkflowNodesMap![variables[0]] const isEnv = isENV(variables) - const isChatVar = isConversationVar(variables) + const isChatVar = isConversationVar(variables) && conversationVariables?.some(v => v.variable === `${variables?.[0] ?? ''}.${variables?.[1] ?? ''}` && v.type !== 'memory') + const isMemoryVar = isConversationVar(variables) && conversationVariables?.some(v => v.variable === `${variables?.[0] ?? ''}.${variables?.[1] ?? ''}` && v.type === 'memory') const isException = isExceptionVariable(varName, node?.type) let variableValid = true @@ -129,6 +130,7 @@ const WorkflowVariableBlockComponent = ({ handleVariableJump() }} isExceptionVariable={isException} + isMemoryVariable={isMemoryVar} errorMsg={!variableValid ? t('workflow.errorMsg.invalidVariable') : undefined} isSelected={isSelected} ref={ref} diff --git a/web/app/components/workflow/nodes/_base/components/variable/variable-label/base/variable-icon.tsx b/web/app/components/workflow/nodes/_base/components/variable/variable-label/base/variable-icon.tsx index 93f47f794a..aa78eae341 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/variable-label/base/variable-icon.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/variable-label/base/variable-icon.tsx @@ -7,13 +7,15 @@ export type VariableIconProps = { className?: string variables?: string[] variableCategory?: VarInInspectType | string + isMemoryVariable?: boolean } const VariableIcon = ({ className, variables = [], variableCategory, + isMemoryVariable, }: VariableIconProps) => { - const VarIcon = useVarIcon(variables, variableCategory) + const VarIcon = useVarIcon(variables, variableCategory, isMemoryVariable) return VarIcon && ( { +export const useVarIcon = (variables: string[], variableCategory?: VarInInspectType | string, isMemoryVariable?: boolean) => { if (variableCategory === 'loop') return Loop if (isENV(variables) || variableCategory === VarInInspectType.environment || variableCategory === 'environment') return Env + if (isMemoryVariable) + return Memory + if (isConversationVar(variables) || variableCategory === VarInInspectType.conversation || variableCategory === 'conversation') return BubbleX diff --git a/web/app/components/workflow/nodes/_base/components/variable/variable-label/types.ts b/web/app/components/workflow/nodes/_base/components/variable/variable-label/types.ts index 6f3b06f6ee..6dcd7508f5 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/variable-label/types.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/variable-label/types.ts @@ -13,6 +13,7 @@ export type VariablePayload = { onClick?: (e: React.MouseEvent) => void errorMsg?: string isExceptionVariable?: boolean + isMemoryVariable?: boolean ref?: React.Ref notShowFullPath?: boolean rightSlot?: ReactNode diff --git a/web/app/components/workflow/types.ts b/web/app/components/workflow/types.ts index 1a267787b2..2716696fd6 100644 --- a/web/app/components/workflow/types.ts +++ b/web/app/components/workflow/types.ts @@ -288,6 +288,7 @@ export enum VarType { arrayFile = 'array[file]', any = 'any', arrayAny = 'array[any]', + memory = 'memory', } export enum ValueType {