Skip to content

Commit

Permalink
unrelated bug in memory where we weren't throwing an error on empty s…
Browse files Browse the repository at this point in the history
…tring for old_content
  • Loading branch information
cpacker committed Dec 21, 2023
1 parent 1e66f2b commit 7c882a2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions memgpt/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def edit_append(self, field, content, sep="\n"):
raise KeyError(f'No memory section named {field} (must be either "persona" or "human")')

def edit_replace(self, field, old_content, new_content):
if len(old_content) == 0:
raise ValueError("old_content cannot be an empty string (must specify old_content to replace)")

if field == "persona":
if old_content in self.persona:
new_persona = self.persona.replace(old_content, new_content)
Expand Down

0 comments on commit 7c882a2

Please sign in to comment.