Skip to content

Commit

Permalink
Raise error when function as llm_config passed to GroupChatManager (m…
Browse files Browse the repository at this point in the history
…icrosoft#911)

* fix groupchat selection

* update

* update notbooks

* update

* update
  • Loading branch information
yiranwu0 authored Dec 10, 2023
1 parent 0b90d79 commit d25c1db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
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

0 comments on commit d25c1db

Please sign in to comment.