Skip to content

Commit

Permalink
hotfix openai function call tool_calls no index
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydzhou committed Sep 22, 2024
1 parent 2474d5b commit 4d1f9e4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/client/platforms/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ export class ChatGPTApi implements LLMApi {
);
}
if (shouldStream) {
let index = -1;
const [tools, funcs] = usePluginStore
.getState()
.getAsTools(
Expand All @@ -302,7 +303,7 @@ export class ChatGPTApi implements LLMApi {
}>;
const tool_calls = choices[0]?.delta?.tool_calls;
if (tool_calls?.length > 0) {
const index = tool_calls[0]?.index;
index += 1;
const id = tool_calls[0]?.id;
const args = tool_calls[0]?.function?.arguments;
if (id) {
Expand All @@ -327,6 +328,8 @@ export class ChatGPTApi implements LLMApi {
toolCallMessage: any,
toolCallResult: any[],
) => {
// reset index value
index = -1;
// @ts-ignore
requestPayload?.messages?.splice(
// @ts-ignore
Expand Down

0 comments on commit 4d1f9e4

Please sign in to comment.