Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,075 Bytes
55d584b 2133289 55d584b 2133289 55d584b 2133289 55d584b 2133289 55d584b 2133289 55d584b 2133289 55d584b 2133289 55d584b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
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")
|