From e25eceaceeca149055b35d87ae46aa5f1ca62315 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 17 Nov 2024 16:39:30 -0800 Subject: [PATCH] fix state updates --- core/index.d.ts | 2 +- gui/src/redux/slices/stateSlice.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/index.d.ts b/core/index.d.ts index 76e68702c..8c3f44f5e 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -276,7 +276,7 @@ export interface ToolCallDelta { type?: "function"; function?: { name?: string; - arguments?: string[]; + arguments?: string; }; } diff --git a/gui/src/redux/slices/stateSlice.ts b/gui/src/redux/slices/stateSlice.ts index c2d314008..db6dbf859 100644 --- a/gui/src/redux/slices/stateSlice.ts +++ b/gui/src/redux/slices/stateSlice.ts @@ -273,14 +273,16 @@ export const stateSlice = createSlice({ message: { id: "NONE", ...action.payload }, }); } else { - console.log("ABC: ", action.payload); // Add to the existing message const msg = state.history[state.history.length - 1].message; if (action.payload.content) { msg.content += stripImages(action.payload.content); } else if (action.payload.toolCalls) { + if (!msg.toolCalls) { + msg.toolCalls = []; + } action.payload.toolCalls.forEach((toolCall, i) => { - if (msg.toolCalls.length < i) { + if (msg.toolCalls.length <= i) { msg.toolCalls.push(toolCall); } else { msg.toolCalls[i].function.arguments +=