fix undefined on tool_calls
This commit is contained in:
@@ -4,6 +4,7 @@ import { createRef } from "preact";
|
|||||||
import { StateUpdater, useEffect, useState } from "preact/hooks";
|
import { StateUpdater, useEffect, useState } from "preact/hooks";
|
||||||
import {
|
import {
|
||||||
ChatStore,
|
ChatStore,
|
||||||
|
ChatStoreMessage,
|
||||||
STORAGE_NAME_TEMPLATE,
|
STORAGE_NAME_TEMPLATE,
|
||||||
STORAGE_NAME_TEMPLATE_API,
|
STORAGE_NAME_TEMPLATE_API,
|
||||||
TemplateAPI,
|
TemplateAPI,
|
||||||
@@ -137,14 +138,16 @@ export default function ChatBOX(props: {
|
|||||||
chatStore.cost += cost;
|
chatStore.cost += cost;
|
||||||
addTotalCost(cost);
|
addTotalCost(cost);
|
||||||
|
|
||||||
chatStore.history.push({
|
const newMsg: ChatStoreMessage = {
|
||||||
role: "assistant",
|
role: "assistant",
|
||||||
content,
|
content,
|
||||||
tool_calls: allChunkTool,
|
|
||||||
hide: false,
|
hide: false,
|
||||||
token: responseTokenCount,
|
token: responseTokenCount,
|
||||||
example: false,
|
example: false,
|
||||||
});
|
};
|
||||||
|
if (allChunkTool.length > 0) newMsg.tool_calls = allChunkTool;
|
||||||
|
|
||||||
|
chatStore.history.push(newMsg);
|
||||||
// manually copy status from client to chatStore
|
// manually copy status from client to chatStore
|
||||||
chatStore.maxTokens = client.max_tokens;
|
chatStore.maxTokens = client.max_tokens;
|
||||||
chatStore.tokenMargin = client.tokens_margin;
|
chatStore.tokenMargin = client.tokens_margin;
|
||||||
|
|||||||
Reference in New Issue
Block a user