From 207114af02af23a843a6a3d3b241f88bb609a610 Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 3 Jan 2025 19:46:18 +0530 Subject: [PATCH 1/2] Extract values from dict instead of copying and using dict in PostCarryoverProcessing --- autogen/messages/agent_messages.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/autogen/messages/agent_messages.py b/autogen/messages/agent_messages.py index e47bd6c889..84fe1110b9 100644 --- a/autogen/messages/agent_messages.py +++ b/autogen/messages/agent_messages.py @@ -256,18 +256,20 @@ class PostCarryoverProcessing(BaseMessage): max_turns: Optional[int] = None def __init__(self, *, uuid: Optional[UUID] = None, chat_info: dict[str, Any]): - # if "message" not in chat_info: - # chat_info["message"] = None + carryover = chat_info.get("carryover", "") + message = chat_info.get("message") + verbose = chat_info.get("verbose", False) - chat_info = deepcopy(chat_info) - sender_name = chat_info.pop("sender").name - recipient_name = chat_info.pop("recipient").name + sender_name = chat_info.get("sender").name # type: ignore [union-attr] + recipient_name = chat_info.get("recipient").name # type: ignore [union-attr] + summary_args = chat_info.get("summary_args", None) + max_turns = chat_info.get("max_turns", None) # Fix Callable in chat_info - if callable(chat_info.get("summary_method")): - chat_info["summary_method"] = chat_info["summary_method"].__name__ + summary_method = chat_info.get("summary_method", "") + if callable(summary_method): + summary_method = summary_method.__name__ - message = chat_info.get("message") print_message = "" if isinstance(message, str): print_message = message @@ -277,11 +279,15 @@ def __init__(self, *, uuid: Optional[UUID] = None, chat_info: dict[str, Any]): print_message = "Dict: " + str(message) elif message is None: print_message = "None" - chat_info["message"] = print_message super().__init__( uuid=uuid, - **chat_info, + carryover=carryover, + message=print_message, + verbose=verbose, + summary_method=summary_method, + summary_args=summary_args, + max_turns=max_turns, sender_name=sender_name, recipient_name=recipient_name, ) From 5bcf0ae6229748da90b813d2e86ceb4c98782349 Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 3 Jan 2025 19:49:17 +0530 Subject: [PATCH 2/2] Refactor getting agent names --- autogen/messages/agent_messages.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autogen/messages/agent_messages.py b/autogen/messages/agent_messages.py index 84fe1110b9..f9558984d0 100644 --- a/autogen/messages/agent_messages.py +++ b/autogen/messages/agent_messages.py @@ -260,8 +260,8 @@ def __init__(self, *, uuid: Optional[UUID] = None, chat_info: dict[str, Any]): message = chat_info.get("message") verbose = chat_info.get("verbose", False) - sender_name = chat_info.get("sender").name # type: ignore [union-attr] - recipient_name = chat_info.get("recipient").name # type: ignore [union-attr] + sender_name = chat_info["sender"].name + recipient_name = chat_info["recipient"].name summary_args = chat_info.get("summary_args", None) max_turns = chat_info.get("max_turns", None)