Skip to content

Added support for the "think" for Ollama #3386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sunyuhan1998
Copy link
Contributor

@sunyuhan1998 sunyuhan1998 commented May 30, 2025

As mentioned in issue: #3383 , Ollama added support for "think" in its latest 0.9.0 version:
https://github.com/ollama/ollama/releases
https://github.com/ollama/ollama/blob/main/docs/api.md#generate-a-chat-completion.

This PR implements support for that attribute and includes the following key changes:

  1. Added the think field to Ollama's ChatRequest
  2. Added the thinking field to Ollama's Message
  3. Added the think property to OllamaOptions, allowing users to specify whether to enable or disable thinking

Actually, there is currently another issue:

As stated in Ollama's API documentation here, during requests to Ollama, the message field supports sending the model's own reasoning (thoughts) back to it. However, AssistantMessage does not currently support transmitting this field, which means the model will not be aware of its previous thoughts.

Therefore, perhaps we need to add a specialized Message implementation for Ollama, such as OllamaAssistantMessage. I'm not sure whether this would be considered a significant change.

      1. Added the `think` field to Ollama's `ChatRequest`
      2. Added the `thinking` field to Ollama's `Message`
      3. Added the `think` property to `OllamaOptions`, allowing users to specify whether to enable or disable thinking

Signed-off-by: Sun Yuhan <[email protected]>
…fault behavior, thereby ensuring compatibility with older versions of Ollama calls.

Signed-off-by: Sun Yuhan <[email protected]>
@sunyuhan1998
Copy link
Contributor Author

@tzolov @ilayaperumalg @markpollack Could you please help review this PR? Thank you.

…tainer image version of ollama to 0.9.0

Signed-off-by: Sun Yuhan <[email protected]>
@markpollack
Copy link
Member

Yes, we will review. Thanks

@markpollack markpollack self-assigned this May 30, 2025
@markpollack markpollack added this to the 1.1.x milestone May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants