File size: 238 Bytes
c7256ee
 
 
 
 
 
 
1
2
3
4
5
6
7
8
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"