transforms
autogen.agentchat.contrib.capabilities.transforms.TextMessageContentName
TextMessageContentName
A transform for including the agent’s name in the content of a message.
How to create and apply the transform:
# Imports
from autogen.agentchat.contrib.capabilities import transform_messages, transforms
Create Transform
name_transform = transforms.TextMessageContentName(position=“start”, format_string=”‘{name}’ said:
“)
Create the TransformMessages
context_handling = transform_messages.TransformMessages( transforms=[ name_transform ] )
Add it to an agent so when they run inference it will apply to the messages
context_handling.add_to_agent(my_agent)
Parameters:Name | Description |
---|---|
position | Type: str Default: ‘start’ |
format_string | Type: str Default: ‘{name} |
deduplicate | Type: bool Default: True |
filter_dict | Type: dict[str, typing.Any] | None Default: None |
exclude_filter | Type: bool Default: True |
Instance Methods
apply_transform
Applies the name change to the message based on the position and format string.
Name | Description |
---|---|
messages | A list of message dictionaries. Type: list[dict[str, typing.Any]] |
Type | Description |
---|---|
list[dict[str, typing.Any]] | List[Dict]: A list of dictionaries with the message content updated with names. |
get_logs
Name | Description |
---|---|
pre_transform_messages | Type: list[dict[str, typing.Any]] |
post_transform_messages | Type: list[dict[str, typing.Any]] |