diff --git a/web/app/components/workflow/nodes/_base/components/form-input-item.tsx b/web/app/components/workflow/nodes/_base/components/form-input-item.tsx index caafd34e97..99789d8afe 100644 --- a/web/app/components/workflow/nodes/_base/components/form-input-item.tsx +++ b/web/app/components/workflow/nodes/_base/components/form-input-item.tsx @@ -233,12 +233,12 @@ const FormInputItem: FC = ({ } } - const handleValueChange = (newValue: any) => { + const handleValueChange = (newValue: any, newType?: VarKindType) => { onChange({ ...value, [variable]: { ...varInput, - type: getVarKindType(), + type: newType ?? getVarKindType(), value: isNumber ? Number.parseFloat(newValue) : newValue, }, }) diff --git a/web/app/components/workflow/nodes/_base/types.ts b/web/app/components/workflow/nodes/_base/types.ts index 18ad9c4e71..8f15c89881 100644 --- a/web/app/components/workflow/nodes/_base/types.ts +++ b/web/app/components/workflow/nodes/_base/types.ts @@ -5,6 +5,7 @@ export enum VarKindType { variable = 'variable', constant = 'constant', mixed = 'mixed', + mention = 'mention', } // Generic resource variable inputs diff --git a/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx b/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx index 238b20bdc1..d0beeabb0c 100644 --- a/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx +++ b/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx @@ -1,4 +1,5 @@ import type { AgentNode } from '@/app/components/base/prompt-editor/types' +import type { VarKindType } from '@/app/components/workflow/nodes/_base/types' import type { Node, NodeOutPutVar, @@ -12,6 +13,7 @@ import { } from 'react' import { useTranslation } from 'react-i18next' import PromptEditor from '@/app/components/base/prompt-editor' +import { VarKindType as VarKindTypeEnum } from '@/app/components/workflow/nodes/_base/types' import { useStore } from '@/app/components/workflow/store' import { BlockEnum } from '@/app/components/workflow/types' import { cn } from '@/utils/classnames' @@ -30,7 +32,7 @@ type MixedVariableTextInputProps = { nodesOutputVars?: NodeOutPutVar[] availableNodes?: Node[] value?: string - onChange?: (text: string) => void + onChange?: (text: string, type?: VarKindType) => void showManageInputField?: boolean onManageInputField?: () => void disableVariableInsertion?: boolean @@ -105,7 +107,7 @@ const MixedVariableTextInput = ({ return nodeId === agentNodeId ? '' : match }).trim() - onChange(valueWithoutAgentVars) + onChange(valueWithoutAgentVars, VarKindTypeEnum.mixed) setControlPromptEditorRerenderKey(Date.now()) }, [detectedAgentFromValue?.nodeId, value, onChange, setControlPromptEditorRerenderKey]) @@ -116,7 +118,7 @@ const MixedVariableTextInput = ({ const valueWithoutTrigger = value.replace(/@$/, '') const newValue = `{{#${agent.id}.context#}}${valueWithoutTrigger}` - onChange(newValue) + onChange(newValue, VarKindTypeEnum.mention) setControlPromptEditorRerenderKey(Date.now()) }, [value, onChange, setControlPromptEditorRerenderKey])