From 8202c0f5434655ed97665e95e2e3305756769f3d Mon Sep 17 00:00:00 2001 From: Vivian Fang Date: Mon, 6 Nov 2023 15:32:58 -0800 Subject: [PATCH] Better error message printing for function call failing (#291) * Better error message printing for function call failing * only one import traceback * don't forward entire stack trace to memgpt --- memgpt/agent.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/memgpt/agent.py b/memgpt/agent.py index 048134dc45..ecf13e86e1 100644 --- a/memgpt/agent.py +++ b/memgpt/agent.py @@ -8,6 +8,7 @@ import requests import json import threading +import traceback import openai from memgpt.persistence_manager import LocalStateManager @@ -568,7 +569,8 @@ def handle_ai_response(self, response_message): function_failed = False except Exception as e: error_msg = f"Error calling function {function_name} with args {function_args}: {str(e)}" - printd(error_msg) + error_msg_user = f"{error_msg}\n{traceback.format_exc()}" + printd(error_msg_user) function_response = package_function_response(False, error_msg) messages.append( { @@ -996,7 +998,8 @@ async def handle_ai_response(self, response_message): function_failed = False except Exception as e: error_msg = f"Error calling function {function_name} with args {function_args}: {str(e)}" - printd(error_msg) + error_msg_user = f"{error_msg}\n{traceback.format_exc()}" + printd(error_msg_user) function_response = package_function_response(False, error_msg) messages.append( {