Skip to content

ChatContext

autogen.tools.ChatContext #

ChatContext(agent)

Bases: BaseContext

ChatContext class that extends BaseContext.

This class is used to represent a chat context that holds a list of messages. It inherits from BaseContext and adds the messages attribute.

Initializes the ChatContext with an agent.

PARAMETER DESCRIPTION
agent

The agent to use for retrieving chat messages.

TYPE: ConversableAgent

Source code in autogen/tools/dependency_injection.py
def __init__(self, agent: "ConversableAgent") -> None:
    """Initializes the ChatContext with an agent.

    Args:
        agent: The agent to use for retrieving chat messages.
    """
    self._agent = agent

chat_messages property #

chat_messages

The messages in the chat.

RETURNS DESCRIPTION
dict[Agent, list[dict[Any, Any]]]

A dictionary of agents and their messages.

last_message property #

last_message

The last message in the chat.

RETURNS DESCRIPTION
Optional[dict[str, Any]]

The last message in the chat.