mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-05 14:55:18 +02:00
update ActionOutput.create_model_class to ActionNode.create_model_class
This commit is contained in:
parent
17087533bb
commit
3f0f008690
7 changed files with 16 additions and 21 deletions
|
|
@ -4,7 +4,7 @@
|
|||
# @Desc :
|
||||
import pytest
|
||||
|
||||
from metagpt.actions import Action, WriteTest
|
||||
from metagpt.actions import Action
|
||||
from metagpt.llm import LLM
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import shutil
|
||||
|
||||
from metagpt.actions.action_output import ActionOutput
|
||||
from metagpt.actions.action_node import ActionNode
|
||||
from metagpt.actions.add_requirement import UserRequirement
|
||||
from metagpt.actions.project_management import WriteTasks
|
||||
from metagpt.environment import Environment
|
||||
|
|
@ -32,7 +32,7 @@ def test_env_deserialize():
|
|||
def test_environment_serdeser():
|
||||
out_mapping = {"field1": (list[str], ...)}
|
||||
out_data = {"field1": ["field1 value1", "field1 value2"]}
|
||||
ic_obj = ActionOutput.create_model_class("prd", out_mapping)
|
||||
ic_obj = ActionNode.create_model_class("prd", out_mapping)
|
||||
|
||||
message = Message(
|
||||
content="prd",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from metagpt.actions.action_output import ActionOutput
|
||||
from metagpt.actions.action_node import ActionNode
|
||||
from metagpt.actions.add_requirement import UserRequirement
|
||||
from metagpt.actions.design_api import WriteDesign
|
||||
from metagpt.memory.memory import Memory
|
||||
|
|
@ -20,7 +20,7 @@ def test_memory_serdeser():
|
|||
|
||||
out_mapping = {"field2": (list[str], ...)}
|
||||
out_data = {"field2": ["field2 value1", "field2 value2"]}
|
||||
ic_obj = ActionOutput.create_model_class("system_design", out_mapping)
|
||||
ic_obj = ActionNode.create_model_class("system_design", out_mapping)
|
||||
msg2 = Message(role="Architect",
|
||||
instruct_content=ic_obj(**out_data),
|
||||
content="system design content",
|
||||
|
|
@ -46,7 +46,7 @@ def test_memory_serdeser_save():
|
|||
|
||||
out_mapping = {"field1": (list[str], ...)}
|
||||
out_data = {"field1": ["field1 value1", "field1 value2"]}
|
||||
ic_obj = ActionOutput.create_model_class("system_design", out_mapping)
|
||||
ic_obj = ActionNode.create_model_class("system_design", out_mapping)
|
||||
msg2 = Message(role="Architect",
|
||||
instruct_content=ic_obj(**out_data),
|
||||
content="system design content",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# @Desc : unittest of schema ser&deser
|
||||
|
||||
from metagpt.actions.action_output import ActionOutput
|
||||
from metagpt.actions.action_node import ActionNode
|
||||
from metagpt.actions.write_code import WriteCode
|
||||
from metagpt.schema import Message
|
||||
from metagpt.utils.common import any_to_str
|
||||
|
|
@ -12,7 +12,7 @@ from tests.metagpt.serialize_deserialize.test_serdeser_base import MockMessage
|
|||
def test_message_serdeser():
|
||||
out_mapping = {"field3": (str, ...), "field4": (list[str], ...)}
|
||||
out_data = {"field3": "field3 value3", "field4": ["field4 value1", "field4 value2"]}
|
||||
ic_obj = ActionOutput.create_model_class("code", out_mapping)
|
||||
ic_obj = ActionNode.create_model_class("code", out_mapping)
|
||||
|
||||
message = Message(
|
||||
content="code",
|
||||
|
|
@ -34,7 +34,7 @@ def test_message_without_postprocess():
|
|||
""" to explain `instruct_content` should be postprocessed """
|
||||
out_mapping = {"field1": (list[str], ...)}
|
||||
out_data = {"field1": ["field1 value1", "field1 value2"]}
|
||||
ic_obj = ActionOutput.create_model_class("code", out_mapping)
|
||||
ic_obj = ActionNode.create_model_class("code", out_mapping)
|
||||
message = MockMessage(
|
||||
content="code",
|
||||
instruct_content=ic_obj(**out_data)
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ from pathlib import Path
|
|||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from metagpt.actions.action import Action
|
||||
from metagpt.actions.action_output import ActionOutput
|
||||
from metagpt.actions import Action, ActionOutput
|
||||
from metagpt.actions.action_node import ActionNode
|
||||
from metagpt.actions.add_requirement import UserRequirement
|
||||
from metagpt.roles.role import Role, RoleReactMode
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ class ActionPass(Action):
|
|||
output_mapping = {
|
||||
"result": (str, ...)
|
||||
}
|
||||
pass_class = ActionOutput.create_model_class("pass", output_mapping)
|
||||
pass_class = ActionNode.create_model_class("pass", output_mapping)
|
||||
pass_output = ActionOutput("ActionPass run passed", pass_class(**{"result": "pass result"}))
|
||||
|
||||
return pass_output
|
||||
|
|
|
|||
|
|
@ -9,13 +9,6 @@ from metagpt.llm import LLM
|
|||
from metagpt.schema import CodingContext, Document
|
||||
|
||||
|
||||
def test_write_task_serialize():
|
||||
action = WriteCodeReview()
|
||||
ser_action_dict = action.dict()
|
||||
assert ser_action_dict["name"] == "WriteCodeReview"
|
||||
# assert "llm" in ser_action_dict # not export
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_write_code_review_deserialize():
|
||||
code_content = """
|
||||
|
|
@ -30,6 +23,8 @@ def div(a: int, b: int = 0):
|
|||
|
||||
action = WriteCodeReview(context=context)
|
||||
serialized_data = action.dict()
|
||||
assert serialized_data["name"] == "WriteCodeReview"
|
||||
|
||||
new_action = WriteCodeReview(**serialized_data)
|
||||
|
||||
assert new_action.name == "WriteCodeReview"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import pytest
|
|||
|
||||
from metagpt.actions import Action
|
||||
from metagpt.schema import AIMessage, Message, SystemMessage, UserMessage
|
||||
from metagpt.actions.action_output import ActionOutput
|
||||
from metagpt.actions.action_node import ActionNode
|
||||
from metagpt.actions.write_code import WriteCode
|
||||
from metagpt.utils.serialize import serialize_general_message, deserialize_general_message
|
||||
from metagpt.utils.common import any_to_str
|
||||
|
|
@ -76,7 +76,7 @@ def test_routes():
|
|||
def test_message_serdeser():
|
||||
out_mapping = {"field3": (str, ...), "field4": (list[str], ...)}
|
||||
out_data = {"field3": "field3 value3", "field4": ["field4 value1", "field4 value2"]}
|
||||
ic_obj = ActionOutput.create_model_class("code", out_mapping)
|
||||
ic_obj = ActionNode.create_model_class("code", out_mapping)
|
||||
|
||||
message = Message(
|
||||
content="code",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue