()
| 5544 | ) |
| 5545 | |
| 5546 | async def sse_passthrough() -> AsyncGenerator[bytes, None]: |
| 5547 | stream_chunks: list[bytes] = [] |
| 5548 | try: |
| 5549 | async for chunk in stream_resp.aiter_bytes(): |
| 5550 | stream_chunks.append(chunk) |
| 5551 | yield _normalize_reasoning_content_chunk(chunk) |
| 5552 | await _record_stream_success( |
| 5553 | parse_stream_usage_metrics(stream_chunks, selected_model, _get_pricing()), |
| 5554 | stream_chunks=stream_chunks, |
| 5555 | ) |
| 5556 | except Exception: |
| 5557 | await _record_stream_failure() |
| 5558 | raise |
| 5559 | finally: |
| 5560 | await _record_stream_aborted(stream_chunks=stream_chunks) |
| 5561 | await stream_resp.aclose() |
| 5562 | |
| 5563 | return StreamingResponse( |
| 5564 | sse_passthrough(), |
no test coverage detected