Skip to content

Commit ecf8040

Browse files
committed
fix: add missing __aiter__ method to ResponseStream for async iteration support
The ResponseStream class was missing the __aiter__ method which is required for async iteration with 'async for' loops. This caused TypeError when trying to iterate over streaming responses asynchronously. Added __aiter__ method that returns self, following the standard async iterator protocol pattern.
1 parent a28e427 commit ecf8040

File tree

1 file changed

+3
-0
lines changed
  • packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/v1

1 file changed

+3
-0
lines changed

packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/v1/responses_wrappers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
302302
def __iter__(self):
303303
return self
304304

305+
def __aiter__(self):
306+
return self
307+
305308
def __next__(self):
306309
try:
307310
chunk = self.__wrapped__.__next__()

0 commit comments

Comments
 (0)