Feature/Allow overrideconfig from executeflow node to take in variables (#4947)

* allow overrideconfig from executeflow node to take in variables

* update array object schema
This commit is contained in:
Henry Heng 2025-07-25 13:37:33 +01:00 committed by GitHub
parent caffad0fb0
commit 221ac9b25d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 16 deletions

View File

@ -30,7 +30,7 @@ class ExecuteFlow_Agentflow implements INode {
constructor() { constructor() {
this.label = 'Execute Flow' this.label = 'Execute Flow'
this.name = 'executeFlowAgentflow' this.name = 'executeFlowAgentflow'
this.version = 1.0 this.version = 1.1
this.type = 'ExecuteFlow' this.type = 'ExecuteFlow'
this.category = 'Agent Flows' this.category = 'Agent Flows'
this.description = 'Execute another flow' this.description = 'Execute another flow'
@ -62,7 +62,8 @@ class ExecuteFlow_Agentflow implements INode {
name: 'executeFlowOverrideConfig', name: 'executeFlowOverrideConfig',
description: 'Override the config passed to the flow', description: 'Override the config passed to the flow',
type: 'json', type: 'json',
optional: true optional: true,
acceptVariable: true
}, },
{ {
label: 'Base URL', label: 'Base URL',
@ -162,12 +163,17 @@ class ExecuteFlow_Agentflow implements INode {
const flowInput = nodeData.inputs?.executeFlowInput as string const flowInput = nodeData.inputs?.executeFlowInput as string
const returnResponseAs = nodeData.inputs?.executeFlowReturnResponseAs as string const returnResponseAs = nodeData.inputs?.executeFlowReturnResponseAs as string
const _executeFlowUpdateState = nodeData.inputs?.executeFlowUpdateState const _executeFlowUpdateState = nodeData.inputs?.executeFlowUpdateState
const overrideConfig =
typeof nodeData.inputs?.executeFlowOverrideConfig === 'string' && let overrideConfig = nodeData.inputs?.executeFlowOverrideConfig
nodeData.inputs.executeFlowOverrideConfig.startsWith('{') && if (typeof overrideConfig === 'string' && overrideConfig.startsWith('{') && overrideConfig.endsWith('}')) {
nodeData.inputs.executeFlowOverrideConfig.endsWith('}') try {
? JSON.parse(nodeData.inputs.executeFlowOverrideConfig) // Handle escaped square brackets and other common escape sequences
: nodeData.inputs?.executeFlowOverrideConfig const unescapedConfig = overrideConfig.replace(/\\(\[|\])/g, '$1')
overrideConfig = JSON.parse(unescapedConfig)
} catch (parseError) {
throw new Error(`Invalid JSON in executeFlowOverrideConfig: ${parseError.message}`)
}
}
const state = options.agentflowRuntime?.state as ICommonObject const state = options.agentflowRuntime?.state as ICommonObject
const runtimeChatHistory = (options.agentflowRuntime?.chatHistory as BaseMessageLike[]) ?? [] const runtimeChatHistory = (options.agentflowRuntime?.chatHistory as BaseMessageLike[]) ?? []

View File

@ -1378,11 +1378,10 @@ export const findAvailableConfigs = (reactFlowNodes: IReactFlowNode[], component
} }
continue continue
} else if (inputParam.type === 'array') { } else if (inputParam.type === 'array') {
// get array item schema
const arrayItem = inputParam.array const arrayItem = inputParam.array
if (Array.isArray(arrayItem)) { if (Array.isArray(arrayItem)) {
const arraySchema = [] const arrayItemSchema: Record<string, string> = {}
// Each array item is a field definition // Build object schema representing the structure of each array item
for (const item of arrayItem) { for (const item of arrayItem) {
let itemType = item.type let itemType = item.type
if (itemType === 'options') { if (itemType === 'options') {
@ -1391,10 +1390,7 @@ export const findAvailableConfigs = (reactFlowNodes: IReactFlowNode[], component
} else if (itemType === 'file') { } else if (itemType === 'file') {
itemType = item.fileType ?? item.type itemType = item.fileType ?? item.type
} }
arraySchema.push({ arrayItemSchema[item.name] = itemType
name: item.name,
type: itemType
})
} }
obj = { obj = {
node: flowNode.data.label, node: flowNode.data.label,
@ -1402,7 +1398,7 @@ export const findAvailableConfigs = (reactFlowNodes: IReactFlowNode[], component
label: inputParam.label, label: inputParam.label,
name: inputParam.name, name: inputParam.name,
type: inputParam.type, type: inputParam.type,
schema: arraySchema schema: arrayItemSchema
} }
} }
} else if (inputParam.loadConfig) { } else if (inputParam.loadConfig) {