(
content: Iterator[bytes],
*,
sync: bool,
client: Anthropic,
async_client: AsyncAnthropic,
)
| 464 | # Unlike make_event_iterator which only parses SSE events using _iter_events(), |
| 465 | # this helper uses __stream__() to process the full stream pipeline including |
| 466 | # parsing message objects and converting error events into raised exceptions. |
| 467 | def make_stream_iterator( |
| 468 | content: Iterator[bytes], |
| 469 | *, |
| 470 | sync: bool, |
| 471 | client: Anthropic, |
| 472 | async_client: AsyncAnthropic, |
| 473 | ) -> AsyncIterator[object] | Iterator[object]: |
| 474 | if sync: |
| 475 | return Stream( |
| 476 | cast_to=object, |
| 477 | client=client, |
| 478 | response=httpx2.Response(200, content=content, request=httpx2.Request("GET", "https://example.com")), |
| 479 | ).__stream__() |
| 480 | |
| 481 | return AsyncStream( |
| 482 | cast_to=object, |
| 483 | client=async_client, |
| 484 | response=httpx2.Response(200, content=to_aiter(content), request=httpx2.Request("GET", "https://example.com")), |
| 485 | ).__stream__() |
no test coverage detected