branch: elpa/gptel commit 2e3865289aaa7abdc5e4d67798db0d9e1edcb26d Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com> Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>
gptel-openai: Handle empty reasoning chunk strings * gptel-openai.el (gptel-curl--parse-stream): If the reasoning field is an empty string, don't count it as a reasoning block. This is an experimental change intended to work around the behavior of some Openrouter models (#1027). * test: Add stream parsing tests, including the failing stream output from #1027. --- gptel-openai.el | 2 +- test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gptel-openai.el b/gptel-openai.el index 2425d36ff3d..f87642cff36 100644 --- a/gptel-openai.el +++ b/gptel-openai.el @@ -241,7 +241,7 @@ information if the stream contains it." ;; Check for reasoning blocks, currently only used by Openrouter (unless (eq (plist-get info :reasoning-block) 'done) (if-let* ((reasoning-chunk (plist-get delta :reasoning)) ;for Openrouter and co - ((not (eq reasoning-chunk :null)))) + ((not (or (eq reasoning-chunk :null) (string-empty-p reasoning-chunk))))) (plist-put info :reasoning (concat (plist-get info :reasoning) reasoning-chunk)) ;; Done with reasoning if we get non-empty content diff --git a/test b/test index 8d3961d7ad3..00c8e27ee58 160000 --- a/test +++ b/test @@ -1 +1 @@ -Subproject commit 8d3961d7ad368ccca84f6b44f49360f78295f3df +Subproject commit 00c8e27ee58a074e494a376b8724f5daa37abc99