Skip to content

Commit

Permalink
Added try except to execute
Browse files Browse the repository at this point in the history
  • Loading branch information
onuratakan committed Jun 11, 2024
1 parent ea1b7bf commit b0ef2f7
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions tiger/tools/interpreter/python/execute.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@


def execute(cell:str) -> str:
from IPython import get_ipython
try:
from IPython import get_ipython

ipython = get_ipython()
result = ipython.run_cell(cell)
log = str(result.result)
if result.error_before_exec is not None:
log += f"\n{result.error_before_exec}"
if result.error_in_exec is not None:
log += f"\n{result.error_in_exec}"
return log
ipython = get_ipython()
result = ipython.run_cell(cell)
log = str(result.result)
if result.error_before_exec is not None:
log += f"\n{result.error_before_exec}"
if result.error_in_exec is not None:
log += f"\n{result.error_in_exec}"
return log
except Exception as e:
return e


tool_name = "interpreter.python.execute"
tool_obj = execute
Expand Down

0 comments on commit b0ef2f7

Please sign in to comment.