feat: preserve UI state memory on API override (#3957)
This commit is contained in:
parent
e1ea1c68d1
commit
2a0e712b7d
|
|
@ -107,13 +107,15 @@ class State_SeqAgents implements INode {
|
||||||
|
|
||||||
if (stateMemory && stateMemory !== 'stateMemoryUI' && stateMemory !== 'stateMemoryCode') {
|
if (stateMemory && stateMemory !== 'stateMemoryUI' && stateMemory !== 'stateMemoryCode') {
|
||||||
try {
|
try {
|
||||||
|
const parsedSchemaFromUI = typeof stateMemoryUI === 'string' ? JSON.parse(stateMemoryUI) : stateMemoryUI
|
||||||
const parsedSchema = typeof stateMemory === 'string' ? JSON.parse(stateMemory) : stateMemory
|
const parsedSchema = typeof stateMemory === 'string' ? JSON.parse(stateMemory) : stateMemory
|
||||||
|
const combinedMemorySchema = [...parsedSchemaFromUI, ...parsedSchema]
|
||||||
const obj: ICommonObject = {}
|
const obj: ICommonObject = {}
|
||||||
for (const sch of parsedSchema) {
|
for (const sch of combinedMemorySchema) {
|
||||||
const key = sch.Key
|
const key = sch.Key ?? sch.key
|
||||||
if (!key) throw new Error(`Key is required`)
|
if (!key) throw new Error(`Key is required`)
|
||||||
const type = sch.Operation
|
const type = sch.Operation ?? sch.type
|
||||||
const defaultValue = sch['Default Value']
|
const defaultValue = sch['Default Value'] ?? sch.defaultValue
|
||||||
|
|
||||||
if (type === 'Append') {
|
if (type === 'Append') {
|
||||||
obj[key] = {
|
obj[key] = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue