BaseOllamaChatCompletionClient errors with host
arg; incorrectly passes Ollama client constructor host
argument to the Ollama client's .chat()
method
#5663
Labels
Milestone
What happened?
Describe the bug
For the purpose of this issue, it's important to distinguish between the ollama AsyncClient python client and the Autogen OllamaChatCompletionClient (and BaseOllamaChatCompletionClient), which itself uses the ollama AsyncClient to interact with an ollama server (i.e. amongst other things, the autogen OllamaChatCompletionClient wraps an ollama AsyncClient)
When instantiating an autogen OllamaChatCompletionClient, you can pass an arbitrary kwargs to its constructor, some of which are intended to be passed through to the ollama AsyncClient constructor, and the rest of which are intended to be passed to the instantiated ollama AsyncClient's various generation methods (i.e. what Autogen tends to refer to as
create_args
) at inference time .Notice that all of the kwargs are passed to both the AsyncClient constructor through the
_ollama_client_from_config()
function to instantiate an AsyncClient and eventually to the AsyncClient's inference time arguments (by passing thecreate_args
to the BaseOllamaChatCompletionClient's constructor).While the ollama AsyncClient's constructor accepts arbitrary kwargs, its
.chat()
method does not. Therefore, if you pass ahost
kwarg to the autogen OllamaChatCompletionClient constructor, while it successfully uses thathost
value when instantiating the underlying ollama AsyncClient, thathost
kwarg is also eventually passed to the AsyncClient's.chat()
method which raises a TypeError:To Reproduce
main
Github branch herehost
kwarg (even passinghttp://localhost:11434
if you have Ollama server running on your host machine should still trigger the issue):.create()
method:host
being passed to ollama AsyncClient's.chat()
raises TypeError as an unexpected kwarg.Expected behavior
Calls to an instantiated OllamaChatCompletionClient's
.create()
method should run successfully, even if ahost
kwarg value is passed to the OllamaChatCompletionClient's constructor.Suggested resolution
My initial thoughts for resolving the issue involve either a) removing all kwargs that are used to create the ollama AsyncClient after the client has been instantiated, or b) remove all kwargs except for those expected by the AsyncClient's
.chat()
method.One challenge with option a will be that there are arbitrary **kwargs that can be passed to the AsyncClient's constructor that are then passed through to httpx, meaning those would also need to be identified and removed. A challenge with option b is that if new kwargs or options are added to the ollama AsyncClient's
.chat()
method signature, they would not be supported in the autogen OllamaChatCompletionClient until the list of excepted kwargs is updated. However, I believe the AsyncClient's.chat()
method signature is relatively stable, so my instinct would be to go with option bWhich packages was the bug in?
Python Extensions (autogen-ext)
AutoGen library version.
Python dev (main branch)
Other library version.
No response
Model used
ollama qwen2.5, but specific model is not relevant to this issue
Model provider
Ollama
Other model provider
No response
Python version
3.12
.NET version
None
Operating system
Ubuntu
The text was updated successfully, but these errors were encountered: