mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-02 14:45:17 +02:00
support multi write_code steps for one task
This commit is contained in:
parent
32fc276245
commit
4c4d9547ff
3 changed files with 13 additions and 5 deletions
|
|
@ -464,8 +464,8 @@ class Task(BaseModel):
|
|||
self.is_finished = False
|
||||
|
||||
def 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.result
|
||||
self.is_success = task_result.is_success
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue