From 993d181716775cfad867397112119aa895e75b92 Mon Sep 17 00:00:00 2001 From: Adam Fourney Date: Mon, 11 Dec 2023 22:08:32 -0800 Subject: [PATCH 1/7] Allow the GroupChatManager to send introductions. --- autogen/agentchat/groupchat.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/autogen/agentchat/groupchat.py b/autogen/agentchat/groupchat.py index c420d7b22044..f8c01e6feacf 100644 --- a/autogen/agentchat/groupchat.py +++ b/autogen/agentchat/groupchat.py @@ -91,6 +91,16 @@ def select_speaker_prompt(self, agents: List[Agent]) -> str: """Return the floating system prompt selecting the next speaker. This is always the *last* message in the context.""" return f"Read the above conversation. Then select the next role from {[agent.name for agent in agents]} to play. Only return the role." + def introductions_msg(self, agents: Optional[List[Agent]] = None) -> str: + """Return the system message for selecting the next speaker. This is always the *first* message in the context.""" + if agents is None: + agents = self.agents + + return f"""Hello everyone. We have assembled a great team today to answer questions and solve tasks. In attendance are: + +{self._participant_roles(agents)} +""" + def manual_select_speaker(self, agents: List[Agent]) -> Union[Agent, None]: """Manually select the next speaker.""" @@ -283,7 +293,8 @@ def __init__( # unlimited consecutive auto reply by default max_consecutive_auto_reply: Optional[int] = sys.maxsize, human_input_mode: Optional[str] = "NEVER", - system_message: Optional[Union[str, List]] = "Group chat manager.", + description: Optional[str] = "Group chat manager that helps to orchestrate conversations.", + send_introductions: Optional[bool] = False, **kwargs, ): if kwargs.get("llm_config") and (kwargs["llm_config"].get("functions") or kwargs["llm_config"].get("tools")): @@ -295,9 +306,12 @@ def __init__( name=name, max_consecutive_auto_reply=max_consecutive_auto_reply, human_input_mode=human_input_mode, - system_message=system_message, + description=description, **kwargs, ) + + self.send_introductions = send_introductions + # Order of register_reply is important. # Allow sync chat if initiated using initiate_chat self.register_reply(Agent, GroupChatManager.run_chat, config=groupchat, reset_config=GroupChat.reset) @@ -316,6 +330,14 @@ def run_chat( message = messages[-1] speaker = sender groupchat = config + + if self.send_introductions: + # Broadcast the intro + intro = {"role": "user", "name": self.name, "content": groupchat.intro_msg()} + for agent in groupchat.agents: + self.send(intro, agent, request_reply=False, silent=True) + groupchat.append(intro) + for i in range(groupchat.max_round): # set the name to speaker's name if the role is not function if message["role"] != "function": From 56445692a19f504b70524235e1ae6941b2751efc Mon Sep 17 00:00:00 2001 From: Adam Fourney Date: Mon, 11 Dec 2023 22:44:17 -0800 Subject: [PATCH 2/7] Fixed function name. --- autogen/agentchat/groupchat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen/agentchat/groupchat.py b/autogen/agentchat/groupchat.py index f8c01e6feacf..7764c39a57af 100644 --- a/autogen/agentchat/groupchat.py +++ b/autogen/agentchat/groupchat.py @@ -333,7 +333,7 @@ def run_chat( if self.send_introductions: # Broadcast the intro - intro = {"role": "user", "name": self.name, "content": groupchat.intro_msg()} + intro = {"role": "user", "name": self.name, "content": groupchat.introductions_msg()} for agent in groupchat.agents: self.send(intro, agent, request_reply=False, silent=True) groupchat.append(intro) From 0607bc411ffd10be9c8bab0d424af66d04ae01c7 Mon Sep 17 00:00:00 2001 From: Adam Fourney Date: Tue, 12 Dec 2023 13:50:44 -0800 Subject: [PATCH 3/7] Added test cases for sending introductions. --- autogen/agentchat/groupchat.py | 14 ++++- test/agentchat/test_groupchat.py | 99 +++++++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 3 deletions(-) diff --git a/autogen/agentchat/groupchat.py b/autogen/agentchat/groupchat.py index 7764c39a57af..daf926faf0ca 100644 --- a/autogen/agentchat/groupchat.py +++ b/autogen/agentchat/groupchat.py @@ -333,10 +333,11 @@ def run_chat( if self.send_introductions: # Broadcast the intro - intro = {"role": "user", "name": self.name, "content": groupchat.introductions_msg()} + intro = groupchat.introductions_msg() for agent in groupchat.agents: self.send(intro, agent, request_reply=False, silent=True) - groupchat.append(intro) + # NOTE: We do not also append to groupchat.messages, + # since groupchat handles its own introductions for i in range(groupchat.max_round): # set the name to speaker's name if the role is not function @@ -388,6 +389,15 @@ async def a_run_chat( message = messages[-1] speaker = sender groupchat = config + + if self.send_introductions: + # Broadcast the intro + intro = groupchat.introductions_msg() + for agent in groupchat.agents: + self.a_send(intro, agent, request_reply=False, silent=True) + # NOTE: We do not also append to groupchat.messages, + # since groupchat handles its own introductions + for i in range(groupchat.max_round): # set the name to speaker's name if the role is not function if message["role"] != "function": diff --git a/test/agentchat/test_groupchat.py b/test/agentchat/test_groupchat.py index 27fda1fd5249..93324a829c05 100644 --- a/test/agentchat/test_groupchat.py +++ b/test/agentchat/test_groupchat.py @@ -429,6 +429,102 @@ def test_next_agent(): assert groupchat.next_agent(agent4, [agent1, agent2, agent3]) == agent1 +def test_send_intros(): + agent1 = autogen.ConversableAgent( + "alice", + description="The first agent.", + max_consecutive_auto_reply=10, + human_input_mode="NEVER", + llm_config=False, + default_auto_reply="This is alice speaking. TERMINATE", + ) + agent2 = autogen.ConversableAgent( + "bob", + description="The second agent.", + max_consecutive_auto_reply=10, + human_input_mode="NEVER", + llm_config=False, + default_auto_reply="This is bob speaking. TERMINATE", + ) + agent3 = autogen.ConversableAgent( + "sam", + description="The third agent.", + max_consecutive_auto_reply=10, + human_input_mode="NEVER", + llm_config=False, + default_auto_reply="This is sam speaking. TERMINATE", + ) + agent4 = autogen.ConversableAgent( + "sally", + description="The fourth agent.", + max_consecutive_auto_reply=10, + human_input_mode="NEVER", + llm_config=False, + default_auto_reply="This is sally speaking. TERMINATE", + ) + + # Test empty is_termination_msg function + groupchat = autogen.GroupChat( + agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 + ) + + intro = groupchat.introductions_msg() + assert "The first agent." in intro + assert "The second agent." in intro + assert "The third agent." in intro + assert "The fourth agent." not in intro + + intro = groupchat.introductions_msg([agent1, agent2, agent4]) + assert "The first agent." in intro + assert "The second agent." in intro + assert "The third agent." not in intro + assert "The fourth agent." in intro + + groupchat = autogen.GroupChat( + agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 + ) + + group_chat_manager = autogen.GroupChatManager( + groupchat=groupchat, + llm_config=False, + send_introductions=True, + is_termination_msg=lambda x: x.get("content", "").rstrip().find("TERMINATE") >= 0, + ) + + group_chat_manager.initiate_chat(group_chat_manager, message="The initiating message.") + for a in [agent1, agent2, agent3]: + messages = agent1.chat_messages[group_chat_manager] + assert len(messages) == 3 + assert "The first agent." in messages[0]["content"] + assert "The second agent." in messages[0]["content"] + assert "The third agent." in messages[0]["content"] + assert "The initiating message." == messages[1]["content"] + assert messages[2]["content"] == agent1._default_auto_reply + + # Reset and start again + agent1.reset() + agent2.reset() + agent3.reset() + agent4.reset() + + groupchat2 = autogen.GroupChat( + agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 + ) + + group_chat_manager2 = autogen.GroupChatManager( + groupchat=groupchat2, + llm_config=False, + is_termination_msg=lambda x: x.get("content", "").rstrip().find("TERMINATE") >= 0, + ) + + group_chat_manager2.initiate_chat(group_chat_manager2, message="The initiating message.") + for a in [agent1, agent2, agent3]: + messages = agent1.chat_messages[group_chat_manager2] + assert len(messages) == 2 + assert "The initiating message." == messages[0]["content"] + assert messages[1]["content"] == agent1._default_auto_reply + + if __name__ == "__main__": # test_func_call_groupchat() # test_broadcast() @@ -438,4 +534,5 @@ def test_next_agent(): # test_n_agents_less_than_3() # test_agent_mentions() # test_termination() - test_next_agent() + # test_next_agent() + test_send_intros() From 5b4c39ddf71129c57a8d35bc381d7feb2a3ff85e Mon Sep 17 00:00:00 2001 From: Adam Fourney Date: Tue, 12 Dec 2023 14:46:14 -0800 Subject: [PATCH 4/7] Trying to sort out why remote pytest is failing. --- test/agentchat/test_groupchat.py | 174 ++++++++++++++++--------------- 1 file changed, 89 insertions(+), 85 deletions(-) diff --git a/test/agentchat/test_groupchat.py b/test/agentchat/test_groupchat.py index 93324a829c05..082a3e8aadc8 100644 --- a/test/agentchat/test_groupchat.py +++ b/test/agentchat/test_groupchat.py @@ -3,6 +3,7 @@ import builtins import autogen import json +import traceback def test_func_call_groupchat(): @@ -430,99 +431,102 @@ def test_next_agent(): def test_send_intros(): - agent1 = autogen.ConversableAgent( - "alice", - description="The first agent.", - max_consecutive_auto_reply=10, - human_input_mode="NEVER", - llm_config=False, - default_auto_reply="This is alice speaking. TERMINATE", - ) - agent2 = autogen.ConversableAgent( - "bob", - description="The second agent.", - max_consecutive_auto_reply=10, - human_input_mode="NEVER", - llm_config=False, - default_auto_reply="This is bob speaking. TERMINATE", - ) - agent3 = autogen.ConversableAgent( - "sam", - description="The third agent.", - max_consecutive_auto_reply=10, - human_input_mode="NEVER", - llm_config=False, - default_auto_reply="This is sam speaking. TERMINATE", - ) - agent4 = autogen.ConversableAgent( - "sally", - description="The fourth agent.", - max_consecutive_auto_reply=10, - human_input_mode="NEVER", - llm_config=False, - default_auto_reply="This is sally speaking. TERMINATE", - ) - - # Test empty is_termination_msg function - groupchat = autogen.GroupChat( - agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 - ) - - intro = groupchat.introductions_msg() - assert "The first agent." in intro - assert "The second agent." in intro - assert "The third agent." in intro - assert "The fourth agent." not in intro + try: + agent1 = autogen.ConversableAgent( + "alice", + description="The first agent.", + max_consecutive_auto_reply=10, + human_input_mode="NEVER", + llm_config=False, + default_auto_reply="This is alice speaking. TERMINATE", + ) + agent2 = autogen.ConversableAgent( + "bob", + description="The second agent.", + max_consecutive_auto_reply=10, + human_input_mode="NEVER", + llm_config=False, + default_auto_reply="This is bob speaking. TERMINATE", + ) + agent3 = autogen.ConversableAgent( + "sam", + description="The third agent.", + max_consecutive_auto_reply=10, + human_input_mode="NEVER", + llm_config=False, + default_auto_reply="This is sam speaking. TERMINATE", + ) + agent4 = autogen.ConversableAgent( + "sally", + description="The fourth agent.", + max_consecutive_auto_reply=10, + human_input_mode="NEVER", + llm_config=False, + default_auto_reply="This is sally speaking. TERMINATE", + ) - intro = groupchat.introductions_msg([agent1, agent2, agent4]) - assert "The first agent." in intro - assert "The second agent." in intro - assert "The third agent." not in intro - assert "The fourth agent." in intro + # Test empty is_termination_msg function + groupchat = autogen.GroupChat( + agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 + ) - groupchat = autogen.GroupChat( - agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 - ) + intro = groupchat.introductions_msg() + assert "The first agent." in intro + assert "The second agent." in intro + assert "The third agent." in intro + assert "The fourth agent." not in intro - group_chat_manager = autogen.GroupChatManager( - groupchat=groupchat, - llm_config=False, - send_introductions=True, - is_termination_msg=lambda x: x.get("content", "").rstrip().find("TERMINATE") >= 0, - ) + intro = groupchat.introductions_msg([agent1, agent2, agent4]) + assert "The first agent." in intro + assert "The second agent." in intro + assert "The third agent." not in intro + assert "The fourth agent." in intro - group_chat_manager.initiate_chat(group_chat_manager, message="The initiating message.") - for a in [agent1, agent2, agent3]: - messages = agent1.chat_messages[group_chat_manager] - assert len(messages) == 3 - assert "The first agent." in messages[0]["content"] - assert "The second agent." in messages[0]["content"] - assert "The third agent." in messages[0]["content"] - assert "The initiating message." == messages[1]["content"] - assert messages[2]["content"] == agent1._default_auto_reply + groupchat = autogen.GroupChat( + agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 + ) - # Reset and start again - agent1.reset() - agent2.reset() - agent3.reset() - agent4.reset() + group_chat_manager = autogen.GroupChatManager( + groupchat=groupchat, + llm_config=False, + send_introductions=True, + is_termination_msg=lambda x: x.get("content", "").rstrip().find("TERMINATE") >= 0, + ) - groupchat2 = autogen.GroupChat( - agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 - ) + group_chat_manager.initiate_chat(group_chat_manager, message="The initiating message.") + for a in [agent1, agent2, agent3]: + messages = agent1.chat_messages[group_chat_manager] + assert len(messages) == 3 + assert "The first agent." in messages[0]["content"] + assert "The second agent." in messages[0]["content"] + assert "The third agent." in messages[0]["content"] + assert "The initiating message." == messages[1]["content"] + assert messages[2]["content"] == agent1._default_auto_reply + + # Reset and start again + agent1.reset() + agent2.reset() + agent3.reset() + agent4.reset() + + groupchat2 = autogen.GroupChat( + agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 + ) - group_chat_manager2 = autogen.GroupChatManager( - groupchat=groupchat2, - llm_config=False, - is_termination_msg=lambda x: x.get("content", "").rstrip().find("TERMINATE") >= 0, - ) + group_chat_manager2 = autogen.GroupChatManager( + groupchat=groupchat2, + llm_config=False, + is_termination_msg=lambda x: x.get("content", "").rstrip().find("TERMINATE") >= 0, + ) - group_chat_manager2.initiate_chat(group_chat_manager2, message="The initiating message.") - for a in [agent1, agent2, agent3]: - messages = agent1.chat_messages[group_chat_manager2] - assert len(messages) == 2 - assert "The initiating message." == messages[0]["content"] - assert messages[1]["content"] == agent1._default_auto_reply + group_chat_manager2.initiate_chat(group_chat_manager2, message="The initiating message.") + for a in [agent1, agent2, agent3]: + messages = agent1.chat_messages[group_chat_manager2] + assert len(messages) == 2 + assert "The initiating message." == messages[0]["content"] + assert messages[1]["content"] == agent1._default_auto_reply + except AttributeError: + traceback.print_exc() if __name__ == "__main__": From ea36e1ff7b3dca288bf49ef0de4abb9d90936365 Mon Sep 17 00:00:00 2001 From: Adam Fourney Date: Tue, 12 Dec 2023 15:07:09 -0800 Subject: [PATCH 5/7] Fixed broken plugin behavior. --- autogen/agentchat/groupchat.py | 20 +++- test/agentchat/test_groupchat.py | 173 +++++++++++++++---------------- 2 files changed, 103 insertions(+), 90 deletions(-) diff --git a/autogen/agentchat/groupchat.py b/autogen/agentchat/groupchat.py index daf926faf0ca..4d8e2be3092e 100644 --- a/autogen/agentchat/groupchat.py +++ b/autogen/agentchat/groupchat.py @@ -331,7 +331,15 @@ def run_chat( speaker = sender groupchat = config - if self.send_introductions: + # To support plugin goupchat behavior (see test_plugin in test_groupchat.py) + # we need to get creative on how we check for this property and use duck typing. + send_introductions = False + try: + send_introductions = self.send_introductions + except AttributeError: + pass + + if send_introductions: # Broadcast the intro intro = groupchat.introductions_msg() for agent in groupchat.agents: @@ -390,7 +398,15 @@ async def a_run_chat( speaker = sender groupchat = config - if self.send_introductions: + # To support plugin goupchat behavior (see test_plugin in test_groupchat.py) + # we need to get creative on how we check for this property and use duck typing. + send_introductions = False + try: + send_introductions = self.send_introductions + except AttributeError: + pass + + if send_introductions: # Broadcast the intro intro = groupchat.introductions_msg() for agent in groupchat.agents: diff --git a/test/agentchat/test_groupchat.py b/test/agentchat/test_groupchat.py index 082a3e8aadc8..3ae099068f80 100644 --- a/test/agentchat/test_groupchat.py +++ b/test/agentchat/test_groupchat.py @@ -431,102 +431,99 @@ def test_next_agent(): def test_send_intros(): - try: - agent1 = autogen.ConversableAgent( - "alice", - description="The first agent.", - max_consecutive_auto_reply=10, - human_input_mode="NEVER", - llm_config=False, - default_auto_reply="This is alice speaking. TERMINATE", - ) - agent2 = autogen.ConversableAgent( - "bob", - description="The second agent.", - max_consecutive_auto_reply=10, - human_input_mode="NEVER", - llm_config=False, - default_auto_reply="This is bob speaking. TERMINATE", - ) - agent3 = autogen.ConversableAgent( - "sam", - description="The third agent.", - max_consecutive_auto_reply=10, - human_input_mode="NEVER", - llm_config=False, - default_auto_reply="This is sam speaking. TERMINATE", - ) - agent4 = autogen.ConversableAgent( - "sally", - description="The fourth agent.", - max_consecutive_auto_reply=10, - human_input_mode="NEVER", - llm_config=False, - default_auto_reply="This is sally speaking. TERMINATE", - ) + agent1 = autogen.ConversableAgent( + "alice", + description="The first agent.", + max_consecutive_auto_reply=10, + human_input_mode="NEVER", + llm_config=False, + default_auto_reply="This is alice speaking. TERMINATE", + ) + agent2 = autogen.ConversableAgent( + "bob", + description="The second agent.", + max_consecutive_auto_reply=10, + human_input_mode="NEVER", + llm_config=False, + default_auto_reply="This is bob speaking. TERMINATE", + ) + agent3 = autogen.ConversableAgent( + "sam", + description="The third agent.", + max_consecutive_auto_reply=10, + human_input_mode="NEVER", + llm_config=False, + default_auto_reply="This is sam speaking. TERMINATE", + ) + agent4 = autogen.ConversableAgent( + "sally", + description="The fourth agent.", + max_consecutive_auto_reply=10, + human_input_mode="NEVER", + llm_config=False, + default_auto_reply="This is sally speaking. TERMINATE", + ) - # Test empty is_termination_msg function - groupchat = autogen.GroupChat( - agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 - ) + # Test empty is_termination_msg function + groupchat = autogen.GroupChat( + agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 + ) - intro = groupchat.introductions_msg() - assert "The first agent." in intro - assert "The second agent." in intro - assert "The third agent." in intro - assert "The fourth agent." not in intro + intro = groupchat.introductions_msg() + assert "The first agent." in intro + assert "The second agent." in intro + assert "The third agent." in intro + assert "The fourth agent." not in intro - intro = groupchat.introductions_msg([agent1, agent2, agent4]) - assert "The first agent." in intro - assert "The second agent." in intro - assert "The third agent." not in intro - assert "The fourth agent." in intro + intro = groupchat.introductions_msg([agent1, agent2, agent4]) + assert "The first agent." in intro + assert "The second agent." in intro + assert "The third agent." not in intro + assert "The fourth agent." in intro - groupchat = autogen.GroupChat( - agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 - ) + groupchat = autogen.GroupChat( + agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 + ) - group_chat_manager = autogen.GroupChatManager( - groupchat=groupchat, - llm_config=False, - send_introductions=True, - is_termination_msg=lambda x: x.get("content", "").rstrip().find("TERMINATE") >= 0, - ) + group_chat_manager = autogen.GroupChatManager( + groupchat=groupchat, + llm_config=False, + send_introductions=True, + is_termination_msg=lambda x: x.get("content", "").rstrip().find("TERMINATE") >= 0, + ) - group_chat_manager.initiate_chat(group_chat_manager, message="The initiating message.") - for a in [agent1, agent2, agent3]: - messages = agent1.chat_messages[group_chat_manager] - assert len(messages) == 3 - assert "The first agent." in messages[0]["content"] - assert "The second agent." in messages[0]["content"] - assert "The third agent." in messages[0]["content"] - assert "The initiating message." == messages[1]["content"] - assert messages[2]["content"] == agent1._default_auto_reply - - # Reset and start again - agent1.reset() - agent2.reset() - agent3.reset() - agent4.reset() - - groupchat2 = autogen.GroupChat( - agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 - ) + group_chat_manager.initiate_chat(group_chat_manager, message="The initiating message.") + for a in [agent1, agent2, agent3]: + messages = agent1.chat_messages[group_chat_manager] + assert len(messages) == 3 + assert "The first agent." in messages[0]["content"] + assert "The second agent." in messages[0]["content"] + assert "The third agent." in messages[0]["content"] + assert "The initiating message." == messages[1]["content"] + assert messages[2]["content"] == agent1._default_auto_reply - group_chat_manager2 = autogen.GroupChatManager( - groupchat=groupchat2, - llm_config=False, - is_termination_msg=lambda x: x.get("content", "").rstrip().find("TERMINATE") >= 0, - ) + # Reset and start again + agent1.reset() + agent2.reset() + agent3.reset() + agent4.reset() + + groupchat2 = autogen.GroupChat( + agents=[agent1, agent2, agent3], messages=[], speaker_selection_method="round_robin", max_round=10 + ) + + group_chat_manager2 = autogen.GroupChatManager( + groupchat=groupchat2, + llm_config=False, + is_termination_msg=lambda x: x.get("content", "").rstrip().find("TERMINATE") >= 0, + ) - group_chat_manager2.initiate_chat(group_chat_manager2, message="The initiating message.") - for a in [agent1, agent2, agent3]: - messages = agent1.chat_messages[group_chat_manager2] - assert len(messages) == 2 - assert "The initiating message." == messages[0]["content"] - assert messages[1]["content"] == agent1._default_auto_reply - except AttributeError: - traceback.print_exc() + group_chat_manager2.initiate_chat(group_chat_manager2, message="The initiating message.") + for a in [agent1, agent2, agent3]: + messages = agent1.chat_messages[group_chat_manager2] + assert len(messages) == 2 + assert "The initiating message." == messages[0]["content"] + assert messages[1]["content"] == agent1._default_auto_reply if __name__ == "__main__": From fca9c6394806ade4ad8a4734289095de009b1064 Mon Sep 17 00:00:00 2001 From: afourney Date: Fri, 19 Jan 2024 16:21:58 -0800 Subject: [PATCH 6/7] Update autogen/agentchat/groupchat.py Co-authored-by: Chi Wang --- autogen/agentchat/groupchat.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/autogen/agentchat/groupchat.py b/autogen/agentchat/groupchat.py index 233af5fbe367..b8cf276774b9 100644 --- a/autogen/agentchat/groupchat.py +++ b/autogen/agentchat/groupchat.py @@ -373,11 +373,7 @@ def run_chat( # To support plugin goupchat behavior (see test_plugin in test_groupchat.py) # we need to get creative on how we check for this property and use duck typing. - send_introductions = False - try: - send_introductions = self.send_introductions - except AttributeError: - pass + send_introductions = getattr(self, "send_introductions", False) if send_introductions: # Broadcast the intro From 5e14de0ffe73421ce4fd11c3832b14fad39d9417 Mon Sep 17 00:00:00 2001 From: Adam Fourney Date: Fri, 19 Jan 2024 16:26:53 -0800 Subject: [PATCH 7/7] Updated as per Chi's suggestions. --- autogen/agentchat/groupchat.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/autogen/agentchat/groupchat.py b/autogen/agentchat/groupchat.py index b8cf276774b9..402dd974b1b6 100644 --- a/autogen/agentchat/groupchat.py +++ b/autogen/agentchat/groupchat.py @@ -371,8 +371,6 @@ def run_chat( speaker = sender groupchat = config - # To support plugin goupchat behavior (see test_plugin in test_groupchat.py) - # we need to get creative on how we check for this property and use duck typing. send_introductions = getattr(self, "send_introductions", False) if send_introductions: @@ -431,13 +429,7 @@ async def a_run_chat( speaker = sender groupchat = config - # To support plugin goupchat behavior (see test_plugin in test_groupchat.py) - # we need to get creative on how we check for this property and use duck typing. - send_introductions = False - try: - send_introductions = self.send_introductions - except AttributeError: - pass + send_introductions = getattr(self, "send_introductions", False) if send_introductions: # Broadcast the intro