44import json
55import inspect
66from types import TracebackType
7- from typing import TYPE_CHECKING , Any , Generic , TypeVar , Iterator , AsyncIterator , cast
7+ from typing import TYPE_CHECKING , Any , Generic , TypeVar , Iterator , Optional , AsyncIterator , cast
88from typing_extensions import Self , Protocol , TypeGuard , override , get_origin , runtime_checkable
99
1010import httpx
1414
1515if TYPE_CHECKING :
1616 from ._client import Gradient , AsyncGradient
17+ from ._models import FinalRequestOptions
1718
1819
1920_T = TypeVar ("_T" )
@@ -23,7 +24,7 @@ class Stream(Generic[_T]):
2324 """Provides the core interface to iterate over a synchronous stream response."""
2425
2526 response : httpx .Response
26-
27+ _options : Optional [ FinalRequestOptions ] = None
2728 _decoder : SSEBytesDecoder
2829
2930 def __init__ (
@@ -32,10 +33,12 @@ def __init__(
3233 cast_to : type [_T ],
3334 response : httpx .Response ,
3435 client : Gradient ,
36+ options : Optional [FinalRequestOptions ] = None ,
3537 ) -> None :
3638 self .response = response
3739 self ._cast_to = cast_to
3840 self ._client = client
41+ self ._options = options
3942 self ._decoder = client ._make_sse_decoder ()
4043 self ._iterator = self .__stream__ ()
4144
@@ -104,7 +107,7 @@ class AsyncStream(Generic[_T]):
104107 """Provides the core interface to iterate over an asynchronous stream response."""
105108
106109 response : httpx .Response
107-
110+ _options : Optional [ FinalRequestOptions ] = None
108111 _decoder : SSEDecoder | SSEBytesDecoder
109112
110113 def __init__ (
@@ -113,10 +116,12 @@ def __init__(
113116 cast_to : type [_T ],
114117 response : httpx .Response ,
115118 client : AsyncGradient ,
119+ options : Optional [FinalRequestOptions ] = None ,
116120 ) -> None :
117121 self .response = response
118122 self ._cast_to = cast_to
119123 self ._client = client
124+ self ._options = options
120125 self ._decoder = client ._make_sse_decoder ()
121126 self ._iterator = self .__stream__ ()
122127
0 commit comments