Skip to content

Commit 1a0a22f

Browse files
Jakub ZikaJakub Zika
authored andcommitted
Make reasoning parsing in openai-chat more robust
The previous implementation assumed the reasoning content would always be under the `:reasoning` key in the stream delta. This change introduces a check for the `:reasoning_content` key as well. This directly enables support for the native reasoning stream from the DeepSeek API (e.g., for `deepseek-reasoner` models) and improves compatibility with other potential OpenAI-like providers that may use this key.
1 parent 57fedd4 commit 1a0a22f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/eca/llm_providers/openai_chat.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@
217217
(on-message-received {:type :text :text (:content delta)}))
218218

219219
;; Process reasoning if present (o1 models and compatible providers)
220-
(when-let [reasoning-text (:reasoning delta)]
220+
(when-let [reasoning-text (or (:reasoning delta)
221+
(:reasoning_content delta))]
221222
(when on-reason
222223
(when-not @reasoning-started*
223224
;; Generate new reason-id for each thinking block
@@ -232,6 +233,7 @@
232233
;; Check if reasoning just stopped (was active, now nil, and we have content)
233234
(when (and @reasoning-started*
234235
(nil? (:reasoning delta))
236+
(nil? (:reasoning_content delta))
235237
(:content delta)
236238
on-reason)
237239
(on-reason {:status :finished :id @current-reason-id*})

0 commit comments

Comments
 (0)