mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 17:08:03 +08:00
feat: Enhance context variable handling for Agent and LLM nodes
This commit is contained in:
@ -67,7 +67,8 @@ const WorkflowVariableBlockComponent = ({
|
||||
)()
|
||||
const [localWorkflowNodesMap, setLocalWorkflowNodesMap] = useState<WorkflowNodesMap>(workflowNodesMap)
|
||||
const node = localWorkflowNodesMap![variables[isRagVar ? 1 : 0]]
|
||||
const isAgentContextVariable = node?.type === BlockEnum.Agent && variables[variablesLength - 1] === 'context'
|
||||
const isContextVariable = (node?.type === BlockEnum.Agent || node?.type === BlockEnum.LLM)
|
||||
&& variables[variablesLength - 1] === 'context'
|
||||
|
||||
const isException = isExceptionVariable(varName, node?.type)
|
||||
const variableValid = useMemo(() => {
|
||||
@ -136,7 +137,7 @@ const WorkflowVariableBlockComponent = ({
|
||||
})
|
||||
}, [node, reactflow, store])
|
||||
|
||||
if (isAgentContextVariable)
|
||||
if (isContextVariable)
|
||||
return <span className="hidden" ref={ref} />
|
||||
|
||||
const Item = (
|
||||
|
||||
@ -123,8 +123,9 @@ export class WorkflowVariableBlockNode extends DecoratorNode<React.JSX.Element>
|
||||
getTextContent(): string {
|
||||
const variables = this.getVariables()
|
||||
const node = this.getWorkflowNodesMap()?.[variables[0]]
|
||||
const isAgentContextVariable = node?.type === BlockEnum.Agent && variables[variables.length - 1] === 'context'
|
||||
const marker = isAgentContextVariable ? '@' : '#'
|
||||
const isContextVariable = (node?.type === BlockEnum.Agent || node?.type === BlockEnum.LLM)
|
||||
&& variables[variables.length - 1] === 'context'
|
||||
const marker = isContextVariable ? '@' : '#'
|
||||
return `{{${marker}${variables.join('.')}${marker}}}`
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user