MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / _aiter_chunks

Method _aiter_chunks

src/opencode_ai/_streaming.py:233–243  ·  view source on GitHub ↗

Given an iterator that yields raw binary data, iterate over it and yield individual SSE chunks

(self, iterator: AsyncIterator[bytes])

Source from the content-addressed store, hash-verified

231 yield sse
232
233 async def _aiter_chunks(self, iterator: AsyncIterator[bytes]) -> AsyncIterator[bytes]:
234 """Given an iterator that yields raw binary data, iterate over it and yield individual SSE chunks"""
235 data = b""
236 async for chunk in iterator:
237 for line in chunk.splitlines(keepends=True):
238 data += line
239 if data.endswith((b"\r\r", b"\n\n", b"\r\n\r\n")):
240 yield data
241 data = b""
242 if data:
243 yield data
244
245 def decode(self, line: str) -> ServerSentEvent | None:
246 # See: https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation # noqa: E501

Callers 1

aiter_bytesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected