
This PR refactored `AgentEvent` and `ChatMessage` union types to abstract base classes. This allows for user-defined message types that subclass one of the base classes to be used in AgentChat. To support a unified interface for working with the messages, the base classes added abstract methods for: - Convert content to string - Convert content to a `UserMessage` for model client - Convert content for rendering in console. - Dump into a dictionary - Load and create a new instance from a dictionary This way, all agents such as `AssistantAgent` and `SocietyOfMindAgent` can utilize the unified interface to work with any built-in and user-defined message type. This PR also introduces a new message type, `StructuredMessage` for AgentChat (Resolves #5131), which is a generic type that requires a user-specified content type. You can create a `StructuredMessage` as follow: ```python class MessageType(BaseModel): data: str references: List[str] message = StructuredMessage[MessageType](content=MessageType(data="data", references=["a", "b"]), source="user") # message.content is of type `MessageType`. ``` This PR addresses the receving side of this message type. To produce this message type from `AssistantAgent`, the work continue in #5934. Added unit tests to verify this message type works with agents and teams.
Building the AutoGen Documentation
AutoGen documentation is based on the sphinx documentation system and uses the myst-parser to render markdown files. It uses the pydata-sphinx-theme to style the documentation.
Prerequisites
Ensure you have all of the dev dependencies for the autogen-core
package installed. You can install them by running the following command from the root of the python repository:
uv sync
source .venv/bin/activate
Building Docs
To build the documentation, run the following command from the root of the python repository:
poe --directory ./packages/autogen-core/ docs-build
To serve the documentation locally, run the following command from the root of the python repository:
poe --directory ./packages/autogen-core/ docs-serve
[!NOTE]
Sphinx will only rebuild files that have changed since the last build. If you want to force a full rebuild, you can delete the ./packages/autogen-core/docs/build
directory before running the docs-build
command.
Versioning the Documentation
The current theme - pydata-sphinx-theme - supports switching between versions of the documentation.
To version the documentation, you need to create a new version of the documentation by copying the existing documentation to a new directory with the version number. For example, to create a new version of the documentation for version 0.1.0
, you would run the following command:
How are various versions built? - TBD.