Add silent option in nested chats and group chat (#2712)

* feat: respect silent request in nested chats and group chat

* fix: address plugin test

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
This commit is contained in:
Rob
2024-05-22 13:39:37 -04:00
committed by GitHub
parent 918244e98e
commit fb74624376
2 changed files with 14 additions and 4 deletions

View File

@@ -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)

View File

@@ -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 groupchat
self._groupchat = groupchat
self._silent = silent
# 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)
@@ -992,6 +995,7 @@ class GroupChatManager(ConversableAgent):
speaker = sender
groupchat = config
send_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 = sender
groupchat = config
send_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: