import json from pathlib import Path from typing import Any def export_jsonl(records: list[dict[str, Any]], filepath: str | Path) -> Path: path = Path(filepath) path.parent.mkdir(parents=True, exist_ok=True) with open(path, "w") as f: for record in records: f.write(json.dumps(record) + "\n") return path def export_hf_dataset(records: list[dict[str, Any]], filepath: str | Path): path = Path(filepath) path.parent.mkdir(parents=True, exist_ok=True) with open(path, "w") as f: json.dump(records, f, indent=2) return path