A programming framework for agentic AI
Add silent option in nested chats and group chat (#2712)
Robfb74624376fa
diff --git a/autogen/agentchat/chat.py b/autogen/agentchat/chat.pyindex b527f8e0b..dd489c036 100644--- a/autogen/agentchat/chat.py+++ b/autogen/agentchat/chat.py@@ -195,7 +195,9 @@ def initiate_chats(chat_queue: List[Dict[str, Any]]) -> List[ChatResult]:r.summary for i, r in enumerate(finished_chats) if i not in finished_chat_indexes_to_exclude_from_carryover]- __post_carryover_processing(chat_info)+ if not chat_info.get("silent", False):+ __post_carryover_processing(chat_info)+sender = chat_info["sender"]chat_res = sender.initiate_chat(**chat_info)finished_chats.append(chat_res)@@ -236,7 +238,10 @@ async def _dependent_chat_future(if isinstance(_chat_carryover, str):_chat_carryover = [_chat_carryover]chat_info["carryover"] = _chat_carryover + [finished_chats[pre_id].summary for pre_id in finished_chats]- __post_carryover_processing(chat_info)++ if not chat_info.get("silent", False):+ __post_carryover_processing(chat_info)+sender = chat_info["sender"]chat_res_future = asyncio.create_task(sender.a_initiate_chat(**chat_info))call_back_with_args = partial(_on_chat_future_done, chat_id=chat_id)diff --git a/autogen/agentchat/groupchat.py b/autogen/agentchat/groupchat.pyindex 8b782f7d6..a2bd6b856 100644--- a/autogen/agentchat/groupchat.py+++ b/autogen/agentchat/groupchat.py@@ -917,6 +917,7 @@ class GroupChatManager(ConversableAgent):max_consecutive_auto_reply: Optional[int] = sys.maxsize,human_input_mode: Optional[str] = "NEVER",system_message: Optional[Union[str, List]] = "Group chat manager.",+ silent: bool = False,**kwargs,):if (@@ -940,6 +941,8 @@ class GroupChatManager(ConversableAgent):# Store groupchatself._groupchat = groupchat+ self._silent = silent+# Order of register_reply is important.# Allow sync chat if initiated using initiate_chatself.register_reply(Agent, GroupChatManager.run_chat, config=groupchat, reset_config=GroupChat.reset)@@ -992,6 +995,7 @@ class GroupChatManager(ConversableAgent):speaker = sendergroupchat = configsend_introductions = getattr(groupchat, "send_introductions", False)+ silent = getattr(self, "_silent", False)if send_introductions:# Broadcast the intro@@ -1046,7 +1050,7 @@ class GroupChatManager(ConversableAgent):reply["content"] = self.clear_agents_history(reply, groupchat)# The speaker sends the message without requesting a reply- speaker.send(reply, self, request_reply=False)+ speaker.send(reply, self, request_reply=False, silent=silent)message = self.last_message(speaker)if self.client_cache is not None:for a in groupchat.agents:@@ -1067,6 +1071,7 @@ class GroupChatManager(ConversableAgent):speaker = sendergroupchat = configsend_introductions = getattr(groupchat, "send_introductions", False)+ silent = getattr(self, "_silent", False)if send_introductions:# Broadcast the intro@@ -1111,7 +1116,7 @@ class GroupChatManager(ConversableAgent):if reply is None:break# The speaker sends the message without requesting a reply- await speaker.a_send(reply, self, request_reply=False)+ await speaker.a_send(reply, self, request_reply=False, silent=silent)message = self.last_message(speaker)if self.client_cache is not None:for a in groupchat.agents: