general planner, code interpreter

This commit is contained in:
yzlin 2023-12-28 20:17:33 +08:00
parent fe6e46d478
commit db4e3343f1
13 changed files with 338 additions and 311 deletions

View file

@ -2,8 +2,14 @@ import pytest
from tqdm import tqdm
from metagpt.logs import logger
from metagpt.roles.ml_engineer import MLEngineer
from metagpt.schema import Plan
from metagpt.roles.ml_engineer import MLEngineer, ExecutePyCode
def reset(role):
"""Restart role with the same goal."""
role.working_memory.clear()
role.planner.plan = Plan(goal=role.planner.plan.goal)
role.execute_code = ExecutePyCode()
async def make_use_tools(requirement: str, auto_run: bool = True):
"""make and use tools for requirement."""
@ -15,7 +21,7 @@ async def make_use_tools(requirement: str, auto_run: bool = True):
role.use_udfs = False
await role.run(requirement)
# use udfs
role.reset()
reset(role)
role.make_udfs = False
role.use_udfs = True
role.use_code_steps = False

View file

@ -141,7 +141,8 @@ class TestPlan:
task = Task(task_id="1", instruction="First Task")
plan.add_tasks([task])
new_task = Task(task_id="2", instruction="New Task")
plan.replace_task(new_task) # Task with ID 2 does not exist in plan
with pytest.raises(AssertionError):
plan.replace_task(new_task) # Task with ID 2 does not exist in plan
assert "1" in plan.task_map
assert "2" not in plan.task_map