Download backend/services/streaming.py from Qar-Raz/NLP-RAG: direct link, hf CLI and curl.
- Browser
- Download file 238 Bytes
-
https://huggingface.co/spaces/Qar-Raz/NLP-RAG/resolve/main/backend/services/streaming.py
- Command line
-
hf download hf://spaces/Qar-Raz/NLP-RAG/backend/services/streaming.py
-
curl -L -o streaming.py https://huggingface.co/spaces/Qar-Raz/NLP-RAG/resolve/main/backend/services/streaming.py
238 Bytes
| 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" | |