Download app/sse.py from minhbe65/RAG-api: direct link, hf CLI and curl.
- Browser
- Download file 471 Bytes
-
https://huggingface.co/spaces/minhbe65/RAG-api/resolve/main/app/sse.py
- Command line
-
hf download hf://spaces/minhbe65/RAG-api/app/sse.py
-
curl -L -o sse.py https://huggingface.co/spaces/minhbe65/RAG-api/resolve/main/app/sse.py
471 Bytes
| """Tiện ích Server-Sent Events. Một định dạng dùng chung cho mọi luồng. | |
| Sự kiện: token | step | tool_start | tool_end | interrupt | citation | done | error | |
| Đọc phía client bằng fetch + ReadableStream (xem frontend/lib/sse.ts). | |
| """ | |
| from __future__ import annotations | |
| import json | |
| from typing import Any | |
| def sse(event: str, data: Any) -> str: | |
| payload = json.dumps(data, ensure_ascii=False) | |
| return f"event: {event}\ndata: {payload}\n\n" | |