Skip to content

Conversation

@woofy0
Copy link
Contributor

@woofy0 woofy0 commented Sep 24, 2025

Description

When use Ollama's stream_chat with tools, it will throw an exception if it decides to call a tool:

TypeError: unhashable type: 'dict'

Traceback (most recent call last):
  File "C:\projects\llama_index\llama-index-integrations\llms\llama-index-llms-ollama\llama_index\llms\ollama\base.py", line 430, in gen
    "tool_calls": list(set(all_tool_calls)),

The other methods in base.py doesn't seem to call list(set(all_tool_calls)) since it looks like there's already logic above it that guarantees uniqueness in the tool calls.

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • No

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Your pull-request will likely not be merged unless it is covered by some form of impactful unit testing.

  • I added new unit tests to cover this change
  • I believe this change is already covered by existing unit tests

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran uv run make format; uv run make lint to appease the lint gods

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Sep 24, 2025
@masci masci changed the title Bug fix ollama stream chat with tools Fix TypeError: unhashable type: 'dict' in Ollama stream chat with tools Sep 25, 2025
Copy link
Contributor

@masci masci left a comment

Choose a reason for hiding this comment

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

LGTM!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 25, 2025
@masci masci merged commit 8079db7 into run-llama:main Sep 25, 2025
10 of 11 checks passed
Nightwing-77 pushed a commit to Nightwing-77/llama_index that referenced this pull request Sep 29, 2025
…ools (run-llama#19938)

* Fixed exception thrown when stream_chat is used with tools and tries to call set on a dict

* updated version

* linting

---------

Co-authored-by: Duong. Sinclair <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants