import json from typing import Any #need ndjson for streaming responses, this is a simple helper to convert dicts to ndjson format def to_ndjson(payload: dict[str, Any]) -> str: return json.dumps(payload, ensure_ascii=False) + "\n"