Skip to content

Commit fd84ef1

Browse files
authored
Raise error when function as llm_config passed to GroupChatManager (#911)
* fix groupchat selection * update * update notbooks * update * update
1 parent 70f4c1c commit fd84ef1

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

autogen/agentchat/groupchat.py

+5
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ def __init__(
286286
system_message: Optional[Union[str, List]] = "Group chat manager.",
287287
**kwargs,
288288
):
289+
if kwargs.get("llm_config") and (kwargs["llm_config"].get("functions") or kwargs["llm_config"].get("tools")):
290+
raise ValueError(
291+
"GroupChatManager is not allowed to make function/tool calls. Please remove the 'functions' or 'tools' config in 'llm_config' you passed in."
292+
)
293+
289294
super().__init__(
290295
name=name,
291296
max_consecutive_auto_reply=max_consecutive_auto_reply,

notebook/agentchat_groupchat_RAG.ipynb

+4-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,10 @@
292292
" speaker_selection_method=\"random\",\n",
293293
" allow_repeat_speaker=False,\n",
294294
" )\n",
295-
" manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)\n",
295+
"\n",
296+
" manager_llm_config = llm_config.copy()\n",
297+
" manager_llm_config.pop(\"functions\")\n",
298+
" manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=manager_llm_config)\n",
296299
"\n",
297300
" # Start chatting with the boss as this is the user proxy agent.\n",
298301
" boss.initiate_chat(\n",

test/agentchat/test_function_call_groupchat.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,18 @@ def get_random_number():
5454
llm_config=llm_config,
5555
)
5656
groupchat = autogen.GroupChat(agents=[user_proxy, coder], messages=[], max_round=7)
57-
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)
57+
58+
# pass in llm_config with functions
59+
with pytest.raises(
60+
ValueError,
61+
match="GroupChatManager is not allowed to make function/tool calls. Please remove the 'functions' or 'tools' config in 'llm_config' you passed in.",
62+
):
63+
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)
64+
65+
# pass in llm_config without functions
66+
llm_config_manager = llm_config.copy()
67+
del llm_config_manager["functions"]
68+
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config_manager)
5869

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

0 commit comments

Comments
 (0)