Skip to content

Commit

Permalink
Add metadata field to basemessage (#5372)
Browse files Browse the repository at this point in the history
Add metadata field to BaseMessage.

Why?
- additional metadata field can track 1) timestamp if needed, 2) flags
about the message. For instance, a use case is a metadata field
{"internal":"yes"} that would hide messages from being displayed in an
application or studio.

As long as an extra field is added to basemessage that is not consumed
by existing agents, I am happy.



Notes:
- We can also only add it to BaseChatMessage, that would be fine
- I don't care what the extra field is called as long as there is an
extra field somewhere
- I don't have preference for the type, a str could work, but a dict
would be more useful.

---------

Co-authored-by: Eric Zhu <[email protected]>
  • Loading branch information
husseinmozannar and ekzhu authored Feb 25, 2025
1 parent c302b54 commit 4dac9c8
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class and includes specific fields relevant to the type of message being sent.
"""

from abc import ABC
from typing import List, Literal
from typing import Dict, List, Literal

from autogen_core import FunctionCall, Image
from autogen_core.memory import MemoryContent
Expand All @@ -23,6 +23,9 @@ class BaseMessage(BaseModel, ABC):
models_usage: RequestUsage | None = None
"""The model client usage incurred when producing this message."""

metadata: Dict[str, str] = {}
"""Additional metadata about the message."""

model_config = ConfigDict(arbitrary_types_allowed=True)


Expand Down

0 comments on commit 4dac9c8

Please sign in to comment.