A programming framework for agentic AI
Raise error when function as llm_config passed to GroupChatManager (#911)
Yiran Wufd84ef197051
diff --git a/autogen/agentchat/groupchat.py b/autogen/agentchat/groupchat.pyindex eb2dde730..c420d7b22 100644--- a/autogen/agentchat/groupchat.py+++ b/autogen/agentchat/groupchat.py@@ -286,6 +286,11 @@ class GroupChatManager(ConversableAgent):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,diff --git a/notebook/agentchat_groupchat_RAG.ipynb b/notebook/agentchat_groupchat_RAG.ipynbindex 9355d8343..c68b31819 100644--- a/notebook/agentchat_groupchat_RAG.ipynb+++ b/notebook/agentchat_groupchat_RAG.ipynb@@ -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",diff --git a/test/agentchat/test_function_call_groupchat.py b/test/agentchat/test_function_call_groupchat.pyindex 484149035..d8fdf30d3 100644--- a/test/agentchat/test_function_call_groupchat.py+++ b/test/agentchat/test_function_call_groupchat.py@@ -54,7 +54,18 @@ def test_function_call_groupchat():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!")