Skip to content

Commit 027d82b

Browse files
authored
fix: add missing __aiter__ method to TextGenerationStream (#196)
Without __aiter__, async for chunk in stream: raises TypeError: 'TextGenerationStream' object is not an async iterable. This makes async streaming completely broken when _is_async=True.
1 parent 1280a2e commit 027d82b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/opengradient/types.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ def __iter__(self):
318318
"""Iterate over stream chunks."""
319319
return self
320320

321+
def __aiter__(self):
322+
"""Return async iterator (required for async for loops)."""
323+
if not self._is_async:
324+
raise TypeError("Use __iter__ for sync iterators")
325+
return self
326+
321327
def __next__(self) -> StreamChunk:
322328
"""Get next stream chunk."""
323329
import json

0 commit comments

Comments
 (0)