Skip to content

docs(ollama): add tool-calling example to integration landing page#473

Open
albertodiazdurana wants to merge 3 commits into
deepset-ai:mainfrom
albertodiazdurana:docs/ollama-tool-calling-example
Open

docs(ollama): add tool-calling example to integration landing page#473
albertodiazdurana wants to merge 3 commits into
deepset-ai:mainfrom
albertodiazdurana:docs/ollama-tool-calling-example

Conversation

@albertodiazdurana
Copy link
Copy Markdown

Closes deepset-ai/haystack-core-integrations#3263.

This adds a minimal tool-calling example to the Ollama integration
landing page (integrations/ollama.md). Practitioners landing on the
page can now see that OllamaChatGenerator supports local tool calling.

The example uses create_tool_from_function (the current public helper
per haystack 2.x) and sets temperature=0.0 + a directive prompt for
reliable tool-call emission on Llama 3.1 8B; both are needed for
reproducibility, verified empirically.

Streaming-with-tools and tool_choice are deferred to the component
reference page (docs.haystack.deepset.ai/docs/ollamachatgenerator),
as agreed in the issue thread.

Closes deepset-ai/haystack-core-integrations#3263.

Adds a minimal OllamaChatGenerator + Tool example to the Ollama
integration landing page so practitioners can discover that local
tool calling is supported. Verified empirically with llama3.1:8b on
Ollama. Streaming-with-tools and tool_choice are deferred to the
component reference page.
Comment thread integrations/ollama.md Outdated
Comment on lines +180 to +185
def get_weather(city: str) -> str:
"""Get current weather for a city."""
return f"Sunny, 22°C in {city}"


weather_tool = create_tool_from_function(get_weather)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use a tool decorator instead of create_tool_from_function?

Address @kacperlukawski review on
deepset-ai#473:
replace create_tool_from_function with the @tool decorator, which
matches the idiomatic form documented in haystack/tools/from_function.py.

Verified empirically against ollama llama3.1:8b: the updated snippet
emits ToolCall(tool_name='get_weather', arguments={'city': 'Berlin'},
...).

Net: -4 / +3 lines on integrations/ollama.md.
@albertodiazdurana
Copy link
Copy Markdown
Author

Thanks @kacperlukawski. Replaced create_tool_from_function with @tool and merged upstream/main. Verified locally against ollama llama3.1:8b: the snippet emits the expected ToolCall(...), and @tool produces a structurally identical Tool to the previous form for the same function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: surface tool-calling on the Ollama integration landing page

2 participants