Skip to content

Commit dab7f4c

Browse files
robrauxsonichiekzhu
authored andcommitted
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 <[email protected]> Co-authored-by: Eric Zhu <[email protected]>
1 parent 7e203a9 commit dab7f4c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

autogen/agentchat/chat.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ def initiate_chats(chat_queue: List[Dict[str, Any]]) -> List[ChatResult]:
195195
r.summary for i, r in enumerate(finished_chats) if i not in finished_chat_indexes_to_exclude_from_carryover
196196
]
197197

198-
__post_carryover_processing(chat_info)
198+
if not chat_info.get("silent", False):
199+
__post_carryover_processing(chat_info)
200+
199201
sender = chat_info["sender"]
200202
chat_res = sender.initiate_chat(**chat_info)
201203
finished_chats.append(chat_res)
@@ -236,7 +238,10 @@ async def _dependent_chat_future(
236238
if isinstance(_chat_carryover, str):
237239
_chat_carryover = [_chat_carryover]
238240
chat_info["carryover"] = _chat_carryover + [finished_chats[pre_id].summary for pre_id in finished_chats]
239-
__post_carryover_processing(chat_info)
241+
242+
if not chat_info.get("silent", False):
243+
__post_carryover_processing(chat_info)
244+
240245
sender = chat_info["sender"]
241246
chat_res_future = asyncio.create_task(sender.a_initiate_chat(**chat_info))
242247
call_back_with_args = partial(_on_chat_future_done, chat_id=chat_id)

autogen/agentchat/groupchat.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ def __init__(
917917
max_consecutive_auto_reply: Optional[int] = sys.maxsize,
918918
human_input_mode: Optional[str] = "NEVER",
919919
system_message: Optional[Union[str, List]] = "Group chat manager.",
920+
silent: bool = False,
920921
**kwargs,
921922
):
922923
if (
@@ -940,6 +941,8 @@ def __init__(
940941
# Store groupchat
941942
self._groupchat = groupchat
942943

944+
self._silent = silent
945+
943946
# Order of register_reply is important.
944947
# Allow sync chat if initiated using initiate_chat
945948
self.register_reply(Agent, GroupChatManager.run_chat, config=groupchat, reset_config=GroupChat.reset)
@@ -992,6 +995,7 @@ def run_chat(
992995
speaker = sender
993996
groupchat = config
994997
send_introductions = getattr(groupchat, "send_introductions", False)
998+
silent = getattr(self, "_silent", False)
995999

9961000
if send_introductions:
9971001
# Broadcast the intro
@@ -1046,7 +1050,7 @@ def run_chat(
10461050
reply["content"] = self.clear_agents_history(reply, groupchat)
10471051

10481052
# The speaker sends the message without requesting a reply
1049-
speaker.send(reply, self, request_reply=False)
1053+
speaker.send(reply, self, request_reply=False, silent=silent)
10501054
message = self.last_message(speaker)
10511055
if self.client_cache is not None:
10521056
for a in groupchat.agents:
@@ -1067,6 +1071,7 @@ async def a_run_chat(
10671071
speaker = sender
10681072
groupchat = config
10691073
send_introductions = getattr(groupchat, "send_introductions", False)
1074+
silent = getattr(self, "_silent", False)
10701075

10711076
if send_introductions:
10721077
# Broadcast the intro
@@ -1111,7 +1116,7 @@ async def a_run_chat(
11111116
if reply is None:
11121117
break
11131118
# The speaker sends the message without requesting a reply
1114-
await speaker.a_send(reply, self, request_reply=False)
1119+
await speaker.a_send(reply, self, request_reply=False, silent=silent)
11151120
message = self.last_message(speaker)
11161121
if self.client_cache is not None:
11171122
for a in groupchat.agents:

0 commit comments

Comments
 (0)