From 72b7d76d79b0e187426787616d96257b64292119 Mon Sep 17 00:00:00 2001 From: ProxyCausal <40151648+ProxyCausal@users.noreply.github.com> Date: Wed, 19 Apr 2023 01:45:06 -0400 Subject: [PATCH] Print exception type for Python tool (#3126) Useful for debugging agents e.g. KeyError in addition to just printing the missing key --- langchain/tools/python/tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain/tools/python/tool.py b/langchain/tools/python/tool.py index 81339ced..607fec22 100644 --- a/langchain/tools/python/tool.py +++ b/langchain/tools/python/tool.py @@ -89,7 +89,7 @@ class PythonAstREPLTool(BaseTool): output = str(e) return output except Exception as e: - return str(e) + return "{}: {}".format(type(e).__name__, str(e)) async def _arun(self, query: str) -> str: """Use the tool asynchronously."""