From 836a20a4020541aadb61ae370ed2c1d8c83043f7 Mon Sep 17 00:00:00 2001 From: Alexander <165938806+alxxdev@users.noreply.github.com> Date: Tue, 9 Jun 2026 15:05:26 +0300 Subject: [PATCH] Update ollama_chat_client.py ## Summary Fix `ollama_chat_client.py` sample where `tools` was passed as a direct keyword argument to `OllamaChatClient.get_response()`, causing `TypeError`. ## Problem `FunctionInvocationLayer.get_response()` does not accept `tools` as a parameter. It should be passed inside the `options` TypedDict (`ChatOptions`). Running the sample raised: ``` TypeError: FunctionInvocationLayer.get_response() got an unexpected keyword argument 'tools' ``` ## Fix Replaced: ```python client.get_response(messages, tools=get_time) client.get_response(messages, tools=get_time, stream=True) ``` With: ```python client.get_response(messages, options={"tools": get_time}) client.get_response(messages, options={"tools": get_time}, stream=True) ``` ## Related issue Closes #6411 ## Testing - Manual: sample now runs without TypeError - Verified tool calling works with `llama3.2` model and Ollama --- .../samples/02-agents/providers/ollama/ollama_chat_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/samples/02-agents/providers/ollama/ollama_chat_client.py b/python/samples/02-agents/providers/ollama/ollama_chat_client.py index adf2d3818e3..386506f3ce4 100644 --- a/python/samples/02-agents/providers/ollama/ollama_chat_client.py +++ b/python/samples/02-agents/providers/ollama/ollama_chat_client.py @@ -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}")