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

Clean memory error messages #523

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion memgpt/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,14 @@ def handle_ai_response(self, response_message):
try:
function_args["self"] = self # need to attach self to arg since it's dynamically linked
function_response_string = function_to_call(**function_args)
function_args.pop("self", None)
function_response = package_function_response(True, function_response_string)
function_failed = False
except Exception as e:
error_msg = f"Error calling function {function_name} with args {function_args}: {str(e)}"
function_args.pop("self", None)
# error_msg = f"Error calling function {function_name} with args {function_args}: {str(e)}"
# Less detailed - don't provide full args, idea is that it should be in recent context so no need (just adds noise)
error_msg = f"Error calling function {function_name}: {str(e)}"
error_msg_user = f"{error_msg}\n{traceback.format_exc()}"
printd(error_msg_user)
function_response = package_function_response(False, error_msg)
Expand Down
6 changes: 3 additions & 3 deletions memgpt/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def edit(self, field, content):
elif field == "human":
return self.edit_human(content)
else:
raise KeyError
raise KeyError(f'No memory section named {field} (must be either "persona" or "human")')

def edit_append(self, field, content, sep="\n"):
if field == "persona":
Expand All @@ -96,7 +96,7 @@ def edit_append(self, field, content, sep="\n"):
new_content = self.human + sep + content
return self.edit_human(new_content)
else:
raise KeyError
raise KeyError(f'No memory section named {field} (must be either "persona" or "human")')

def edit_replace(self, field, old_content, new_content):
if field == "persona":
Expand All @@ -112,7 +112,7 @@ def edit_replace(self, field, old_content, new_content):
else:
raise ValueError("Content not found in human (make sure to use exact string)")
else:
raise KeyError
raise KeyError(f'No memory section named {field} (must be either "persona" or "human")')


def summarize_messages(
Expand Down