Group Chat with Customized Speaker Selection Method
Introduce group chat with customized speaker selection method.
AG2 offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framework allows tool use and human participation through multi-agent conversation. Please find documentation about this feature here.
In this notebook, we demonstrate how to pass a customized agent selection method to GroupChat. The customized function looks like this:
The last speaker and the groupchat object are passed to the function.
Commonly used variables from groupchat are groupchat.messages
an
groupchat.agents
, which is the message history and the agents in the
group chat respectively. You can access other attributes of the
groupchat, such as groupchat.allowed_speaker_transitions_dict
for
pre-defined allowed_speaker_transitions_dict.
Set your API Endpoint
The
config_list_from_json
function loads a list of configurations from an environment variable or
a json file.
Learn more about configuring LLMs for agents here.
Construct Agents
- Planner: Give a plan and revise.
- Admin: Human in the loop to approve or terminate the process.
- Engineer: Retrieve papers from the internet by writing code.
- Executor: Execute the code.
- Scientist: Read the papers and write a summary.
The pipeline is the following:
- The planner interact with Admin (user) to revise a plan. Only when the Admin types “Approve”, we can move to the next step.
- The engineer will write code to retrieve papers from the internet. The code will be executed by executor.
- When the code is executed successfully, the scientist will read the papers and write a summary.
- The summary will be reviewed by the Admin and give comments. When the Admin types “TERMINATE”, the process will be terminated.