branch: elpa/gptel
commit 8e0d6829c759a338d8ee5f81b9523a9be9a514d4
Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>

    gptel-openai: Fix collision with openrouter parsing (#669)
    
    * gptel-openai.el (gptel-curl--parse-stream): Don't touch the
    :reasoning key of fsm-info in OpenAI's `gptel-curl--parse-stream'
    method unless using Openrouter.  This was causing collisions with
    the parsing of responses from other OpenAI-compatible backends
    that include the reasoning text in the main response field.
    
    This whole code path is a kludge, it might be better to just spin
    out a gptel-openrouter backend inheriting from gptel-openai.  This
    would be similar to how gptel-deepseek works.
---
 gptel-openai.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gptel-openai.el b/gptel-openai.el
index a550f0c12d..ea32b254ea 100644
--- a/gptel-openai.el
+++ b/gptel-openai.el
@@ -230,7 +230,9 @@ information if the stream contains it."
                       ;; old tool block continues, so continue collecting 
arguments in :partial_json 
                       (push (plist-get func :arguments) (plist-get info 
:partial_json)))))
                 ;; Check for reasoning blocks, currently only used by 
Openrouter
-                (unless (eq (plist-get info :reasoning) 'done)
+                ;; FIXME: Should this be moved to a dedicated Openrouter 
backend?
+                (unless (or (eq (plist-get info :reasoning) 'done)
+                            (not (plist-member delta :reasoning)))
                   (if-let* ((reasoning-chunk (plist-get delta :reasoning)) 
;for openrouter
                             ((not (eq reasoning-chunk :null))))
                       (plist-put info :reasoning

Reply via email to