[GH-ISSUE #7799] langchain_ollama tool_calls is None #4986

Closed
opened 2026-04-12 16:02:57 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @UICJohn on GitHub (Nov 22, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7799

What is the issue?

File "/workspaces/vivichains-base/.venv/lib/python3.11/site-packages/langchain_ollama/chat_models.py", line 732, in _agenerate final_chunk = await self._achat_stream_with_aggregation( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspaces/vivichains-base/.venv/lib/python3.11/site-packages/langchain_ollama/chat_models.py", line 602, in _achat_stream_with_aggregation tool_calls=_get_tool_calls_from_response(stream_resp), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspaces/vivichains-base/.venv/lib/python3.11/site-packages/langchain_ollama/chat_models.py", line 71, in _get_tool_calls_from_response for tc in response["message"]["tool_calls"]: TypeError: 'NoneType' object is not iterable

when requesting message from langchain-ollama to ollama server, the message from response is: Message(role='assistant', content='It', images=None, tool_calls=None), which make if "tool_calls" in response["message"] is always true.

langchain-ollama version: 0.2.0

OS

macOS

GPU

Apple

CPU

Apple

Ollama version

0.4.3

Originally created by @UICJohn on GitHub (Nov 22, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7799 ### What is the issue? ` File "/workspaces/vivichains-base/.venv/lib/python3.11/site-packages/langchain_ollama/chat_models.py", line 732, in _agenerate final_chunk = await self._achat_stream_with_aggregation( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspaces/vivichains-base/.venv/lib/python3.11/site-packages/langchain_ollama/chat_models.py", line 602, in _achat_stream_with_aggregation tool_calls=_get_tool_calls_from_response(stream_resp), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspaces/vivichains-base/.venv/lib/python3.11/site-packages/langchain_ollama/chat_models.py", line 71, in _get_tool_calls_from_response for tc in response["message"]["tool_calls"]: TypeError: 'NoneType' object is not iterable` when requesting message from langchain-ollama to ollama server, the message from response is: Message(role='assistant', content='It', images=None, tool_calls=None), which make `if "tool_calls" in response["message"]` is always true. langchain-ollama version: 0.2.0 ### OS macOS ### GPU Apple ### CPU Apple ### Ollama version 0.4.3
GiteaMirror added the bug label 2026-04-12 16:02:57 -05:00
Author
Owner

@rick-github commented on GitHub (Nov 22, 2024):

langchain-ollama is a langchain project.

<!-- gh-comment-id:2494106250 --> @rick-github commented on GitHub (Nov 22, 2024): langchain-ollama is a [langchain](https://github.com/langchain-ai/langchain) project.
Author
Owner

@edmcman commented on GitHub (Nov 22, 2024):

I think it's from ollama python package 0.4.0. https://github.com/langchain-ai/langchain/pull/28291

<!-- gh-comment-id:2494294229 --> @edmcman commented on GitHub (Nov 22, 2024): I think it's from ollama python package 0.4.0. https://github.com/langchain-ai/langchain/pull/28291
Author
Owner

@edmcman commented on GitHub (Nov 22, 2024):

As a workaround, try pip install langchain_ollama 'ollama<0.4.0'

<!-- gh-comment-id:2494310914 --> @edmcman commented on GitHub (Nov 22, 2024): As a workaround, try `pip install langchain_ollama 'ollama<0.4.0'`
Author
Owner

@UICJohn commented on GitHub (Nov 23, 2024):

Well, wrong place to post the bug report.Anyone with the same issue can refer to this link: https://github.com/langchain-ai/langchain/issues/28281

<!-- gh-comment-id:2495182176 --> @UICJohn commented on GitHub (Nov 23, 2024): Well, wrong place to post the bug report.Anyone with the same issue can refer to this link: https://github.com/langchain-ai/langchain/issues/28281
Author
Owner

@edmcman commented on GitHub (Nov 23, 2024):

So was the API breaking change in Ollama intentional?

On Fri, Nov 22, 2024, 8:21 PM Marsland - @.***
@.***> wrote:

Well, wrong place to post the bug report.Anyone with the same issue can
refer to this link: langchain-ai/langchain#28281
https://github.com/langchain-ai/langchain/issues/28281


Reply to this email directly, view it on GitHub
https://github.com/ollama/ollama/issues/7799#issuecomment-2495182176,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAHYKZIJCXAM4P23FM7XJNL2B7KALAVCNFSM6AAAAABSJT37L6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJVGE4DEMJXGY
.
You are receiving this because you commented.Message ID:
@.***>

<!-- gh-comment-id:2495484022 --> @edmcman commented on GitHub (Nov 23, 2024): So was the API breaking change in Ollama intentional? On Fri, Nov 22, 2024, 8:21 PM Marsland - ***@***.*** ***@***.***> wrote: > Well, wrong place to post the bug report.Anyone with the same issue can > refer to this link: langchain-ai/langchain#28281 > <https://github.com/langchain-ai/langchain/issues/28281> > > — > Reply to this email directly, view it on GitHub > <https://github.com/ollama/ollama/issues/7799#issuecomment-2495182176>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAHYKZIJCXAM4P23FM7XJNL2B7KALAVCNFSM6AAAAABSJT37L6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJVGE4DEMJXGY> > . > You are receiving this because you commented.Message ID: > ***@***.***> >
Author
Owner

@rick-github commented on GitHub (Nov 23, 2024):

So was the API breaking change in Ollama intentional?

Probably a question for ollama-python.

<!-- gh-comment-id:2495486884 --> @rick-github commented on GitHub (Nov 23, 2024): > So was the API breaking change in Ollama intentional? Probably a question for [ollama-python](https://github.com/ollama/ollama-python/issues).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#4986