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

Raise error when function as llm_config passed to GroupChatManager #911

Merged
merged 9 commits into from
Dec 10, 2023
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
5 changes: 5 additions & 0 deletions autogen/agentchat/groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ def __init__(
system_message: Optional[Union[str, List]] = "Group chat manager.",
**kwargs,
):
if kwargs.get("llm_config") and (kwargs["llm_config"].get("functions") or kwargs["llm_config"].get("tools")):
raise ValueError(
"GroupChatManager is not allowed to make function/tool calls. Please remove the 'functions' or 'tools' config in 'llm_config' you passed in."
)

super().__init__(
name=name,
max_consecutive_auto_reply=max_consecutive_auto_reply,
Expand Down
5 changes: 4 additions & 1 deletion notebook/agentchat_groupchat_RAG.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@
" speaker_selection_method=\"random\",\n",
" allow_repeat_speaker=False,\n",
" )\n",
" manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)\n",
"\n",
" manager_llm_config = llm_config.copy()\n",
" manager_llm_config.pop(\"functions\")\n",
" manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=manager_llm_config)\n",
"\n",
" # Start chatting with the boss as this is the user proxy agent.\n",
" boss.initiate_chat(\n",
Expand Down
13 changes: 12 additions & 1 deletion test/agentchat/test_function_call_groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,18 @@ def get_random_number():
llm_config=llm_config,
)
groupchat = autogen.GroupChat(agents=[user_proxy, coder], messages=[], max_round=7)
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)

# pass in llm_config with functions
with pytest.raises(
ValueError,
match="GroupChatManager is not allowed to make function/tool calls. Please remove the 'functions' or 'tools' config in 'llm_config' you passed in.",
):
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)

# pass in llm_config without functions
llm_config_manager = llm_config.copy()
del llm_config_manager["functions"]
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config_manager)

user_proxy.initiate_chat(manager, message="Let's start the game!")

Expand Down
Loading