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

Fix side effects on message history #3619

Merged
merged 4 commits into from
May 1, 2023
Merged
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
10 changes: 6 additions & 4 deletions autogpt/memory_management/summary_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ def update_running_summary(current_memory: str, new_events: List[Dict]) -> str:
update_running_summary(new_events)
# Returns: "This reminds you of these events from your past: \nI entered the kitchen and found a scrawled note saying 7."
"""
# Create a copy of the new_events list to prevent modifying the original list
updated_new_events = new_events.copy()

# Replace "assistant" with "you". This produces much better first person past tense results.
for event in new_events:
for event in updated_new_events:
if event["role"].lower() == "assistant":
event["role"] = "you"
# Remove "thoughts" dictionary from "content"
Expand All @@ -74,8 +77,7 @@ def update_running_summary(current_memory: str, new_events: List[Dict]) -> str:
event["role"] = "your computer"
# Delete all user messages
elif event["role"] == "user":
new_events.remove(event)

updated_new_events.remove(event)
# This can happen at any point during execturion, not just the beginning
if len(new_events) == 0:
new_events = "Nothing new happened."
Expand All @@ -91,7 +93,7 @@ def update_running_summary(current_memory: str, new_events: List[Dict]) -> str:

Latest Development:
"""
{new_events}
{updated_new_events}
"""
'''

Expand Down