Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
geekan committed Dec 23, 2023
1 parent 6624819 commit c7f47e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion metagpt/actions/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init_subclass__(cls, **kwargs: Any) -> None:
action_subclass_registry[cls.__name__] = cls

def dict(self, *args, **kwargs) -> "DictStrAny":
obj_dict = super(Action, self).dict(*args, **kwargs)
obj_dict = super().dict(*args, **kwargs)
if "llm" in obj_dict:
obj_dict.pop("llm")
return obj_dict
Expand Down
14 changes: 13 additions & 1 deletion tests/metagpt/actions/test_action_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def test_debate_one_role():


@pytest.mark.asyncio
async def test_action_node():
async def test_action_node_one_layer():
node = ActionNode(key="key-a", expected_type=str, instruction="instruction-b", example="example-c")

raw_template = node.compile(context="123", schema="raw", mode="auto")
Expand All @@ -74,3 +74,15 @@ async def test_action_node():
assert "key-a" in markdown_template

assert node_dict["key-a"] == "instruction-b"


@pytest.mark.asyncio
async def test_action_node_two_layer():
node_a = ActionNode(key="key-a", expected_type=str, instruction="i-a", example="e-a")
node_b = ActionNode(key="key-b", expected_type=str, instruction="i-b", example="e-b")

root = ActionNode.from_children(key="", nodes=[node_a, node_b])
assert "key-a" in root.children
assert node_b in root.children.values()
json_template = root.compile(context="123", schema="json", mode="auto")
assert "i-a" in json_template

0 comments on commit c7f47e8

Please sign in to comment.