This commit is contained in:
geekan 2023-12-23 19:35:07 +08:00
parent f136e7bd3d
commit e043694461
2 changed files with 14 additions and 2 deletions

View file

@ -59,7 +59,7 @@ class Action(BaseModel):
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

View file

@ -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")
@ -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