Skip to content

OllamaChatCompletionClient load_component() error #6994

@mhou7712

Description

@mhou7712

What happened?

import asyncio
from autogen_core.models import ChatCompletionClient, UserMessage

async def main():

    config = {
        "provider": "OllamaChatCompletionClient",
        "config": {
            "model": "qwen3",  # The Ollama model to use
            "host": "http://1.2.3.4:30130",
        }
    }

    client = ChatCompletionClient.load_component(config)

if __name__ == "__main__":
    asyncio.run(main())

the error is shown:

Traceback (most recent call last):
  File "/var/spool/autogen-dev/codes/autogen-tutorials/./ag_infra_test_04_ollama_test_2.py", line 19, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/var/spool/autogen-dev/codes/autogen-tutorials/./ag_infra_test_04_ollama_test_2.py", line 16, in main
    client = ChatCompletionClient.load_component(config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/autogen_core/_component_config.py", line 223, in load_component
    raise ValueError("Invalid")
ValueError: Invalid

However, the following code works with the same configuration:

import asyncio
from autogen_ext.models.ollama import OllamaChatCompletionClient

async def main():

    client = OllamaChatCompletionClient(
        model="qwen3", host = "http://1.2.3.4:30130"
        )

if __name__ == "__main__":
    asyncio.run(main())

Any suggestion?

Thanks.

Which packages was the bug in?

Python AgentChat (autogen-agentchat>=0.4.0)

AutoGen library version.

Python 0.7.4

Other library version.

No response

Model used

qwen3

Model provider

Ollama

Other model provider

No response

Python version

3.11

.NET version

None

Operating system

Ubuntu

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions