Files
dzentra_bot/app/tools/dzengi_probe/response_store.py

23 lines
655 B
Python

# app/tools/dzengi_probe/response_store.py
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
def save_json(path: Path, payload: Any) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
with path.open("w", encoding="utf-8") as file:
json.dump(payload, file, ensure_ascii=False, indent=2, sort_keys=True)
file.write("\n")
def append_jsonl(path: Path, payload: Any) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
with path.open("a", encoding="utf-8") as file:
file.write(json.dumps(payload, ensure_ascii=False, sort_keys=True))
file.write("\n")