Skip to content

Commit df0bd4d

Browse files
giles17Copilot
andauthored
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>
1 parent ed4ff18 commit df0bd4d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

python/samples/02-agents/providers/ollama/ollama_chat_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ async def main() -> None:
4040
print(f"User: {message}")
4141
if stream:
4242
print("Assistant: ", end="")
43-
async for chunk in client.get_response(messages, tools=get_time, stream=True):
43+
async for chunk in client.get_response(messages, options={"tools": [get_time]}, stream=True):
4444
if str(chunk):
4545
print(str(chunk), end="")
4646
print("")
4747
else:
48-
response = await client.get_response(messages, tools=get_time)
48+
response = await client.get_response(messages, options={"tools": [get_time]})
4949
print(f"Assistant: {response}")
5050

5151

0 commit comments

Comments
 (0)