branch: elpa/gptel
commit 0caad30f750961bb05159ea89aac4ee74353539d
Author: Karthik Chikmagalur <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>
gptel-request: Fix blank response check inside reasoning block
* gptel-request.el (gptel-curl--stream-filter): Update reasoning
block parsing logic when streaming. Now:
1. blank response chunks before reasoning blocks are ignored by
the reasoning parser. (Same as before)
2. blank response chunks inside a reasoning block are captured as
reasoning text by the parser. (New behavior)
Without this, reasoning text consisting of blank strings is
categorized as a response, causing the reasoning block demarcation
to fail and additional "#+begin_reasoning" (or equivalent markup)
to be inserted by gptel's default streaming callback.
---
gptel-request.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gptel-request.el b/gptel-request.el
index 9a30a914822..03ae103a97c 100644
--- a/gptel-request.el
+++ b/gptel-request.el
@@ -2764,7 +2764,8 @@ PROCESS and _STATUS are process parameters."
(unless reasoning-block ;Record that we're in a reasoning
block (#709)
(plist-put proc-info :reasoning-block 'in))
(plist-put proc-info :reasoning nil)) ;Reset for next
parsing round
- ((string-blank-p response)) ;Defer checking if response is
blank
+ ((and (string-blank-p response) ;Defer checking if response
is blank
+ (not reasoning-block))) ;unless we're in a reasoning
block already
((and (null reasoning-block) (length> response 0))
;; Obtained from main response stream: reasoning block start
(if-let* ((idx (string-match-p "<think>" response)))