branch: elpa/gptel
commit df6a069e137f3094f5b63264e5cb983b1685d39a
Author: Karthik Chikmagalur <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>
gptel-openai: Handle :null tool names in streaming tool calls
* gptel-openai.el (gptel-curl--parse-stream): Some
OpenAI-compatible APIs, like Openrouter, provide a tool name of
:null in streaming tool call chunks after supplying the actual
tool name with the first chunk for that tool call. Account for
this in the streaming parser. (#1181)
---
gptel-openai.el | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gptel-openai.el b/gptel-openai.el
index 29e7bb022d3..79c3d071481 100644
--- a/gptel-openai.el
+++ b/gptel-openai.el
@@ -222,9 +222,9 @@ information if the stream contains it."
;; No text content, so look for tool calls
(when-let* ((tool-call (map-nested-elt delta '(:tool_calls
0)))
(func (plist-get tool-call :function)))
- (if (and (plist-get func :name)
- ;; TEMP: This check is for litellm compatibility,
should be removed
- (not (equal (plist-get func :name) "null"))) ;
new tool block begins
+ (if (and-let* ((func-name (plist-get func :name)) ((not
(eq func-name :null))))
+ ;; TEMP: This check is for litellm compatibility,
should be removed
+ (not (equal func-name "null"))) ; new tool block
begins
(progn
(when-let* ((partial (plist-get info :partial_json)))
(let* ((prev-tool-call (car (plist-get info
:tool-use)))