Stream response from upstream, yielding raw bytes.
(
upstream_url: str,
body: dict,
headers: dict[str, str],
)
| 571 | |
| 572 | |
| 573 | async def _stream_upstream( |
| 574 | upstream_url: str, |
| 575 | body: dict, |
| 576 | headers: dict[str, str], |
| 577 | ) -> AsyncGenerator[bytes, None]: |
| 578 | """Stream response from upstream, yielding raw bytes.""" |
| 579 | client = _get_client() |
| 580 | async with client.stream( |
| 581 | "POST", |
| 582 | upstream_url, |
| 583 | json=body, |
| 584 | headers=headers, |
| 585 | ) as resp: |
| 586 | async for chunk in resp.aiter_bytes(): |
| 587 | yield chunk |
| 588 | |
| 589 | |
| 590 | def _extract_assistant_text(content: bytes) -> str: |
nothing calls this directly
no test coverage detected