Skip to content

Commit

Permalink
Merge pull request #344 from kumaranvpl/fix-messages
Browse files Browse the repository at this point in the history
Bug fix: Extract values from dict instead of copying dict in PostCaryoverProcessing
  • Loading branch information
davorrunje authored Jan 3, 2025
2 parents 12e9665 + 5bcf0ae commit 4d84d42
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions autogen/messages/agent_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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["sender"].name
recipient_name = chat_info["recipient"].name
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
Expand All @@ -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,
)
Expand Down

0 comments on commit 4d84d42

Please sign in to comment.