UnifiedMessage
autogen.llm_clients.models.unified_message.UnifiedMessage #
Bases: BaseModel
Unified message format supporting all provider features.
This message format can represent: - Text, images, audio, video - Reasoning blocks (OpenAI o1/o3, Anthropic) - Citations (web search results) - Tool calls and results - Any future content types via GenericContent - Any future role types via extensible role field
The role field uses UserRoleType which provides: - Type-safe enum values for standard roles (UserRoleEnum.USER, etc.) - String literal typing for known roles ("user", "assistant", "system", "tool") - Flexible string fallback for unknown/future provider-specific roles
get_text #
Extract all text content as string.
Uses the get_text() method of each content block for unified text extraction.
Source code in autogen/llm_clients/models/unified_message.py
get_reasoning #
get_citations #
get_tool_calls #
get_content_by_type #
Get all content blocks of a specific type.
This is especially useful for unknown types handled by GenericContent.
| PARAMETER | DESCRIPTION |
|---|---|
content_type | The type string to filter by (e.g., "text", "reasoning", "reflection") TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
list[BaseContent] | List of content blocks matching the type |
Source code in autogen/llm_clients/models/unified_message.py
is_standard_role #
Check if this message uses a standard role.
| RETURNS | DESCRIPTION |
|---|---|
bool | True if role is one of the standard roles (user, assistant, system, tool), |
bool | False if it's a custom/future role |