Merge branch 'code_intepreter' into sd_and_debugcode_ut

This commit is contained in:
stellahsr 2024-01-12 16:58:05 +08:00
commit 192e2aa807
13 changed files with 180 additions and 855 deletions

View file

@ -1,4 +1,12 @@
from metagpt.actions.write_plan import Plan, Task, precheck_update_plan_from_rsp
import pytest
from metagpt.actions.write_plan import (
Plan,
Task,
WritePlan,
precheck_update_plan_from_rsp,
)
from metagpt.schema import Message
def test_precheck_update_plan_from_rsp():
@ -12,3 +20,12 @@ def test_precheck_update_plan_from_rsp():
invalid_rsp = "wrong"
success, _ = precheck_update_plan_from_rsp(invalid_rsp, plan)
assert not success
@pytest.mark.asyncio
async def test_write_plan():
rsp = await WritePlan().run(context=[Message("run analysis on sklearn iris dataset", role="user")])
assert "task_id" in rsp
assert "instruction" in rsp
assert "json" not in rsp # the output should be the content inside ```json ```

View file

@ -0,0 +1,13 @@
import pytest
from metagpt.logs import logger
from metagpt.roles.code_interpreter import CodeInterpreter
@pytest.mark.asyncio
async def test_code_interpreter():
requirement = "Run data analysis on sklearn Iris dataset, include a plot"
ci = CodeInterpreter(goal=requirement, auto_run=True, use_tools=False)
rsp = await ci.run(requirement)
logger.info(rsp)
assert len(rsp.content) > 0