Skip to content

Fixed an issue where tool calls could not function properly when using the new version of Ollama. #3372

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

Closed

Conversation

sunyuhan1998
Copy link
Contributor

As stated in the issue: #3369, when using the new version of Ollama and a tool call is made, a NullPointerException occurs involving "evalDuration".

This is because, according to the official Ollama API documentation: https://github.com/ollama/ollama/blob/main/docs/api.md#generate-a-chat-completion, fields like eval_duration are only populated when the model response is completed. However, during a tool call, the from method of org.springframework.ai.ollama.OllamaChatModel fails to handle null values properly, leading to this issue.

I'm not entirely sure whether it's due to any changes Ollama may have made to the response interface. However, by adding more robust null checks, we can make this functionality work correctly.

…i.ollama.OllamaChatModel` could not work correctly when a tool call occurred while using Ollama.

Signed-off-by: Sun Yuhan <1085481446@qq.com>
@sunyuhan1998
Copy link
Contributor Author

Hi @tzolov , would you please have time to review this PR? Thank you.

@ilayaperumalg
Copy link
Member

@sunyuhan1998 Thanks for fixing the bug! Rebased and merged as 72fe3bf. Also, back-ported the changes into 1.0.x via 1eecd17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants