mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-01 22:14:03 -04:00
fix: first tool call chunk without arguments (#2234)
Co-authored-by: Marcus Schiesser <marcus.schiesser@googlemail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@llamaindex/openai": patch
|
||||
---
|
||||
|
||||
fix: first tool call chunk without arguments
|
||||
@@ -415,12 +415,16 @@ export class OpenAI extends ToolCallLLM<OpenAIAdditionalChatOptions> {
|
||||
toolCallMap.set(choice.delta.tool_calls[0].id, currentToolCall);
|
||||
} else {
|
||||
if (choice.delta.tool_calls?.[0]!.function?.arguments) {
|
||||
if (typeof currentToolCall!.input !== "string") {
|
||||
currentToolCall!.input = "";
|
||||
}
|
||||
currentToolCall!.input +=
|
||||
choice.delta.tool_calls[0].function.arguments;
|
||||
}
|
||||
}
|
||||
|
||||
const isDone: boolean = choice.finish_reason !== null;
|
||||
const isDone: boolean =
|
||||
choice.finish_reason !== null && choice.finish_reason !== undefined;
|
||||
|
||||
if (isDone && currentToolCall) {
|
||||
// for the last one, we need to emit the tool call
|
||||
|
||||
Reference in New Issue
Block a user