Non-streaming chat endpoint for comparison. Waits for the complete response before returning. Useful for testing or when streaming isn't needed. Args: request: Chat request with prompt Returns: Complete response as JSON
(request: ChatRequest)
| 63 | |
| 64 | @app.post("/chat/sync", response_model=ChatResponse) |
| 65 | async def chat_sync(request: ChatRequest): |
| 66 | """Non-streaming chat endpoint for comparison. |
| 67 | |
| 68 | Waits for the complete response before returning. |
| 69 | Useful for testing or when streaming isn't needed. |
| 70 | |
| 71 | Args: |
| 72 | request: Chat request with prompt |
| 73 | |
| 74 | Returns: |
| 75 | Complete response as JSON |
| 76 | """ |
| 77 | client = await get_dirty_client_async() |
| 78 | action = "generate_with_thinking" if request.thinking else "generate" |
| 79 | |
| 80 | tokens = [] |
| 81 | async for token in client.stream_async( |
| 82 | "streaming_chat.chat_app:ChatApp", |
| 83 | action, |
| 84 | request.prompt |
| 85 | ): |
| 86 | tokens.append(token) |
| 87 | |
| 88 | return ChatResponse(response="".join(tokens)) |
| 89 | |
| 90 | |
| 91 | @app.get("/health") |
nothing calls this directly
no test coverage detected