Spaces:
Running
Running
Download tests/stream_packets.py from dherain24/claude-proxy: direct link, hf CLI and curl.
- Browser
- Download file 819 Bytes
-
https://huggingface.co/spaces/dherain24/claude-proxy/resolve/main/tests/stream_packets.py
- Command line
-
hf download hf://spaces/dherain24/claude-proxy/tests/stream_packets.py
-
curl -L -o stream_packets.py https://huggingface.co/spaces/dherain24/claude-proxy/resolve/main/tests/stream_packets.py
819 Bytes
| """Explicit provider packets for tests whose fixtures are serialized text frames.""" | |
| from collections.abc import AsyncIterator | |
| from free_claude_code.core.async_iterators import try_close_async_iterator | |
| from free_claude_code.core.stream_output import StreamOutput | |
| class PacketFixtureStream(AsyncIterator[StreamOutput]): | |
| def __init__(self, source: AsyncIterator[str]) -> None: | |
| self.source = source | |
| def __aiter__(self): | |
| return self | |
| async def __anext__(self) -> StreamOutput: | |
| return StreamOutput((await anext(self.source),)) | |
| async def aclose(self) -> None: | |
| error = await try_close_async_iterator(self.source) | |
| if error is not None: | |
| raise error | |
| def packets(source: AsyncIterator[str]) -> PacketFixtureStream: | |
| return PacketFixtureStream(source) | |