Commit d87771a1 by Archer Committed by GitHub

fix: toolcall index not start zero (#5811)

parent 68271c08
...@@ -57,7 +57,7 @@ type LLMResponse = { ...@@ -57,7 +57,7 @@ type LLMResponse = {
completeMessages: ChatCompletionMessageParam[]; completeMessages: ChatCompletionMessageParam[];
}; };
/* /*
底层封装 LLM 调用 帮助上层屏蔽 stream 和非 stream,以及 toolChoice 和 promptTool 模式。 底层封装 LLM 调用 帮助上层屏蔽 stream 和非 stream,以及 toolChoice 和 promptTool 模式。
工具调用无论哪种模式,都存 toolChoice 的格式,promptTool 通过修改 toolChoice 的结构,形成特定的 messages 进行调用。 工具调用无论哪种模式,都存 toolChoice 的格式,promptTool 通过修改 toolChoice 的结构,形成特定的 messages 进行调用。
*/ */
...@@ -243,7 +243,7 @@ export const createStreamResponse = async ({ ...@@ -243,7 +243,7 @@ export const createStreamResponse = async ({
type: 'function', type: 'function',
function: callingTool! function: callingTool!
}; };
toolCalls.push(call); toolCalls[index] = call;
onToolCall?.({ call }); onToolCall?.({ call });
callingTool = null; callingTool = null;
} }
...@@ -268,7 +268,7 @@ export const createStreamResponse = async ({ ...@@ -268,7 +268,7 @@ export const createStreamResponse = async ({
reasoningText: reasoningContent, reasoningText: reasoningContent,
finish_reason, finish_reason,
usage, usage,
toolCalls toolCalls: toolCalls.filter((call) => !!call)
}; };
} else { } else {
let startResponseWrite = false; let startResponseWrite = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment