mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-22 09:01:09 +03:00
Feat/add ability to specify initial state in overrideConfig (#2893)
add ability to specify initial state in overrideConfig
This commit is contained in:
@@ -557,6 +557,7 @@ const getReturnOutput = async (nodeData: INodeData, input: string, options: ICom
|
||||
const tabIdentifier = nodeData.inputs?.[`${TAB_IDENTIFIER}_${nodeData.id}`] as string
|
||||
const updateStateMemoryUI = nodeData.inputs?.updateStateMemoryUI as string
|
||||
const updateStateMemoryCode = nodeData.inputs?.updateStateMemoryCode as string
|
||||
const updateStateMemory = nodeData.inputs?.updateStateMemory as string
|
||||
|
||||
const selectedTab = tabIdentifier ? tabIdentifier.split(`_${nodeData.id}`)[0] : 'updateStateMemoryUI'
|
||||
const variables = await getVars(appDataSource, databaseEntities, nodeData)
|
||||
@@ -571,6 +572,27 @@ const getReturnOutput = async (nodeData: INodeData, input: string, options: ICom
|
||||
vars: prepareSandboxVars(variables)
|
||||
}
|
||||
|
||||
if (updateStateMemory && updateStateMemory !== 'updateStateMemoryUI' && updateStateMemory !== 'updateStateMemoryCode') {
|
||||
try {
|
||||
const parsedSchema = typeof updateStateMemory === 'string' ? JSON.parse(updateStateMemory) : updateStateMemory
|
||||
const obj: ICommonObject = {}
|
||||
for (const sch of parsedSchema) {
|
||||
const key = sch.Key
|
||||
if (!key) throw new Error(`Key is required`)
|
||||
let value = sch.Value as string
|
||||
if (value.startsWith('$flow')) {
|
||||
value = customGet(flow, sch.Value.replace('$flow.', ''))
|
||||
} else if (value.startsWith('$vars')) {
|
||||
value = customGet(flow, sch.Value.replace('$', ''))
|
||||
}
|
||||
obj[key] = value
|
||||
}
|
||||
return obj
|
||||
} catch (e) {
|
||||
throw new Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedTab === 'updateStateMemoryUI' && updateStateMemoryUI) {
|
||||
try {
|
||||
const parsedSchema = typeof updateStateMemoryUI === 'string' ? JSON.parse(updateStateMemoryUI) : updateStateMemoryUI
|
||||
|
||||
Reference in New Issue
Block a user