Skip to content

Commit 93cdbe5

Browse files
chore(internal): add request options to SSE classes
1 parent 4e8e5cf commit 93cdbe5

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/stagehand/_response.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
152152
),
153153
response=self.http_response,
154154
client=cast(Any, self._client),
155+
options=self._options,
155156
),
156157
)
157158

@@ -162,6 +163,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
162163
cast_to=extract_stream_chunk_type(self._stream_cls),
163164
response=self.http_response,
164165
client=cast(Any, self._client),
166+
options=self._options,
165167
),
166168
)
167169

@@ -175,6 +177,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
175177
cast_to=cast_to,
176178
response=self.http_response,
177179
client=cast(Any, self._client),
180+
options=self._options,
178181
),
179182
)
180183

src/stagehand/_streaming.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import inspect
66
from 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
88
from typing_extensions import Self, Protocol, TypeGuard, override, get_origin, runtime_checkable
99

1010
import httpx
@@ -13,6 +13,7 @@
1313

1414
if TYPE_CHECKING:
1515
from ._client import Stagehand, AsyncStagehand
16+
from ._models import FinalRequestOptions
1617

1718

1819
_T = TypeVar("_T")
@@ -22,7 +23,7 @@ class Stream(Generic[_T]):
2223
"""Provides the core interface to iterate over a synchronous stream response."""
2324

2425
response: httpx.Response
25-
26+
_options: Optional[FinalRequestOptions] = None
2627
_decoder: SSEBytesDecoder
2728

2829
def __init__(
@@ -31,10 +32,12 @@ def __init__(
3132
cast_to: type[_T],
3233
response: httpx.Response,
3334
client: Stagehand,
35+
options: Optional[FinalRequestOptions] = None,
3436
) -> None:
3537
self.response = response
3638
self._cast_to = cast_to
3739
self._client = client
40+
self._options = options
3841
self._decoder = client._make_sse_decoder()
3942
self._iterator = self.__stream__()
4043

@@ -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: AsyncStagehand,
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

Comments
 (0)