Skip to content

Python: Update ollama samples#6412

Open
alxxdev wants to merge 2 commits into
microsoft:mainfrom
alxxdev:alxxdev-patch-1
Open

Python: Update ollama samples#6412
alxxdev wants to merge 2 commits into
microsoft:mainfrom
alxxdev:alxxdev-patch-1

Conversation

@alxxdev

@alxxdev alxxdev commented Jun 9, 2026

Copy link
Copy Markdown

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:

client.get_response(messages, tools=get_time)
client.get_response(messages, tools=get_time, stream=True)

With:

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

Motivation and Context

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

## 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 microsoft#6411

## Testing

- Manual: sample now runs without TypeError
- Verified tool calling works with `llama3.2` model and Ollama
Copilot AI review requested due to automatic review settings June 9, 2026 12:06

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 instead of the tools keyword argument.

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})

Comment thread python/samples/02-agents/providers/ollama/ollama_chat_client.py
Comment thread python/samples/02-agents/providers/ollama/ollama_chat_client.py
@moonbox3 moonbox3 added the python label Jun 9, 2026
@github-actions github-actions Bot changed the title Update ollama_chat_client.py Python: Update ollama_chat_client.py Jun 9, 2026
@eavanvalkenburg eavanvalkenburg changed the title Python: Update ollama_chat_client.py Python: Update ollama samples Jun 10, 2026
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

4 participants