in experimental/piranha_playground/rule_inference/piranha_chat.py [0:0]
def _get_examples(path_to_examples_rules):
"""
Walks through a specified directory to gather and format the content of example rule and edge files.
The formatted content is then returned as a single string.
:param path_to_examples_rules: str: Path to the directory containing example rule and edge files.
:return str: Formatted content of example rule and edge files.
"""
task_examples = ""
for root, dirs, files in os.walk(path_to_examples_rules):
for file in files:
if file.endswith("rules.toml") or file.endswith("edges.toml"):
file_name = os.path.join(root, file)
file_contents = Path(file_name).read_text()
file_contents = "\n".join(
[
line
for line in file_contents.split("\n")
if not line.startswith("#")
]
)
task_examples += f"<file_name_start> {file_name} <file_name_end>\n"
task_examples += f"```toml {file_contents}```\n"
return task_examples