(
content: Iterator[bytes],
*,
sync: bool,
client: Anthropic,
async_client: AsyncAnthropic,
)
| 282 | # Unlike make_event_iterator which only parses SSE events using _iter_events(), |
| 283 | # this helper uses __stream__() to process the full stream pipeline including |
| 284 | # parsing message objects and converting error events into raised exceptions. |
| 285 | def make_stream_iterator( |
| 286 | content: Iterator[bytes], |
| 287 | *, |
| 288 | sync: bool, |
| 289 | client: Anthropic, |
| 290 | async_client: AsyncAnthropic, |
| 291 | ) -> AsyncIterator[object] | Iterator[object]: |
| 292 | if sync: |
| 293 | return Stream( |
| 294 | cast_to=object, |
| 295 | client=client, |
| 296 | response=httpx.Response(200, content=content, request=httpx.Request("GET", "https://example.com")), |
| 297 | ).__stream__() |
| 298 | |
| 299 | return AsyncStream( |
| 300 | cast_to=object, |
| 301 | client=async_client, |
| 302 | response=httpx.Response(200, content=to_aiter(content), request=httpx.Request("GET", "https://example.com")), |
| 303 | ).__stream__() |
no test coverage detected