-
Notifications
You must be signed in to change notification settings - Fork 4.4k
ollama: Add tool call support #29563
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
Conversation
The best way to allow tool calls on specific models is likely to have the user explicitly allow tools on specific models in |
The show model information API should have what you're looking for. You'll just have to call it on each model. |
Unfortunately I believe the |
Does it not? The capabilities key contains "tools" on llama models which have tool support. Are there models where this doesn't apply? |
I just checked with a bunch of different model families are it seems I was wrong! Thank you @lj3954, I'll work on something to make use of it. |
Value implements ToString, so we dont need to pass it through serde_json::to_string. This saves us from handling an error that can never occur since serde_json::json! always returns a valid Value
@mgsloan Hey! I saw you recently worked on #29885. I looked at creating a similar map_to_completion_events function for the ollama provider, but it doesn't seem to be working as I hoped for. Would you like to take a look at this PR's implementation and see if there's anything you could point out at a quick glance? Otherwise I'll schedule myself a deep dive into the agent crate. Thank you in advance! |
Thanks so much for getting this started! Very helpful ❤️ |
Really nice work here, @tidely! We made some small tweaks to your pull request, but it was already working great for the most part! |
The goal of this PR is to support tool calls using ollama. A lot of the serialization work was done in #15803 however the abstraction over language models always disables tools. ## Changelog: - Use `serde_json::Value` inside `OllamaFunctionCall` just as it's used in `OllamaFunctionCall`. This fixes deserialization of ollama tool calls. - Added deserialization tests using json from official ollama api docs. - Fetch model capabilities during model enumeration from ollama provider - Added `supports_tools` setting to manually configure if a model supports tools ## TODO: - [x] Fix tool call serialization/deserialization - [x] Fetch model capabilities from ollama api - [x] Add tests for parsing model capabilities - [ ] Documentation for `supports_tools` field for ollama language model config - [ ] Convert between generic language model types - [x] Pass tools to ollama Release Notes: - N/A --------- Co-authored-by: Antonio Scandurra <[email protected]> Co-authored-by: Nathan Sobo <[email protected]>
The goal of this PR is to support tool calls using ollama. A lot of the serialization work was done in #15803 however the abstraction over language models always disables tools.
Changelog:
serde_json::Value
insideOllamaFunctionCall
just as it's used inOllamaFunctionCall
. This fixes deserialization of ollama tool calls.supports_tools
setting to manually configure if a model supports toolsTODO:
supports_tools
field for ollama language model configRelease Notes: