Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fix groupchat #904

Merged
merged 7 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autogen/agentchat/groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _prepare_and_select_agents(self, last_speaker: Agent) -> Tuple[Optional[Agen
return agents[0], agents
elif not agents:
raise ValueError(
f"No agent can execute the function {self.messages[-1]['name']}. "
f"No agent can execute the function {self.messages[-1]['function_call']['name']}. "
sonichi marked this conversation as resolved.
Show resolved Hide resolved
"Please check the function_map of the agents."
)
# remove the last speaker from the list to avoid selecting the same speaker if allow_repeat_speaker is False
Expand Down
28 changes: 28 additions & 0 deletions test/agentchat/test_function_call_groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,33 @@ def get_random_number():
user_proxy.initiate_chat(manager, message="Let's start the game!")


def test_no_function_map():
dummy1 = autogen.UserProxyAgent(
name="User_proxy",
system_message="A human admin that will execute function_calls.",
human_input_mode="NEVER",
)

dummy2 = autogen.UserProxyAgent(
name="User_proxy",
system_message="A human admin that will execute function_calls.",
human_input_mode="NEVER",
)
groupchat = autogen.GroupChat(agents=[dummy1, dummy2], messages=[], max_round=7)
groupchat.messages = [
{
"role": "assistant",
"content": None,
"function_call": {"name": "get_random_number", "arguments": "{}"},
}
]
with pytest.raises(
ValueError,
match="No agent can execute the function get_random_number. Please check the function_map of the agents.",
):
groupchat._prepare_and_select_agents(dummy2)


if __name__ == "__main__":
test_function_call_groupchat()
test_no_function_map()
Loading