(
content: Iterator[bytes],
*,
sync: bool,
client: Anthropic,
async_client: AsyncAnthropic,
)
| 392 | # Unlike make_event_iterator which only parses SSE events using _iter_events(), |
| 393 | # this helper uses __stream__() to process the full stream pipeline including |
| 394 | # parsing message objects and converting error events into raised exceptions. |
| 395 | def make_stream_iterator( |
| 396 | content: Iterator[bytes], |
| 397 | *, |
| 398 | sync: bool, |
| 399 | client: Anthropic, |
| 400 | async_client: AsyncAnthropic, |
| 401 | ) -> AsyncIterator[object] | Iterator[object]: |
| 402 | if sync: |
| 403 | return Stream( |
| 404 | cast_to=object, |
| 405 | client=client, |
| 406 | response=httpx2.Response(200, content=content, request=httpx2.Request("GET", "https://example.com")), |
| 407 | ).__stream__() |
| 408 | |
| 409 | return AsyncStream( |
| 410 | cast_to=object, |
| 411 | client=async_client, |
| 412 | response=httpx2.Response(200, content=to_aiter(content), request=httpx2.Request("GET", "https://example.com")), |
| 413 | ).__stream__() |
no test coverage detected