Gemini: Fix parsing multiple tool calls in one response Fixes #4537

3246d2960c26a18985000b6ae88ece0f78650aa9

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +3 -2Showing whitespace changes
public/scripts/tool-calling.js+3 -2
@@ -526,12 +526,13 @@ export class ToolManager {
526526 for (let choiceIndex = 0; choiceIndex < parsed.candidates.length; choiceIndex++) {
527527 const candidate = parsed.candidates[choiceIndex];
528528 if (Array.isArray(candidate?.content?.parts)) {
529529 for (let toolCallIndexpartIndex = 0; toolCallIndexpartIndex < candidate.content.parts.length; toolCallIndexpartIndex++) {
530530 const part = candidate.content.parts[toolCallIndexpartIndex];
531531 if (part.functionCall) {
532532 if (!Array.isArray(toolCalls[choiceIndex])) {
533533 toolCalls[choiceIndex] = [];
534534 }
535+ const toolCallIndex = toolCalls[choiceIndex].length;
535536 if (toolCalls[choiceIndex][toolCallIndex] === undefined) {
536537 toolCalls[choiceIndex][toolCallIndex] = {};
537538 }