The ChatAdmin
class, an extension of the Agent
class in MiniAutoGen, is designed to manage and orchestrate chat sessions. It plays a pivotal role in controlling the flow and execution of chat rounds, ensuring that conversations align with predefined goals and constraints.
ChatAdmin
inherits from the Agent
class and adds specific functionalities for administrating group chats, such as starting/stopping the chat and executing chat rounds.
- Purpose: Initializes a
ChatAdmin
object with specified parameters. - Parameters:
agent_id
(str
): The unique identifier of the agent.name
(str
): The name of the agent.role
(str
): The role of the agent in the chat.pipeline
(Pipeline
): The pipeline used for processing chat messages.group_chat
(GroupChat
): The group chat object to be managed.max_rounds
(int
): The maximum number of chat rounds to be executed.
- Purpose: Starts the Chat Admin, setting it to a running state.
- Functionality: Logs the start of the Chat Admin and sets the
running
flag toTrue
.
- Purpose: Stops the Chat Admin.
- Functionality: Sets the
running
flag toFalse
and logs the stop action.
- Purpose: Executes the chat rounds based on the maximum round limit and running state.
- Functionality: Manages the execution of chat rounds using the provided pipeline and persists the chat state.
- Purpose: Executes a single round of the chat.
- Parameters:
state
(ChatPipelineState
): The current state of the chat pipeline.
- Functionality: Logs the round execution, processes the chat round using the pipeline, increments the round counter, and persists the chat state.
- Purpose: Creates a
ChatAdmin
object from JSON data. - Parameters:
json_data
(dict
): The JSON data containing agent information.pipeline
(Pipeline
): The pipeline for processing chat messages.group_chat
(GroupChat
): The group chat object.max_rounds
(int
): The maximum number of chat rounds.
- Returns: A
ChatAdmin
object. - Raises:
ValueError
if the JSON data lacks required keys.
chat_admin = ChatAdmin(
agent_id="admin1",
name="ChatController",
role="Administrator",
pipeline=my_pipeline,
group_chat=my_group_chat,
max_rounds=10
)
chat_admin.run()
chat_admin.stop()
Assuming json_data
contains required keys and valid objects for pipeline
and group_chat
:
json_data = {"agent_id": "admin2", "name": "SessionManager", "role": "Coordinator"}
chat_admin_from_json = ChatAdmin.from_json(
json_data, my_pipeline, my_group_chat, 5
)