add more components in pipeline

This commit is contained in:
yzlin 2023-11-24 14:05:11 +08:00
parent 3d18dfe2b5
commit fdef9c8547
7 changed files with 82 additions and 41 deletions

View file

@ -1,12 +1,12 @@
import pytest
from metagpt.actions.write_code_function import WriteCodeFunction
from metagpt.actions.write_analysis_code import WriteCodeByGenerate
from metagpt.actions.execute_code import ExecutePyCode
@pytest.mark.asyncio
async def test_write_code():
write_code = WriteCodeFunction()
write_code = WriteCodeByGenerate()
code = await write_code.run("Write a hello world code.")
assert "language" in code.content
assert "code" in code.content
@ -15,7 +15,7 @@ async def test_write_code():
@pytest.mark.asyncio
async def test_write_code_by_list_prompt():
write_code = WriteCodeFunction()
write_code = WriteCodeByGenerate()
msg = ["a=[1,2,5,10,-10]", "写出求a中最大值的代码python"]
code = await write_code.run(msg)
assert "language" in code.content
@ -25,7 +25,7 @@ async def test_write_code_by_list_prompt():
@pytest.mark.asyncio
async def test_write_code_by_list_plan():
write_code = WriteCodeFunction()
write_code = WriteCodeByGenerate()
execute_code = ExecutePyCode()
messages = []
plan = ["随机生成一个pandas DataFrame时间序列", "绘制这个时间序列的直方图", "求均值"]

View file

@ -24,7 +24,7 @@ def test_messages():
class TestPlan:
def test_add_tasks_ordering(self):
plan = Plan()
plan = Plan(goal="")
tasks = [
Task(task_id="1", dependent_task_ids=["2", "3"], instruction="Third"),
@ -36,7 +36,7 @@ class TestPlan:
assert [task.task_id for task in plan.tasks] == ["2", "3", "1"]
def test_add_tasks_to_existing_no_common_prefix(self):
plan = Plan()
plan = Plan(goal="")
tasks = [
Task(task_id="1", dependent_task_ids=["2", "3"], instruction="Third"),
@ -52,7 +52,7 @@ class TestPlan:
assert not plan.tasks[0].is_finished # must be the new unfinished task
def test_add_tasks_to_existing_with_common_prefix(self):
plan = Plan()
plan = Plan(goal="")
tasks = [
Task(task_id="1", dependent_task_ids=["2", "3"], instruction="Third"),
@ -75,7 +75,7 @@ class TestPlan:
assert plan.current_task_id == "4"
def test_current_task(self):
plan = Plan()
plan = Plan(goal="")
tasks = [
Task(task_id="1", dependent_task_ids=["2"], instruction="Second"),
Task(task_id="2", instruction="First")
@ -84,7 +84,7 @@ class TestPlan:
assert plan.current_task.task_id == "2"
def test_finish_task(self):
plan = Plan()
plan = Plan(goal="")
tasks = [
Task(task_id="1", instruction="First"),
Task(task_id="2", dependent_task_ids=["1"], instruction="Second")
@ -94,7 +94,7 @@ class TestPlan:
assert plan.current_task.task_id == "2"
def test_finished_tasks(self):
plan = Plan()
plan = Plan(goal="")
tasks = [
Task(task_id="1", instruction="First"),
Task(task_id="2", dependent_task_ids=["1"], instruction="Second")