Skip to content

Python: pass Ollama sample tools through options#6504

Open
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/ollama-sample-tools-options
Open

Python: pass Ollama sample tools through options#6504
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/ollama-sample-tools-options

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Summary

  • pass Ollama sample tools through options={"tools": ...} instead of the unsupported tools= keyword
  • update both streaming and non-streaming sample calls

Fixes #6411.

Test plan

  • python -m py_compile python/samples/02-agents/providers/ollama/ollama_chat_client.py
  • rg -n "get_response\([^\n]*tools=" python/samples/02-agents/providers/ollama/ollama_chat_client.py python/packages -S
  • AST check that the sample has no tools= get_response calls and both sample calls pass options
  • git diff --check upstream/main..HEAD

Copilot AI review requested due to automatic review settings June 12, 2026 23:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the Ollama chat client sample to pass tool configuration via an options dictionary rather than using a dedicated tools parameter.

Changes:

  • Switched streaming call to client.get_response(..., options={"tools": get_time}, stream=True)
  • Switched non-streaming call to client.get_response(..., options={"tools": get_time})

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):
print("")
else:
response = await client.get_response(messages, tools=get_time)
response = await client.get_response(messages, options={"tools": get_time})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: ollama_chat_client.py sample passes tools as direct argument to get_response() causing TypeError

3 participants