add test case for action node

This commit is contained in:
geekan 2023-12-23 17:38:47 +08:00
parent 5223c4afa9
commit f136e7bd3d
5 changed files with 88 additions and 12 deletions

View file

@ -340,15 +340,15 @@ class ActionNode:
return self
def action_node_from_tuple_example():
# 示例:列表中包含元组
list_of_tuples = [("key1", str, "Instruction 1", "Example 1")]
def action_node_example():
node = ActionNode(key="key-0", expected_type=str, instruction="instruction-a", example="example-b")
# 从列表中创建 ActionNode 实例
nodes = [ActionNode(*data) for data in list_of_tuples]
for i in nodes:
logger.info(i)
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_from_tuple_example()
action_node_example()

View file

@ -521,7 +521,7 @@ class Role(BaseModel):
return self._rc.memory.get(k=k)
@role_raise_decorator
async def run(self, with_message=None):
async def run(self, with_message=None) -> Message | None:
"""Observe, and think and act based on the results of the observation"""
if with_message:
msg = None