Skip to content

docs(ollama): add streaming-with-tools example to OllamaChatGenerator reference#11268

Open
albertodiazdurana wants to merge 3 commits intodeepset-ai:mainfrom
albertodiazdurana:docs/ollamachatgenerator-streaming-with-tools
Open

docs(ollama): add streaming-with-tools example to OllamaChatGenerator reference#11268
albertodiazdurana wants to merge 3 commits intodeepset-ai:mainfrom
albertodiazdurana:docs/ollamachatgenerator-streaming-with-tools

Conversation

@albertodiazdurana
Copy link
Copy Markdown

@albertodiazdurana albertodiazdurana commented May 6, 2026

Related Issues

Proposed Changes:

Adds a ### Streaming with Tools section to the OllamaChatGenerator reference page (docs-website/docs/pipeline-components/generators/ollamachatgenerator.mdx), between the existing ### Streaming section and the ## Usage heading.

The section includes:

  • An executable example combining streaming_callback and tools on OllamaChatGenerator.
  • A behavioral note: within a single generation step, streamed text tokens and tool-call deltas are mutually exclusive. When the model invokes a tool, chunk.content is empty in the streamed chunks, and the final replies[0].text is None while replies[0].tool_calls carries the reconstructed call list.

How did you test it?

Manually verified against OllamaChatGenerator + llama3.1:8b on Ollama, with two spike scripts:

  1. Primary spike (directive prompt invoking get_weather): 2 chunks fired (1 carrying the tool-call delta, 1 closing). replies[0].tool_calls = [ToolCall(tool_name='get_weather', arguments={'city': 'Berlin'}, ...)]. replies[0].text is None. meta.finish_reason: stop.

  2. Backfill spike (mutual-exclusivity check): six prompts spanning directive / ambiguous / arithmetic / unrelated-topic / literary. Across all six, never observed text content and tool-call deltas in the same chunk, nor text and tool_calls together in the final ChatMessage. The arithmetic prompt ("What is 2+2?") produced 99 chunks of pure text (98 text-chunks, 0 tool-chunks), confirming text streaming works as expected when the model elects not to use a tool.

The change is documentation-only and does not introduce code changes; no unit-test additions apply.

Notes for the reviewer

Checklist

… reference

Closes deepset-ai/haystack-core-integrations#3263 (follow-up).

The component reference page already covers Tool Support and Streaming
in separate sections, but no example shows them combined. Adds a
Streaming with Tools section between the two, with an executable example
verified empirically against llama3.1:8b on Ollama.

Notable behavior captured in the doc: when the model invokes a tool,
streamed chunks carry tool_calls deltas and chunk.content is empty;
the final ChatMessage has text=None and tool_calls populated.
@albertodiazdurana albertodiazdurana requested a review from a team as a code owner May 6, 2026 16:15
@albertodiazdurana albertodiazdurana requested review from anakin87 and removed request for a team May 6, 2026 16:15
@vercel
Copy link
Copy Markdown

vercel Bot commented May 6, 2026

@albertodiazdurana is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 6, 2026

CLA assistant check
All committers have signed the CLA.

Per CONTRIBUTING.md, every PR requires a release note under
releasenotes/notes/. Categorized as `enhancements` to match the
shape of prior docs-only release notes (e.g.,
docs-cleaner-markdown-ocr-examples-...yaml).
@vercel
Copy link
Copy Markdown

vercel Bot commented May 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
haystack-docs Ready Ready Preview, Comment May 7, 2026 8:42am

Request Review

Copy link
Copy Markdown
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

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

Thank you!

I left some comments.

In addition, please also copy this change to 2.28 versioned docs (latest stable) in docs-website/versioned_docs/version-2.28/pipeline-components/generators/ollamachatgenerator.mdx.

@@ -0,0 +1,4 @@
---
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.

Since this change only affects docs, we don't need a release note. Please remove this file.

Comment on lines +133 to +135
:::tip[What to expect when tools fire]
When the model emits a tool call rather than free-form text, streamed chunks carry `tool_calls` deltas and `chunk.content` is empty. The final `replies[0].text` will be `None`, and `replies[0].tool_calls` holds the reconstructed call list. Plain text streaming and tool calling are mutually exclusive within a single generation step.
:::
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.

Suggested change
:::tip[What to expect when tools fire]
When the model emits a tool call rather than free-form text, streamed chunks carry `tool_calls` deltas and `chunk.content` is empty. The final `replies[0].text` will be `None`, and `replies[0].tool_calls` holds the reconstructed call list. Plain text streaming and tool calling are mutually exclusive within a single generation step.
:::

this is already kinda clear, so I'd remove this tip section

- Remove releasenotes/notes/streaming-with-tools-ollamachatgenerator-docs-8e339d62f38ebd06.yaml: docs-only change does not need a release note.
- Remove the :::tip[What to expect when tools fire] admonition from docs-website/docs/pipeline-components/generators/ollamachatgenerator.mdx: the inline comments in the streaming-with-tools example already convey the same information.
- Add the Streaming with Tools section to docs-website/versioned_docs/version-2.28/pipeline-components/generators/ollamachatgenerator.mdx (latest stable), byte-identical to the v3 docs section.
@albertodiazdurana
Copy link
Copy Markdown
Author

Thanks for the review @anakin87! Addressed all three comments:

  • Removed releasenotes/notes/streaming-with-tools-ollamachatgenerator-docs-8e339d62f38ebd06.yaml (docs-only change, no release note needed).
  • Removed the :::tip[What to expect when tools fire] admonition at the bottom of the streaming-with-tools section, the inline comments in the example already convey the same information.
  • Copied the new ### Streaming with Tools section into docs-website/versioned_docs/version-2.28/pipeline-components/generators/ollamachatgenerator.mdx (byte-identical to the v3 docs section).

Ready for another look when you have a moment.

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

3 participants