From 2a0e712b7d895694bf724d85defaa7776df6338f Mon Sep 17 00:00:00 2001 From: inkyu <87048860+grapestore@users.noreply.github.com> Date: Tue, 4 Feb 2025 02:12:09 +0900 Subject: [PATCH] feat: preserve UI state memory on API override (#3957) --- .../components/nodes/sequentialagents/State/State.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/components/nodes/sequentialagents/State/State.ts b/packages/components/nodes/sequentialagents/State/State.ts index 31d7af0c0..5c48cb7a7 100644 --- a/packages/components/nodes/sequentialagents/State/State.ts +++ b/packages/components/nodes/sequentialagents/State/State.ts @@ -107,13 +107,15 @@ class State_SeqAgents implements INode { if (stateMemory && stateMemory !== 'stateMemoryUI' && stateMemory !== 'stateMemoryCode') { try { + const parsedSchemaFromUI = typeof stateMemoryUI === 'string' ? JSON.parse(stateMemoryUI) : stateMemoryUI const parsedSchema = typeof stateMemory === 'string' ? JSON.parse(stateMemory) : stateMemory + const combinedMemorySchema = [...parsedSchemaFromUI, ...parsedSchema] const obj: ICommonObject = {} - for (const sch of parsedSchema) { - const key = sch.Key + for (const sch of combinedMemorySchema) { + const key = sch.Key ?? sch.key if (!key) throw new Error(`Key is required`) - const type = sch.Operation - const defaultValue = sch['Default Value'] + const type = sch.Operation ?? sch.type + const defaultValue = sch['Default Value'] ?? sch.defaultValue if (type === 'Append') { obj[key] = {