Skip to content

Commit c77acf1

Browse files
committed
[Improvement] Fix Reasoning with Ollama
1 parent 01408f9 commit c77acf1

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

console_gpt/unichat_handler.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ def handle_streaming_completion(model_name, response_stream, conversation):
3636
reasoning_content += delta.reasoning_content
3737
rmd = Markdown(reasoning_content, code_theme="dracula")
3838
live.update(rmd)
39+
40+
if hasattr(delta, "reasoning") and delta.reasoning:
41+
reasoning_content += delta.reasoning
42+
rmd = Markdown(reasoning_content, code_theme="dracula")
43+
live.update(rmd)
3944

4045
if hasattr(delta, "content") and delta.content:
4146
current_content += delta.content
@@ -130,6 +135,10 @@ def handle_non_streaming_completion(model_name, response, conversation):
130135
if reasoning_content:
131136
assistance_reply(reasoning_content, f"{model_name} Reasoning")
132137

138+
reasoning = getattr(message, "reasoning", None)
139+
if reasoning:
140+
assistance_reply(reasoning, f"{model_name} Reasoning")
141+
133142
# Handle content
134143
content = getattr(message, "content", None)
135144
if not content and not has_previous_tool_calls:

0 commit comments

Comments
 (0)