warbler-cda / convert_to_jsonl.py
jmeyer1980
Fix syntax errors in app.py preventing Gradio app startup on HF Spaces
2133289
raw
history blame
1.08 kB
import json
import os
def convert_templates_to_jsonl(pack_dir):
"""Convert templates.json to pack_name.jsonl for a given pack directory."""
pack_name = os.path.basename(pack_dir)
templates_path = os.path.join(pack_dir, "pack", "templates.json")
jsonl_path = os.path.join(pack_dir, f"{pack_name}.jsonl")
if not os.path.exists(templates_path):
print(f"No templates.json found in {pack_dir}")
return
with open(templates_path, "r") as f:
templates = json.load(f)
with open(jsonl_path, "w") as f:
for template in templates:
json.dump(template, f)
f.write("\n")
print(f"Converted {templates_path} to {jsonl_path}")
# Convert the three default packs
packs_to_convert = [
"packs/warbler-pack-core",
"packs/warbler-pack-faction-politics",
"packs/warbler-pack-wisdom-scrolls",
]
for pack in packs_to_convert:
if os.path.exists(pack):
convert_templates_to_jsonl(pack)
else:
print(f"Pack directory {pack} not found")