branch: elpa/gptel
commit 95d3da7cd9d183c5320a529475117dbe1c7e9b6c
Author: Trannie Carter <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>

    gptel-ollama: Reinitialize :reasoning-block after tool calls
    
    gptel-ollama.el (gptel-curl--parse-stream): Some models can reason
    in phases, for instance:
    
    - Reasoning block before a tool call
    - Tool call
    - New reasoning block after the tool call
    
    This is different from calling tools as part of the reasoning
    phase.
    
    Reinitialize reasoning-block to nil when there is no reasoning.
    This change is experimental, as this initialization will occur
    every turn in the stream parser when there is no reasoning
    content.
---
 gptel-ollama.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gptel-ollama.el b/gptel-ollama.el
index 4839c2cbcba..c17e8b4150d 100644
--- a/gptel-ollama.el
+++ b/gptel-ollama.el
@@ -61,8 +61,9 @@ Intended for internal use only.")
             (if (and reasoning (not (eq reasoning :null)))
                 (plist-put info :reasoning
                            (concat (plist-get info :reasoning) reasoning))
-              (when (eq 'in (plist-get info :reasoning-block))
-                (plist-put info :reasoning-block t)))
+              (if (eq 'in (plist-get info :reasoning-block))
+                  (plist-put info :reasoning-block t)
+                (plist-put info :reasoning-block nil)))
             (unless (eq done :json-false)
               (with-current-buffer (plist-get info :buffer)
                 (cl-incf gptel--ollama-token-count

Reply via email to