autogen.GroupChatManager
GroupChatManager
(In preview) A chat manager agent that can manage a group chat of multiple agents.
Parameters:Name | Description |
---|---|
groupchat | Type: autogen.GroupChat |
name | name of the agent. Type: str | None Default: ‘chat_manager’ |
max_consecutive_auto_reply | the maximum number of consecutive auto replies. default to None (no limit provided, class attribute MAX_CONSECUTIVE_AUTO_REPLY will be used as the limit in this case). When set to 0, no auto reply will be generated. Type: int | None Default: 9223372036854775807 |
human_input_mode | whether to ask for human inputs every time a message is received. Possible values are “ALWAYS”, “TERMINATE”, “NEVER”. (1) When “ALWAYS”, the agent prompts for human input every time a message is received. Under this mode, the conversation stops when the human input is “exit”, or when is_termination_msg is True and there is no human input. (2) When “TERMINATE”, the agent only prompts for human input only when a termination message is received or the number of auto reply reaches the max_consecutive_auto_reply. (3) When “NEVER”, the agent will never prompt for human input. Under this mode, the conversation stops when the number of auto reply reaches the max_consecutive_auto_reply or when is_termination_msg is True. Type: Literal['ALWAYS', 'NEVER', 'TERMINATE'] Default: ‘NEVER’ |
system_message | system message for the ChatCompletion inference. Type: str | list | None Default: ‘Group chat manager.‘ |
silent | (Experimental) whether to print the message sent. If None, will use the value of silent in each function. Type: bool Default: False |
**kwargs |
Instance Attributes
groupchat
Returns the group chat managed by the group chat manager.
last_speaker
Return the agent who sent the last message to group chat manager.
In a group chat, an agent will always send a message to the group chat manager, and the group chat manager will send the message to all other agents in the group chat. So, when an agent receives a message, it will always be from the group chat manager. With this property, the agent receiving the message can know who actually sent the message.
Example:
Instance Methods
a_resume
Resumes a group chat using the previous messages as a starting point, asynchronously. Requires the agents, group chat, and group chat manager to be established as per the original group chat.
Parameters:Name | Description |
---|---|
messages | Type: list[dict] | str |
remove_termination_string | Type: str | Callable[[str], str] | None Default: None |
silent | Type: bool | None Default: False |
Type | Description |
---|---|
tuple[autogen.ConversableAgent, dict] | - Tuple[ConversableAgent, Dict]: A tuple containing the last agent who spoke and their message |
a_run_chat
Run a group chat asynchronously.
Parameters:Name | Description |
---|---|
messages | Type: list[dict] | None Default: None |
sender | Type: autogen.Agent | None Default: None |
config | Type: autogen.GroupChat | None Default: None |
chat_messages_for_summary
The list of messages in the group chat as a conversation to summarize. The agent is ignored.
Parameters:Name | Description |
---|---|
agent | Type: autogen.Agent |
clear_agents_history
Clears history of messages for all agents or selected one. Can preserve selected number of last messages.
That function is called when user manually provide “clear history” phrase in his reply.
When “clear history” is provided, the history of messages for all agents is cleared.
When “clear history <agent_name>
” is provided, the history of messages for selected agent is cleared.
When “clear history <nr_of_messages_to_preserve>
” is provided, the history of messages for all agents is cleared
except last <nr_of_messages_to_preserve>
messages.
When “clear history <agent_name>
<nr_of_messages_to_preserve>
” is provided, the history of messages for selected
agent is cleared except last <nr_of_messages_to_preserve>
messages.
Phrase “clear history” and optional arguments are cut out from the reply before it passed to the chat.
Name | Description |
---|---|
reply | reply message dict to analyze. Type: dict |
groupchat | GroupChat object. Type: autogen.GroupChat |
messages_from_string
Reads the saved state of messages in Json format for resume and returns as a messages list
Parameters:Name | Description |
---|---|
message_string | Type: str |
Type | Description |
---|---|
list[dict] | - List[Dict]: List of messages |
messages_to_string
Converts the provided messages into a Json string that can be used for resuming the chat. The state is made up of a list of messages
Parameters:Name | Description |
---|---|
messages | Type: list[dict] |
Type | Description |
---|---|
str | - str: Json representation of the messages which can be persisted for resuming later |
resume
Resumes a group chat using the previous messages as a starting point. Requires the agents, group chat, and group chat manager to be established as per the original group chat.
Parameters:Name | Description |
---|---|
messages | Type: list[dict] | str |
remove_termination_string | Type: str | Callable[[str], str] | None Default: None |
silent | Type: bool | None Default: False |
Type | Description |
---|---|
tuple[autogen.ConversableAgent, dict] | - Tuple[ConversableAgent, Dict]: A tuple containing the last agent who spoke and their message |
run_chat
Run a group chat.
Parameters:Name | Description |
---|---|
messages | Type: list[dict] | None Default: None |
sender | Type: autogen.Agent | None Default: None |
config | Type: autogen.GroupChat | None Default: None |