(
chat_service: ChatService,
username: str,
post_data: dict[str, Any],
)
| 65 | |
| 66 | |
| 67 | async def _build_streaming_chat_response( |
| 68 | chat_service: ChatService, |
| 69 | username: str, |
| 70 | post_data: dict[str, Any], |
| 71 | ) -> StreamingResponse | JSONResponse: |
| 72 | try: |
| 73 | stream = await chat_service.build_chat_stream(username, post_data) |
| 74 | except ChatServiceError as exc: |
| 75 | return _open_api_error(str(exc)) |
| 76 | |
| 77 | return StreamingResponse( |
| 78 | stream, |
| 79 | media_type="text/event-stream", |
| 80 | headers={ |
| 81 | "Cache-Control": "no-cache", |
| 82 | "Transfer-Encoding": "chunked", |
| 83 | "Connection": "keep-alive", |
| 84 | }, |
| 85 | ) |
| 86 | |
| 87 | |
| 88 | async def _open_api_chat_response( |
no test coverage detected