Skip to content

Commit a90cd30

Browse files
yiranwu0davorrunje
andauthored
Minor fix groupchat (microsoft#904)
* minor fix groupchat * update * update --------- Co-authored-by: Davor Runje <[email protected]>
1 parent e31a6fa commit a90cd30

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

autogen/agentchat/groupchat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def _prepare_and_select_agents(self, last_speaker: Agent) -> Tuple[Optional[Agen
170170
return agents[0], agents
171171
elif not agents:
172172
raise ValueError(
173-
f"No agent can execute the function {self.messages[-1]['name']}. "
173+
f"No agent can execute the function {self.messages[-1]['function_call']['name']}. "
174174
"Please check the function_map of the agents."
175175
)
176176
# remove the last speaker from the list to avoid selecting the same speaker if allow_repeat_speaker is False

test/agentchat/test_function_call_groupchat.py

+28
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,33 @@ def get_random_number():
7171
user_proxy.initiate_chat(manager, message="Let's start the game!")
7272

7373

74+
def test_no_function_map():
75+
dummy1 = autogen.UserProxyAgent(
76+
name="User_proxy",
77+
system_message="A human admin that will execute function_calls.",
78+
human_input_mode="NEVER",
79+
)
80+
81+
dummy2 = autogen.UserProxyAgent(
82+
name="User_proxy",
83+
system_message="A human admin that will execute function_calls.",
84+
human_input_mode="NEVER",
85+
)
86+
groupchat = autogen.GroupChat(agents=[dummy1, dummy2], messages=[], max_round=7)
87+
groupchat.messages = [
88+
{
89+
"role": "assistant",
90+
"content": None,
91+
"function_call": {"name": "get_random_number", "arguments": "{}"},
92+
}
93+
]
94+
with pytest.raises(
95+
ValueError,
96+
match="No agent can execute the function get_random_number. Please check the function_map of the agents.",
97+
):
98+
groupchat._prepare_and_select_agents(dummy2)
99+
100+
74101
if __name__ == "__main__":
75102
test_function_call_groupchat()
103+
test_no_function_map()

0 commit comments

Comments
 (0)