fix state updates

This commit is contained in:
Nate 2024-11-17 16:39:30 -08:00
parent ac62fed5e8
commit e25eceacee
2 changed files with 5 additions and 3 deletions

2
core/index.d.ts vendored
View file

@ -276,7 +276,7 @@ export interface ToolCallDelta {
type?: "function";
function?: {
name?: string;
arguments?: string[];
arguments?: string;
};
}

View file

@ -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 +=