File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
packages/providers/openai/src Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @llamaindex/openai " : patch
3+ ---
4+
5+ fix: first tool call chunk without arguments
Original file line number Diff line number Diff line change @@ -415,12 +415,16 @@ export class OpenAI extends ToolCallLLM<OpenAIAdditionalChatOptions> {
415415 toolCallMap . set ( choice . delta . tool_calls [ 0 ] . id , currentToolCall ) ;
416416 } else {
417417 if ( choice . delta . tool_calls ?. [ 0 ] ! . function ?. arguments ) {
418+ if ( typeof currentToolCall ! . input !== "string" ) {
419+ currentToolCall ! . input = "" ;
420+ }
418421 currentToolCall ! . input +=
419422 choice . delta . tool_calls [ 0 ] . function . arguments ;
420423 }
421424 }
422425
423- const isDone : boolean = choice . finish_reason !== null ;
426+ const isDone : boolean =
427+ choice . finish_reason !== null && choice . finish_reason !== undefined ;
424428
425429 if ( isDone && currentToolCall ) {
426430 // for the last one, we need to emit the tool call
You can’t perform that action at this time.
0 commit comments