File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -342,23 +342,26 @@ func (cs *openAIChatSession) SendStreaming(ctx context.Context, contents ...any)
342
342
}
343
343
344
344
// Handle tool call completion
345
+ var toolCallsForThisChunk []openai.ChatCompletionMessageToolCall
345
346
if tool , ok := acc .JustFinishedToolCall (); ok {
346
347
klog .V (2 ).Infof ("Tool call finished: %s %s" , tool .Name , tool .Arguments )
347
- currentToolCalls = append ( currentToolCalls , openai.ChatCompletionMessageToolCall {
348
+ newToolCall := openai.ChatCompletionMessageToolCall {
348
349
ID : tool .ID ,
349
350
Function : openai.ChatCompletionMessageToolCallFunction {
350
351
Name : tool .Name ,
351
352
Arguments : tool .Arguments ,
352
353
},
353
- })
354
+ }
355
+ currentToolCalls = append (currentToolCalls , newToolCall )
356
+ // Only include the newly finished tool call in this chunk
357
+ toolCallsForThisChunk = []openai.ChatCompletionMessageToolCall {newToolCall }
354
358
}
355
359
356
- // Create a streaming response with proper nil checks
357
360
streamResponse := & openAIChatStreamResponse {
358
361
streamChunk : chunk ,
359
362
accumulator : acc ,
360
363
content : "" , // Default to empty content
361
- toolCalls : currentToolCalls ,
364
+ toolCalls : toolCallsForThisChunk ,
362
365
}
363
366
364
367
// Only process content if there are choices and a delta
You can’t perform that action at this time.
0 commit comments