agentchat.agent
Agent
(In preview) A protocol for Agent.
An agent can communicate with other agents and perform actions.
Different agents can differ in what actions they perform in the receive
method.
name
The name of the agent.
description
The description of the agent. Used for the agent’s introduction in a group chat setting.
send
Send a message to another agent.
Arguments:
message
dict or str - the message to send. If a dict, it should be a JSON-serializable and follows the OpenAI’s ChatCompletion schema.recipient
Agent - the recipient of the message.request_reply
bool - whether to request a reply from the recipient.
a_send
(Async) Send a message to another agent.
Arguments:
message
dict or str - the message to send. If a dict, it should be a JSON-serializable and follows the OpenAI’s ChatCompletion schema.recipient
Agent - the recipient of the message.request_reply
bool - whether to request a reply from the recipient.
receive
Receive a message from another agent.
Arguments:
message
dict or str - the message received. If a dict, it should be a JSON-serializable and follows the OpenAI’s ChatCompletion schema.sender
Agent - the sender of the message.request_reply
bool - whether the sender requests a reply.
a_receive
(Async) Receive a message from another agent.
Arguments:
message
dict or str - the message received. If a dict, it should be a JSON-serializable and follows the OpenAI’s ChatCompletion schema.sender
Agent - the sender of the message.request_reply
bool - whether the sender requests a reply.
generate_reply
Generate a reply based on the received messages.
Arguments:
messages
list[dict] - a list of messages received from other agents. The messages are dictionaries that are JSON-serializable and follows the OpenAI’s ChatCompletion schema.sender
- sender of an Agent instance.
Returns:
str or dict or None: the generated reply. If None, no reply is generated.
a_generate_reply
(Async) Generate a reply based on the received messages.
Arguments:
messages
list[dict] - a list of messages received from other agents. The messages are dictionaries that are JSON-serializable and follows the OpenAI’s ChatCompletion schema.sender
- sender of an Agent instance.
Returns:
str or dict or None: the generated reply. If None, no reply is generated.
LLMAgent
(In preview) A protocol for an LLM agent.
system_message
The system message of this agent.
update_system_message
Update this agent’s system message.
Arguments:
system_message
str - system message for inference.