Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#5489 from ConnectAI-E/feature-fix-o…
Browse files Browse the repository at this point in the history
…penai-function-call

Feature fix openai function call
  • Loading branch information
lloydzhou authored Sep 22, 2024
2 parents 2474d5b + 3a96905 commit 23f2b62
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,10 +303,10 @@ export class ChatGPTApi implements LLMApi {
}>;
const tool_calls = choices[0]?.delta?.tool_calls;
if (tool_calls?.length > 0) {
const index = tool_calls[0]?.index;
const id = tool_calls[0]?.id;
const args = tool_calls[0]?.function?.arguments;
if (id) {
index += 1;
runTools.push({
id,
type: tool_calls[0]?.type,
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 23f2b62

Please sign in to comment.