Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add silent option in nested chats and group chat #2712

Merged
merged 4 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions autogen/agentchat/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions autogen/agentchat/groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ def __init__(
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 (
Expand All @@ -940,6 +941,8 @@ def __init__(
# 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)
Expand Down Expand Up @@ -992,6 +995,7 @@ def run_chat(
speaker = sender
groupchat = config
send_introductions = getattr(groupchat, "send_introductions", False)
silent = getattr(self, "_silent", False)
ekzhu marked this conversation as resolved.
Show resolved Hide resolved

if send_introductions:
# Broadcast the intro
Expand Down Expand Up @@ -1046,7 +1050,7 @@ def run_chat(
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:
Expand All @@ -1067,6 +1071,7 @@ async def a_run_chat(
speaker = sender
groupchat = config
send_introductions = getattr(groupchat, "send_introductions", False)
silent = getattr(self, "_silent", False)

if send_introductions:
# Broadcast the intro
Expand Down Expand Up @@ -1111,7 +1116,7 @@ async def a_run_chat(
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:
Expand Down
Loading