Merge pull request #1141 from orange-crow/add_try_except_for_plan_and_act

add try_except for _plan_and_act in data_interpreter.
This commit is contained in:
Alexander Wu 2024-04-01 10:42:33 +08:00 committed by GitHub
commit ed53e1c8a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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."""