mirror of
https://github.com/anomalyco/opencode-sdk-python.git
synced 2026-05-17 12:42:25 +00:00
chore(internal): codegen related update
This commit is contained in:
parent
875138a43a
commit
ab5c4936b8
4 changed files with 20 additions and 16 deletions
|
|
@ -54,11 +54,12 @@ class Stream(Generic[_T]):
|
|||
process_data = self._client._process_response_data
|
||||
iterator = self._iter_events()
|
||||
|
||||
for sse in iterator:
|
||||
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
|
||||
|
||||
# As we might not fully consume the response stream, we need to close it explicitly
|
||||
response.close()
|
||||
try:
|
||||
for sse in iterator:
|
||||
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
|
||||
finally:
|
||||
# Ensure the response is closed even if the consumer doesn't read all data
|
||||
response.close()
|
||||
|
||||
def __enter__(self) -> Self:
|
||||
return self
|
||||
|
|
@ -117,11 +118,12 @@ class AsyncStream(Generic[_T]):
|
|||
process_data = self._client._process_response_data
|
||||
iterator = self._iter_events()
|
||||
|
||||
async for sse in iterator:
|
||||
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
|
||||
|
||||
# As we might not fully consume the response stream, we need to close it explicitly
|
||||
await response.aclose()
|
||||
try:
|
||||
async for sse in iterator:
|
||||
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
|
||||
finally:
|
||||
# Ensure the response is closed even if the consumer doesn't read all data
|
||||
await response.aclose()
|
||||
|
||||
async def __aenter__(self) -> Self:
|
||||
return self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue