| 526 | 526 | for (let choiceIndex = 0; choiceIndex < parsed.candidates.length; choiceIndex++) { |
| 527 | 527 | const candidate = parsed.candidates[choiceIndex]; |
| 528 | 528 | if (Array.isArray(candidate?.content?.parts)) { |
| 529 | 529 | for (let toolCallIndexpartIndex = 0; toolCallIndexpartIndex < candidate.content.parts.length; toolCallIndexpartIndex++) { |
| 530 | 530 | const part = candidate.content.parts[toolCallIndexpartIndex]; |
| 531 | 531 | if (part.functionCall) { |
| 532 | 532 | if (!Array.isArray(toolCalls[choiceIndex])) { |
| 533 | 533 | toolCalls[choiceIndex] = []; |
| 534 | 534 | } |
| 535 | + const toolCallIndex = toolCalls[choiceIndex].length; |
| 535 | 536 | if (toolCalls[choiceIndex][toolCallIndex] === undefined) { |
| 536 | 537 | toolCalls[choiceIndex][toolCallIndex] = {}; |
| 537 | 538 | } |