GroupChat
GroupChat
has four built-in conversation patterns:
Method | Agent selection |
---|---|
auto (default) | Automatic, chosen by the GroupChatManager using an LLM |
round_robin | Sequentially in their added order |
random | Randomly |
manual | Selected by you at each turn |
Callable | Create your own flow |
Coordinating the GroupChat
is the GroupChatManager
, an agent that provides a way to start and resume multi-agent chats.
Let’s continue our lesson planner example to include a lesson reviewer and a teacher agent.
Before jumping into the code, here’s a quick run down of what you need to do:
- If using
auto
speaker selection, add specific descriptions to agents for GroupChatManager to use - Create a
GroupChat
and aGroupChatManager
- Start the chat with the
GroupChatManager
You can start any multi-agent chats using the initiate_chat
method
-
Separate to
system_message
, we add adescription
for our planner and reviewer agents and this is used exclusively for the purposes of determining the next agent by theGroupChatManager
when using automatic speaker selection. -
The teacher’s
system_message
is suitable as a description so, by not setting it, theGroupChatManager
will use thesystem_message
for the teacher when determining the next agent. -
The workflow is ended when the teacher’s message contains the phrase “DONE!”.
-
Construct the
GroupChat
with our agents and selection method as automatic (which is the default). -
GroupChat
requires aGroupChatManager
to manage the chat and an LLM configuration is needed because they’ll use an LLM to decide the next agent. -
Starting a chat with the
GroupChatManager
as therecipient
kicks off the group chat.
Now, let’s look at how this is done in a Swarm.