Skip to content

Commit 242c014

Browse files
timfelkarthink
authored andcommitted
gptel-openai: Don't parse tools named "null" (karthink#935) (karthink#951)
* gptel-openai.el (gptel-curl--parse-stream): Temporarily ignore tools named "null" (the string, not the JSON type) when parsing tools during streaming. This is for compatibility with the litellm API, but this problem is on their side. NOTE: This change will be reverted without warning at the time of the next gptel release. (If litellm hasn't fixed it by then, your usage might break.) Co-authored-by: karthink <[email protected]>
1 parent 8daf537 commit 242c014

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

gptel-openai.el

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ information if the stream contains it."
219219
;; No text content, so look for tool calls
220220
(when-let* ((tool-call (map-nested-elt delta '(:tool_calls 0)))
221221
(func (plist-get tool-call :function)))
222-
(if (plist-get func :name) ;new tool block begins
222+
(if (and (plist-get func :name)
223+
;; TEMP: This check is for litellm compatibility, should be removed
224+
(not (equal (plist-get func :name) "null"))) ; new tool block begins
223225
(progn
224226
(when-let* ((partial (plist-get info :partial_json)))
225227
(let* ((prev-tool-call (car (plist-get info :tool-use)))

0 commit comments

Comments
 (0)