🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
support multi write_code steps for one task
lidanyang4c4d9547ff55
diff --git a/metagpt/schema.py b/metagpt/schema.pyindex 11610b6c3..94e64d7fa 100644--- a/metagpt/schema.py+++ b/metagpt/schema.py@@ -464,8 +464,8 @@ class Task(BaseModel):self.is_finished = Falsedef update_task_result(self, task_result: TaskResult):- self.code = task_result.code + "\n" + task_result.code- self.result = task_result.result+ self.code = self.code + "\n" + task_result.code+ self.result = self.result + "\n" + task_result.resultself.is_success = task_result.is_successdiff --git a/metagpt/strategy/planner.py b/metagpt/strategy/planner.pyindex 427e41562..95ad1f5cc 100644--- a/metagpt/strategy/planner.py+++ b/metagpt/strategy/planner.py@@ -40,8 +40,14 @@ PLAN_STATUS = """## Current Task{current_task}+## Finished Section of Current Task+### code+{current_task_code}+### execution result+{current_task_result}+## Task Guidance-Write complete code for 'Current Task'. And avoid duplicating code from 'Finished Tasks', such as repeated import of packages, reading data, etc.+Write code for the incomplete sections of 'Current Task'. And avoid duplicating code from 'Finished Tasks', such as repeated import of packages, reading data, etc.Specifically, {guidance}"""@@ -173,6 +179,8 @@ class Planner(BaseModel):code_written=code_written,task_results=task_results,current_task=self.current_task.instruction,+ current_task_code=self.current_task.code if self.current_task.code else "",+ current_task_result=self.current_task.result if self.current_task.result else "",guidance=guidance,)diff --git a/metagpt/tools/tool_recommend.py b/metagpt/tools/tool_recommend.pyindex ab847d10e..0c596707a 100644--- a/metagpt/tools/tool_recommend.py+++ b/metagpt/tools/tool_recommend.py@@ -106,11 +106,11 @@ class ToolRecommender(BaseModel):Wrap recommended tools with their info in a string, which can be used directly in a prompt."""recommended_tools = await self.recommend_tools(**kwargs)+ if fix:+ recommended_tools.extend([self.tools[tool_name] for tool_name in fix if tool_name in self.tools])if not recommended_tools:return ""tool_schemas = {tool.name: tool.schemas for tool in recommended_tools}- if fix:- tool_schemas.update({tool.name: tool.schemas for tool in self.tools.values() if tool.name in fix})return TOOL_INFO_PROMPT.format(tool_schemas=tool_schemas)async def recall_tools(self, context: str = "", plan: Plan = None, topk: int = 20) -> list[Tool]: