Tool support
Ollama now supports tool calling with popular models such as Llama 3.1. This enables a model to answer a given prompt using tool(s) it knows about, making it possible for models to perform more complex tasks or interact with the outside world.
Example tools include:
- Functions and APIs
- Web browsing
- Code interpreter
- much more!
352317275-aea4d7c1-f1be-41fd-9077-023d37a9d052.mov
To use tools, provide the tools
field when using Ollama's Chat API:
import ollama
response = ollama.chat(
model='llama3.1',
messages=[{'role': 'user', 'content': 'What is the weather in Toronto?'}],
# provide a weather checking tool to the model
tools=[{
'type': 'function',
'function': {
'name': 'get_current_weather',
'description': 'Get the current weather for a city',
'parameters': {
'type': 'object',
'properties': {
'city': {
'type': 'string',
'description': 'The name of the city',
},
},
'required': ['city'],
},
},
},
],
)
print(response['message']['tool_calls'])
More information:
New models
- Llama 3.1: a new state-of-the-art model from Meta available in 8B, 70B and 405B parameter sizes with support for tool calling.
- Mistral Large 2: Mistral's new 123B flagship model that is significantly more capable in code generation, tool calling, mathematics, and reasoning with 128k context window and support for dozens of languages.
- Firefunction v2: An open weights function calling model based on Llama 3, competitive with GPT-4o function calling capabilities.
- Llama-3-Groq-Tool-Use: A series of models from Groq that represent a significant advancement in open-source AI capabilities for tool use/function calling.
What's Changed
- Fixed duplicate error message when running
ollama create
New Contributors
- @lreed-mdsol made their first contribution in #5757
- @ajhai made their first contribution in #5799
Full Changelog: v0.2.8...v0.3.0