add try_except for _plan_and_act in data_interpreter.

This commit is contained in:
刘棒棒 2024-03-30 18:52:53 +08:00
parent fdf53ac555
commit 5255be144e

View file

@ -86,9 +86,13 @@ class DataInterpreter(Role):
return Message(content=code, role="assistant", cause_by=WriteAnalysisCode)
async def _plan_and_act(self) -> Message:
rsp = await super()._plan_and_act()
await self.execute_code.terminate()
return rsp
try:
rsp = await super()._plan_and_act()
await self.execute_code.terminate()
return rsp
except Exception as e:
await self.execute_code.terminate()
raise e
async def _act_on_task(self, current_task: Task) -> TaskResult:
"""Useful in 'plan_and_act' mode. Wrap the output in a TaskResult for review and confirmation."""