Skip to content

add support for thinking#521

Merged
drifkin merged 2 commits intomainfrom
drifkin/thinking-support
May 29, 2025
Merged

add support for thinking#521
drifkin merged 2 commits intomainfrom
drifkin/thinking-support

Conversation

@drifkin
Copy link
Copy Markdown
Contributor

@drifkin drifkin commented May 27, 2025

To support ollama/ollama#10584

@drifkin drifkin requested a review from jmorganca May 27, 2025 07:29
@drifkin drifkin force-pushed the drifkin/thinking-support branch from aada745 to eaad6df Compare May 27, 2025 07:35
@jmorganca jmorganca requested review from ParthSareen and mxyng May 27, 2025 16:12
Comment thread examples/thinking.py

response = chat('deepseek-r1', messages=messages, think=True)

print('Thinking:\n========\n\n' + response.message.thinking)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print('Thinking:\n========\n\n' + response.message.thinking)
print('Thinking:')
print(response.message.thinking)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and can do the same below

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha turns out I did have a version like that before, but I really wanted to highlight that there are two fields now, so having two print lines total feels like it slightly helps with that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool yeah that makes sense - could we just get rid of the === portion then and just do newline?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ===== is very intentional to do a markdown style header that's much more noticeable in its plaintext form, like

Thinking:
========

<Here is the thinking content>

Response:
========

<Here is the response>

Comment thread examples/thinking.py
@@ -0,0 +1,13 @@
from ollama import chat
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add this example to the examples/README.md

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh thank you! I totally didn't see that file

@drifkin drifkin merged commit 756bd8f into main May 29, 2025
2 checks passed
@drifkin drifkin deleted the drifkin/thinking-support branch May 29, 2025 23:02
@saddy001
Copy link
Copy Markdown

What's with ollama.generate? That should get the think parameter too.

drifkin added a commit that referenced this pull request May 30, 2025
@drifkin
Copy link
Copy Markdown
Contributor Author

drifkin commented May 30, 2025

What's with ollama.generate? That should get the think parameter too.

apologies, should be fixed in #524, will try to get that published soon

drifkin added a commit that referenced this pull request May 30, 2025
drifkin added a commit that referenced this pull request May 30, 2025
@saddy001
Copy link
Copy Markdown

saddy001 commented Jun 2, 2025

In the meantime I switched to .chat and I wonder what may be the purpose of .generate when there is .chat with stream=True.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants