mirror of
https://github.com/hwchase17/langchain.git
synced 2026-02-21 22:56:05 +00:00
Harrison/tools exp (#372)
This commit is contained in:
@@ -16,7 +16,11 @@ class PythonREPL:
|
||||
"""Run command with own globals/locals and returns anything printed."""
|
||||
old_stdout = sys.stdout
|
||||
sys.stdout = mystdout = StringIO()
|
||||
exec(command, self._globals, self._locals)
|
||||
sys.stdout = old_stdout
|
||||
output = mystdout.getvalue()
|
||||
try:
|
||||
exec(command, self._globals, self._locals)
|
||||
sys.stdout = old_stdout
|
||||
output = mystdout.getvalue()
|
||||
except Exception as e:
|
||||
sys.stdout = old_stdout
|
||||
output = str(e)
|
||||
return output
|
||||
|
||||
Reference in New Issue
Block a user