| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
ca39adc358
|
Fix JSON serialization of team state by handling datetime objects in message dump (#6797)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
da20f7c6c7
|
Feature/agentchat message id field 6317 (#6645)
## Why are these changes needed? This PR implements unique ID fields for AgentChat messages to enable proper correlation between streaming chunks and completed messages. Currently, there's no way to correlate `ModelClientStreamingChunkEvent` chunks with their eventual completed message, which can lead to duplicate message display in streaming scenarios. The implementation adds: - `id: str` field to `BaseChatMessage` with automatic UUID generation - `id: str` field to `BaseAgentEvent` with automatic UUID generation - `full_message_id: str | None` field to `ModelClientStreamingChunkEvent` for chunk-to-message correlation This allows consumers of the streaming API to avoid double-printing messages by correlating chunks with their final complete message. ## Related issue number Closes #6317 ## Checks - [x] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
a4a16fd2f8
|
Aegis structure message (#6289)
Added support for structured message component using the Json to Pydantic utility functions. Note: also adding the ability to use a format string for structured messages. Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> |
1 year ago |
|
|
7615c7b83b
|
Rename to use BaseChatMessage and BaseAgentEvent. Bring back union types. (#6144)
Rename the `ChatMessage` and `AgentEvent` base classes to `BaseChatMessage` and `BaseAgentEvent`. Bring back the `ChatMessage` and `AgentEvent` as union of built-in concrete types to avoid breaking existing applications that depends on Pydantic serialization. Why? Many existing code uses containers like this: ```python class AppMessage(BaseModel): name: str message: ChatMessage # Serialization is this: m = AppMessage(...) m.model_dump_json() # Fields like HandoffMessage.target will be lost because it is now treated as a base class without content or target fields. ``` The assumption on `ChatMessage` or `AgentEvent` to be a union of concrete types could be in many existing code bases. So this PR brings back the union types, while keep method type hints such as those on `on_messages` to use the `BaseChatMessage` and `BaseAgentEvent` base classes for flexibility. |
1 year ago |
|
|
025490a1bd
|
Use class hierarchy to organize AgentChat message types and introduce StructuredMessage type (#5998)
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. |
1 year ago |