Python: Fix ollama_chat_client.py sample: pass tools via options dict (#6480)

* Fix ollama_chat_client.py sample: pass tools via options dict

The sample was passing tools as a direct keyword argument to
get_response(), which caused a TypeError. The tools parameter
must be passed inside the options dict per the SupportsChatGetResponse
protocol.

Fixes #6411

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Wrap tools in a list as expected by OllamaChatClient

_prepare_tools_for_ollama iterates the tools value, so it must be a
list rather than a bare FunctionTool instance.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Giles Odigwe
2026-06-14 23:52:14 -07:00
committed by GitHub
Unverified
parent ed4ff188fc
commit df0bd4da82
@@ -40,12 +40,12 @@ async def main() -> None:
print(f"User: {message}")
if stream:
print("Assistant: ", end="")
async for chunk in client.get_response(messages, tools=get_time, stream=True):
async for chunk in client.get_response(messages, options={"tools": [get_time]}, stream=True):
if str(chunk):
print(str(chunk), end="")
print("")
else:
response = await client.get_response(messages, tools=get_time)
response = await client.get_response(messages, options={"tools": [get_time]})
print(f"Assistant: {response}")