mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
Feature: Add dot notation support for nested output variable resolution (#4506)
Add dot notation support for nested output variable resolution
This commit is contained in:
@@ -335,6 +335,30 @@ export const resolveVariables = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the variable is an output reference like `nodeId.output.path`
|
||||||
|
const outputMatch = variableFullPath.match(/^(.*?)\.output\.(.+)$/)
|
||||||
|
if (outputMatch && agentFlowExecutedData) {
|
||||||
|
// Extract nodeId and outputPath from the match
|
||||||
|
const [, nodeIdPart, outputPath] = outputMatch
|
||||||
|
// Clean nodeId (handle escaped underscores)
|
||||||
|
const cleanNodeId = nodeIdPart.replace('\\', '')
|
||||||
|
// Find the last (most recent) matching node data instead of the first one
|
||||||
|
const nodeData = [...agentFlowExecutedData].reverse().find((d) => d.nodeId === cleanNodeId)
|
||||||
|
if (nodeData?.data?.output && outputPath.trim()) {
|
||||||
|
const variableValue = get(nodeData.data.output, outputPath)
|
||||||
|
if (variableValue !== undefined) {
|
||||||
|
// Replace the reference with actual value
|
||||||
|
const formattedValue =
|
||||||
|
Array.isArray(variableValue) || (typeof variableValue === 'object' && variableValue !== null)
|
||||||
|
? JSON.stringify(variableValue)
|
||||||
|
: String(variableValue)
|
||||||
|
resolvedValue = resolvedValue.replace(match, formattedValue)
|
||||||
|
// Skip fallback logic
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Find node data in executed data
|
// Find node data in executed data
|
||||||
// sometimes turndown value returns a backslash like `llmAgentflow\_1`, remove the backslash
|
// sometimes turndown value returns a backslash like `llmAgentflow\_1`, remove the backslash
|
||||||
const cleanNodeId = variableFullPath.replace('\\', '')
|
const cleanNodeId = variableFullPath.replace('\\', '')
|
||||||
|
|||||||
Reference in New Issue
Block a user