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 class names used in persistence manager logging #503

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Changes from all 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
36 changes: 18 additions & 18 deletions memgpt/persistence_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def save(self, filename):
pickle.dump(self, fh, protocol=pickle.HIGHEST_PROTOCOL)

def init(self, agent):
printd(f"Initializing InMemoryStateManager with agent object")
printd(f"Initializing {self.__class__.__name__} with agent object")
self.all_messages = [{"timestamp": get_local_time(), "message": msg} for msg in agent.messages.copy()]
self.messages = [{"timestamp": get_local_time(), "message": msg} for msg in agent.messages.copy()]
self.memory = agent.memory
Expand All @@ -77,28 +77,28 @@ def prepend_to_messages(self, added_messages):
# first tag with timestamps
added_messages = [{"timestamp": get_local_time(), "message": msg} for msg in added_messages]

printd(f"InMemoryStateManager.prepend_to_message")
printd(f"{self.__class__.__name__}.prepend_to_message")
self.messages = [self.messages[0]] + added_messages + self.messages[1:]
self.all_messages.extend(added_messages)

def append_to_messages(self, added_messages):
# first tag with timestamps
added_messages = [{"timestamp": get_local_time(), "message": msg} for msg in added_messages]

printd(f"InMemoryStateManager.append_to_messages")
printd(f"{self.__class__.__name__}.append_to_messages")
self.messages = self.messages + added_messages
self.all_messages.extend(added_messages)

def swap_system_message(self, new_system_message):
# first tag with timestamps
new_system_message = {"timestamp": get_local_time(), "message": new_system_message}

printd(f"InMemoryStateManager.swap_system_message")
printd(f"{self.__class__.__name__}.swap_system_message")
self.messages[0] = new_system_message
self.all_messages.append(new_system_message)

def update_memory(self, new_memory):
printd(f"InMemoryStateManager.update_memory")
printd(f"{self.__class__.__name__}.update_memory")
self.memory = new_memory


Expand Down Expand Up @@ -146,12 +146,12 @@ def save(self, filename):
printd(f"Saved state to {fh}")

def init(self, agent):
printd(f"Initializing InMemoryStateManager with agent object")
printd(f"Initializing {self.__class__.__name__} with agent object")
self.all_messages = [{"timestamp": get_local_time(), "message": msg} for msg in agent.messages.copy()]
self.messages = [{"timestamp": get_local_time(), "message": msg} for msg in agent.messages.copy()]
self.memory = agent.memory
printd(f"InMemoryStateManager.all_messages.len = {len(self.all_messages)}")
printd(f"InMemoryStateManager.messages.len = {len(self.messages)}")
printd(f"{self.__class__.__name__}.all_messages.len = {len(self.all_messages)}")
printd(f"{self.__class__.__name__}.messages.len = {len(self.messages)}")

# Persistence manager also handles DB-related state
self.recall_memory = self.recall_memory_cls(message_database=self.all_messages)
Expand All @@ -166,28 +166,28 @@ def prepend_to_messages(self, added_messages):
# first tag with timestamps
added_messages = [{"timestamp": get_local_time(), "message": msg} for msg in added_messages]

printd(f"InMemoryStateManager.prepend_to_message")
printd(f"{self.__class__.__name__}.prepend_to_message")
self.messages = [self.messages[0]] + added_messages + self.messages[1:]
self.all_messages.extend(added_messages)

def append_to_messages(self, added_messages):
# first tag with timestamps
added_messages = [{"timestamp": get_local_time(), "message": msg} for msg in added_messages]

printd(f"InMemoryStateManager.append_to_messages")
printd(f"{self.__class__.__name__}.append_to_messages")
self.messages = self.messages + added_messages
self.all_messages.extend(added_messages)

def swap_system_message(self, new_system_message):
# first tag with timestamps
new_system_message = {"timestamp": get_local_time(), "message": new_system_message}

printd(f"InMemoryStateManager.swap_system_message")
printd(f"{self.__class__.__name__}.swap_system_message")
self.messages[0] = new_system_message
self.all_messages.append(new_system_message)

def update_memory(self, new_memory):
printd(f"InMemoryStateManager.update_memory")
printd(f"{self.__class__.__name__}.update_memory")
self.memory = new_memory


Expand All @@ -199,12 +199,12 @@ def __init__(self, archival_memory_db):
self.archival_memory_db = archival_memory_db

def init(self, agent):
print(f"Initializing InMemoryStateManager with agent object")
print(f"Initializing {self.__class__.__name__} with agent object")
self.all_messages = [{"timestamp": get_local_time(), "message": msg} for msg in agent.messages.copy()]
self.messages = [{"timestamp": get_local_time(), "message": msg} for msg in agent.messages.copy()]
self.memory = agent.memory
print(f"InMemoryStateManager.all_messages.len = {len(self.all_messages)}")
print(f"InMemoryStateManager.messages.len = {len(self.messages)}")
print(f"{self.__class__.__name__}.all_messages.len = {len(self.all_messages)}")
print(f"{self.__class__.__name__}.messages.len = {len(self.messages)}")
self.recall_memory = self.recall_memory_cls(message_database=self.all_messages)
self.archival_memory = self.archival_memory_cls(archival_memory_database=self.archival_memory_db)

Expand All @@ -228,12 +228,12 @@ def save(self, _filename):
raise NotImplementedError

def init(self, agent):
print(f"Initializing InMemoryStateManager with agent object")
print(f"Initializing {self.__class__.__name__} with agent object")
self.all_messages = [{"timestamp": get_local_time(), "message": msg} for msg in agent.messages.copy()]
self.messages = [{"timestamp": get_local_time(), "message": msg} for msg in agent.messages.copy()]
self.memory = agent.memory
print(f"InMemoryStateManager.all_messages.len = {len(self.all_messages)}")
print(f"InMemoryStateManager.messages.len = {len(self.messages)}")
print(f"{self.__class__.__name__}.all_messages.len = {len(self.all_messages)}")
print(f"{self.__class__.__name__}.messages.len = {len(self.messages)}")

# Persistence manager also handles DB-related state
self.recall_memory = self.recall_memory_cls(message_database=self.all_messages)
Expand Down
Loading