Skip to content

Commit c89d61d

Browse files
committed
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.
1 parent 98009c1 commit c89d61d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

gptel-request.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2764,7 +2764,8 @@ PROCESS and _STATUS are process parameters."
27642764
(unless reasoning-block ;Record that we're in a reasoning block (#709)
27652765
(plist-put proc-info :reasoning-block 'in))
27662766
(plist-put proc-info :reasoning nil)) ;Reset for next parsing round
2767-
((string-blank-p response)) ;Defer checking if response is blank
2767+
((and (string-blank-p response) ;Defer checking if response is blank
2768+
(not reasoning-block))) ;unless we're in a reasoning block already
27682769
((and (null reasoning-block) (length> response 0))
27692770
;; Obtained from main response stream: reasoning block start
27702771
(if-let* ((idx (string-match-p "<think>" response)))

0 commit comments

Comments
 (0)