branch: elpa/gptel commit 5341ec71b6ffccf1822c7c6e31930f990d5842fd Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com> Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>
openai-extras: Refine reasoning block detection for Deepseek * gptel-openai-extras.el (gptel-curl--parse-stream): Update the Deepseek backend's reasoning block handling (when streaming) to handle models that use <think> blocks. This brings the logic in line with that of the main OpenAI stream parser, as refined in 9caf7684c3a4182e173afe57fa06e53aafc53434. (#901) --- gptel-openai-extras.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gptel-openai-extras.el b/gptel-openai-extras.el index 9f2c8caa06..f2c3d7b05f 100644 --- a/gptel-openai-extras.el +++ b/gptel-openai-extras.el @@ -294,11 +294,11 @@ parameters." ;; and reset by the stream filter. (plist-put info :reasoning (concat (plist-get info :reasoning) reasoning)) - (when-let* ((content (plist-get delta :content)) - ((not (eq content :null)))) - (if (eq (plist-get info :reasoning-block) 'in) ;Check if in reasoning block - (plist-put info :reasoning-block t) ;End of streaming reasoning block - (plist-put info :reasoning-block 'done)) ;Not using a reasoning model + ;; Done with reasoning if we get non-empty content + (when-let* (((plist-member info :reasoning)) ;Is this a reasoning model? + (content (plist-get delta :content)) ;Started receiving text content? + ((not (or (eq content :null) (string-empty-p content))))) + (plist-put info :reasoning-block t) ;Signal end of reasoning block (throw 'done t))))))))))) (cl-defmethod gptel--parse-response :before ((_backend gptel-deepseek) response info)