You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: autogen/agentchat/groupchat.py
+31-5
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,13 @@ class GroupChat:
28
28
When set to True and when a message is a function call suggestion,
29
29
the next speaker will be chosen from an agent which contains the corresponding function name
30
30
in its `function_map`.
31
+
- select_speaker_message_template: customize the select speaker message (used in "auto" speaker selection), which appears first in the message context and generally includes the agent descriptions and list of agents. The string value will be converted to an f-string, use "{roles}" to output the agent's and their role descriptions and "{agentlist}" for a comma-separated list of agent names in square brackets. The default value is:
32
+
"You are in a role play game. The following roles are available:
33
+
{roles}.
34
+
Read the following conversation.
35
+
Then select the next role from {agentlist} to play. Only return the role."
36
+
- select_speaker_prompt_template: customize the select speaker prompt (used in "auto" speaker selection), which appears last in the message context and generally includes the list of agents and guidance for the LLM to select the next agent. The string value will be converted to an f-string, use "{agentlist}" for a comma-separated list of agent names in square brackets. The default value is:
37
+
"Read the above conversation. Then select the next role from {agentlist} to play. Only return the role."
31
38
- speaker_selection_method: the method for selecting the next speaker. Default is "auto".
32
39
Could be any of the following (case insensitive), will raise ValueError if not recognized:
33
40
- "auto": the next speaker is selected automatically by LLM.
In this test, two agents are part of a group chat which has customized select speaker message and select speaker prompt templates. Both valid and empty string values will be used.
1247
+
The expected behaviour is that the customized speaker selection message and prompts will override the default values or throw exceptions if empty.
1248
+
"""
1249
+
1250
+
agent1=autogen.ConversableAgent(
1251
+
"Alice",
1252
+
description="A wonderful employee named Alice.",
1253
+
human_input_mode="NEVER",
1254
+
llm_config=False,
1255
+
)
1256
+
agent2=autogen.ConversableAgent(
1257
+
"Bob",
1258
+
description="An amazing employee named Bob.",
1259
+
human_input_mode="NEVER",
1260
+
llm_config=False,
1261
+
)
1262
+
1263
+
# Customised message, this is always the first message in the context
1264
+
custom_msg="""You are the CEO of a niche organisation creating small software tools for the healthcare sector with a small team of specialists. Call them in sequence.
1265
+
The job roles and responsibilities are:
1266
+
{roles}
1267
+
You must select only from {agentlist}."""
1268
+
1269
+
# Customised prompt, this is always the last message in the context
1270
+
custom_prompt="""Read the above conversation.
1271
+
Then select the next job role from {agentlist} to take action.
1272
+
RETURN ONLY THE NAME OF THE NEXT ROLE."""
1273
+
1274
+
# Test empty is_termination_msg function
1275
+
groupchat=autogen.GroupChat(
1276
+
agents=[agent1, agent2],
1277
+
messages=[],
1278
+
speaker_selection_method="auto",
1279
+
max_round=10,
1280
+
select_speaker_message_template=custom_msg,
1281
+
select_speaker_prompt_template=custom_prompt,
1282
+
)
1283
+
1284
+
# Test with valid strings, checking for the correct string and roles / agentlist to be included
0 commit comments