mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
refine: add terminate in Interpreter instead of Role.
This commit is contained in:
parent
1e04e34103
commit
803359a758
3 changed files with 6 additions and 4 deletions
|
|
@ -58,7 +58,8 @@ class ExecuteNbCode(Action):
|
|||
|
||||
async def terminate(self):
|
||||
"""kill NotebookClient"""
|
||||
await self.nb_client._async_cleanup_kernel()
|
||||
if self.nb_client.km is not None:
|
||||
await self.nb_client._async_cleanup_kernel()
|
||||
|
||||
async def reset(self):
|
||||
"""reset NotebookClient"""
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ class Interpreter(Role):
|
|||
def working_memory(self):
|
||||
return self.rc.working_memory
|
||||
|
||||
async def _plan_and_act(self) -> Message:
|
||||
await super()._plan_and_act()
|
||||
await self.execute_code.terminate()
|
||||
|
||||
async def _act_on_task(self, current_task: Task) -> TaskResult:
|
||||
code, result, is_success = await self._write_and_exec_code()
|
||||
task_result = TaskResult(code=code, result=result, is_success=is_success)
|
||||
|
|
|
|||
|
|
@ -503,9 +503,6 @@ class Role(SerializationMixin, ContextMixin, BaseModel):
|
|||
|
||||
self.rc.memory.add(rsp) # add to persistent memory
|
||||
|
||||
if hasattr(self, "execute_code") and hasattr(self.execute_code, "terminate"):
|
||||
await self.execute_code.terminate()
|
||||
|
||||
return rsp
|
||||
|
||||
async def _act_on_task(self, current_task: Task) -> TaskResult:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue