🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
action node test
geekanf02bbb250de6
diff --git a/metagpt/actions/action_node.py b/metagpt/actions/action_node.pyindex 9534e91c5..d80327a8c 100644--- a/metagpt/actions/action_node.py+++ b/metagpt/actions/action_node.py@@ -348,17 +348,3 @@ class ActionNode:cls = self.create_children_class()self.instruct_content = cls(**tmp)return self---def action_node_example():- node = ActionNode(key="key-0", expected_type=str, instruction="instruction-a", example="example-b")-- logger.info(node.compile(context="123", schema="raw", mode="auto"))- logger.info(node.compile(context="123", schema="json", mode="auto"))- logger.info(node.compile(context="123", schema="markdown", mode="auto"))- logger.info(node.to_dict())- logger.info(node)---if __name__ == "__main__":- action_node_example()diff --git a/tests/metagpt/actions/test_action_node.py b/tests/metagpt/actions/test_action_node.pyindex ebc428d75..335a62b92 100644--- a/tests/metagpt/actions/test_action_node.py+++ b/tests/metagpt/actions/test_action_node.py@@ -12,6 +12,7 @@ import pytestfrom metagpt.actions import Actionfrom metagpt.actions.action_node import ActionNodefrom metagpt.environment import Environment+from metagpt.llm import LLMfrom metagpt.roles import Rolefrom metagpt.schema import Messagefrom metagpt.team import Team@@ -81,14 +82,19 @@ async def test_action_node_one_layer():@pytest.mark.asyncioasync 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")+ node_a = ActionNode(key="reasoning", expected_type=str, instruction="reasoning step by step", example="")+ node_b = ActionNode(key="answer", expected_type=str, instruction="the final answer", example="")- root = ActionNode.from_children(key="", nodes=[node_a, node_b])- assert "key-a" in root.children+ root = ActionNode.from_children(key="detail answer", nodes=[node_a, node_b])+ assert "reasoning" in root.childrenassert node_b in root.children.values()- json_template = root.compile(context="123", schema="json", mode="auto")- assert "i-a" in json_template++ # FIXME: ADD MARKDOWN SUPPORT. NEED TO TUNE MARKDOWN SYMBOL FIRST.+ answer1 = await root.fill(context="what's the answer to 123+456?", schema="json", strgy="simple", llm=LLM())+ assert "579" in answer1.content++ answer2 = await root.fill(context="what's the answer to 123+456?", schema="json", strgy="complex", llm=LLM())+ assert "579" in answer2.contentt_dict = {