-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
base: main
Are you sure you want to change the base?
Added support for the "think" for Ollama #3386
Conversation
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]>
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]>
@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]>
Yes, we will review. Thanks |
models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaOptions.java
Show resolved
Hide resolved
models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java
Show resolved
Hide resolved
…tionMetadata`, and added corresponding unit tests. Signed-off-by: Sun Yuhan <[email protected]>
Signed-off-by: Sun Yuhan <[email protected]>
可以考虑加一个可自由扩展参数的字段,可以灵活应对兼容参数并避免延迟于ollama的更新。 |
Hi @markpollack , I hope you're doing well! I just wanted to check in and see if there are any further changes needed for this PR. Let me know if there's anything else I should address — happy to make adjustments if needed! Thanks again for your time and review! |
I would like to ask: If this PR is merged, will this feature be included in the snapshot version library? Then how can developers who are currently using the GA version use this feature? |
It seems to me that this feature should be included in 1.1.x, as well as being backport to 1.0.x. By the time the 1.0.x version is officially released, users currently using the 1.0.0 GA version will be able to use it by upgrading to the 1.0.x version |
…-thinking # Conflicts: # models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java # models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaImage.java
yes, I will backport it. Sorry about the delay. Only now getting my project mgmt hat on full time @sunyuhan1998 |
no problem at all! Please feel free to let me know if any changes are needed. |
Fixes #3383
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:
think
field to Ollama'sChatRequest
thinking
field to Ollama'sMessage
think
property toOllamaOptions
, allowing users to specify whether to enable or disable thinkingActually, 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 asOllamaAssistantMessage
. I'm not sure whether this would be considered a significant change.