Coverage for tinytroupe / examples / loaders.py: 0%
10 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-02-28 17:48 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-02-28 17:48 +0000
1import json
2import os
4def load_example_agent_specification(name:str):
5 """
6 Load an example agent specification.
8 Args:
9 name (str): The name of the agent.
11 Returns:
12 dict: The agent specification.
13 """
14 return json.load(open(os.path.join(os.path.dirname(__file__), f'./agents/{name}.agent.json'), 'r', encoding='utf-8', errors='replace'))
16def load_example_fragment_specification(name:str):
17 """
18 Load an example fragment specification.
20 Args:
21 name (str): The name of the fragment.
23 Returns:
24 dict: The fragment specification.
25 """
26 return json.load(open(os.path.join(os.path.dirname(__file__), f'./fragments/{name}.fragment.json'), 'r', encoding='utf-8', errors='replace'))
28def list_example_agents():
29 """
30 List the available example agents.
32 Returns:
33 list: A list of the available example agents.
34 """
35 return [f.replace('.agent.json', '') for f in os.listdir(os.path.join(os.path.dirname(__file__), './agents'))]
37def list_example_fragments():
38 """
39 List the available example fragments.
41 Returns:
42 list: A list of the available example fragments.
43 """
44 return [f.replace('.fragment.json', '') for f in os.listdir(os.path.join(os.path.dirname(__file__), './fragments'))]