github microsoft/autogen python-v0.4.8

18 hours ago

What's New

Ollama Chat Completion Client

To use the new Ollama Client:

pip install -U "autogen-ext[ollama]"
from autogen_ext.models.ollama import OllamaChatCompletionClient
from autogen_core.models import UserMessage

ollama_client = OllamaChatCompletionClient(
    model="llama3",
)

result = await ollama_client.create([UserMessage(content="What is the capital of France?", source="user")])  # type: ignore
print(result)

To load a client from configuration:

from autogen_core.models import ChatCompletionClient

config = {
    "provider": "OllamaChatCompletionClient",
    "config": {"model": "llama3"},
}

client = ChatCompletionClient.load_component(config)

It also supports structured output:

from autogen_ext.models.ollama import OllamaChatCompletionClient
from autogen_core.models import UserMessage
from pydantic import BaseModel


class StructuredOutput(BaseModel):
    first_name: str
    last_name: str


ollama_client = OllamaChatCompletionClient(
    model="llama3",
    response_format=StructuredOutput,
)
result = await ollama_client.create([UserMessage(content="Who was the first man on the moon?", source="user")])  # type: ignore
print(result)

New Required name Field in FunctionExecutionResult

Now name field is required in FunctionExecutionResult:

exec_result = FunctionExecutionResult(call_id="...", content="...", name="...", is_error=False)
  • fix: Update SKChatCompletionAdapter message conversion by @lspinheiro in #5749

Using thought Field in CreateResult and ThoughtEvent

Now CreateResult uses the optional thought field for the extra text content generated as part of a tool call from model. It is currently supported by OpenAIChatCompletionClient.

When available, the thought content will be emitted by AssistantAgent as a ThoughtEvent message.

  • feat: Add thought process handling in tool calls and expose ThoughtEvent through stream in AgentChat by @ekzhu in #5500

New metadata Field in AgentChat Message Types

Added a metadata field for custom message content set by applications.

Exception in AgentChat Agents is now fatal

Now, if there is an exception raised within an AgentChat agent such as the AssistantAgent, instead of silently stopping the team, it will raise the exception.

New Termination Conditions

New termination conditions for better control of agents.

See how you use TextMessageTerminationCondition to control a single agent team running in a loop: https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/tutorial/teams.html#single-agent-team.

FunctionCallTermination is also discussed as an example for custom termination condition: https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/tutorial/termination.html#custom-termination-condition

  • TextMessageTerminationCondition for agentchat by @EItanya in #5742
  • FunctionCallTermination condition by @ekzhu in #5808

Docs Update

The ChainLit sample contains UserProxyAgent in a team, and shows you how to use it to get user input from UI. See: https://github.com/microsoft/autogen/tree/main/python/samples/agentchat_chainlit

  • doc & sample: Update documentation for human-in-the-loop and UserProxyAgent; Add UserProxyAgent to ChainLit sample; by @ekzhu in #5656
  • docs: Add logging instructions for AgentChat and enhance core logging guide by @ekzhu in #5655
  • doc: Enrich AssistantAgent API documentation with usage examples. by @ekzhu in #5653
  • doc: Update SelectorGroupChat doc on how to use O3-mini model. by @ekzhu in #5657
  • update human in the loop docs for agentchat by @victordibia in #5720
  • doc: update guide for termination condition and tool usage by @ekzhu in #5807
  • Add examples for custom model context in AssistantAgent and ChatCompletionContext by @ekzhu in #5810

Bug Fixes

  • Initialize BaseGroupChat before reset by @gagb in #5608
  • fix: Remove R1 model family from is_openai function by @ekzhu in #5652
  • fix: Crash in argument parsing when using Openrouter by @philippHorn in #5667
  • Fix: Add support for custom headers in HTTP tool requests by @linznin in #5660
  • fix: Structured output with tool calls for OpenAIChatCompletionClient by @ekzhu in #5671
  • fix: Allow background exceptions to be fatal by @jackgerrits in #5716
  • Fix: Auto-Convert Pydantic and Dataclass Arguments in AutoGen Tool Calls by @mjunaidca in #5737

Other Python Related Changes

New Contributors

Full Changelog: python-v0.4.7...python-v0.4.8

Don't miss a new autogen release

NewReleases is sending notifications on new releases.