From c581158fa11414dd9755a6ea3875dcfb3fad3496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BC=9F=E9=9F=AC?= Date: Thu, 1 Aug 2024 10:23:38 +0800 Subject: [PATCH] =?UTF-8?q?planner=E6=B7=BB=E5=8A=A0=20finish=20crrent=20t?= =?UTF-8?q?ask=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/schema.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/metagpt/schema.py b/metagpt/schema.py index c716f8b2f..648e2bd73 100644 --- a/metagpt/schema.py +++ b/metagpt/schema.py @@ -657,6 +657,11 @@ class Plan(BaseModel): self.current_task.is_finished = True self._update_current_task() # set to next task + def finish_all_tasks(self): + "Finish all tasks." + while self.current_task: + self.finish_current_task() + def is_plan_finished(self) -> bool: """Check if all tasks are finished""" return all(task.is_finished for task in self.tasks) @@ -669,14 +674,16 @@ class Plan(BaseModel): """ return [task for task in self.tasks if task.is_finished] - def append_task(self, task_id: str, dependent_task_ids: list[str], instruction: str, assignee: str, task_type: str = ""): + def append_task( + self, task_id: str, dependent_task_ids: list[str], instruction: str, assignee: str, task_type: str = "" + ): """Append a new task with task_id (number) to the end of existing task sequences. If dependent_task_ids is not empty, the task will depend on the tasks with the ids in the list. Note that the assignee should be the 'name' of the role.""" new_task = Task( task_id=task_id, dependent_task_ids=dependent_task_ids, instruction=instruction, assignee=assignee, - task_type=task_type + task_type=task_type, ) return self._append_task(new_task)