Skip to content

Commit 13484f8

Browse files
feat(api): manual updates
1 parent 722abc9 commit 13484f8

File tree

3 files changed

+41
-70
lines changed

3 files changed

+41
-70
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 7
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-349e1b0f6291eedd731c1660155a50adcb3424fb8cd9e17bbdc0939ff3bbffcd.yml
3-
openapi_spec_hash: 456b593ea71d72bc31a6338a25363e9f
4-
config_hash: 5f6b5ec6e84fb01932ba87c6a9623d9b
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-e6a9dca1a93568e403ac72128d86f30c8c3f1336d4b67017d7e61b1836f10f47.yml
3+
openapi_spec_hash: ef01e0649bb0e283df0aa81c369649df
4+
config_hash: abc9d1eb9779bb5629eaed7074c42809

README.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ client = Stagehand(
4343

4444
response = client.sessions.act(
4545
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
46-
input="Click the login button",
46+
input="click the first link on the page",
4747
)
4848
print(response.data)
4949
```
@@ -76,7 +76,7 @@ client = AsyncStagehand(
7676
async def main() -> None:
7777
response = await client.sessions.act(
7878
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
79-
input="Click the login button",
79+
input="click the first link on the page",
8080
)
8181
print(response.data)
8282

@@ -119,7 +119,7 @@ async def main() -> None:
119119
) as client:
120120
response = await client.sessions.act(
121121
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
122-
input="Click the login button",
122+
input="click the first link on the page",
123123
)
124124
print(response.data)
125125

@@ -169,9 +169,8 @@ from stagehand import Stagehand
169169
client = Stagehand()
170170

171171
try:
172-
client.sessions.act(
173-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
174-
input="Click the login button",
172+
client.sessions.start(
173+
model_name="gpt-4o",
175174
)
176175
except stagehand.APIConnectionError as e:
177176
print("The server could not be reached")
@@ -215,9 +214,8 @@ client = Stagehand(
215214
)
216215

217216
# Or, configure per-request:
218-
client.with_options(max_retries=5).sessions.act(
219-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
220-
input="Click the login button",
217+
client.with_options(max_retries=5).sessions.start(
218+
model_name="gpt-4o",
221219
)
222220
```
223221

@@ -241,9 +239,8 @@ client = Stagehand(
241239
)
242240

243241
# Override per-request:
244-
client.with_options(timeout=5.0).sessions.act(
245-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
246-
input="Click the login button",
242+
client.with_options(timeout=5.0).sessions.start(
243+
model_name="gpt-4o",
247244
)
248245
```
249246

@@ -285,13 +282,12 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
285282
from stagehand import Stagehand
286283

287284
client = Stagehand()
288-
response = client.sessions.with_raw_response.act(
289-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
290-
input="Click the login button",
285+
response = client.sessions.with_raw_response.start(
286+
model_name="gpt-4o",
291287
)
292288
print(response.headers.get('X-My-Header'))
293289

294-
session = response.parse() # get the object that `sessions.act()` would have returned
290+
session = response.parse() # get the object that `sessions.start()` would have returned
295291
print(session.data)
296292
```
297293

@@ -306,9 +302,8 @@ The above interface eagerly reads the full response body when you make the reque
306302
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
307303

308304
```python
309-
with client.sessions.with_streaming_response.act(
310-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
311-
input="Click the login button",
305+
with client.sessions.with_streaming_response.start(
306+
model_name="gpt-4o",
312307
) as response:
313308
print(response.headers.get("X-My-Header"))
314309

tests/test_client.py

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -876,26 +876,20 @@ def test_parse_retry_after_header(
876876
@mock.patch("stagehand._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
877877
@pytest.mark.respx(base_url=base_url)
878878
def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, client: Stagehand) -> None:
879-
respx_mock.post("/v1/sessions/c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123/act").mock(
880-
side_effect=httpx.TimeoutException("Test timeout error")
881-
)
879+
respx_mock.post("/v1/sessions/start").mock(side_effect=httpx.TimeoutException("Test timeout error"))
882880

883881
with pytest.raises(APITimeoutError):
884-
client.sessions.with_streaming_response.act(
885-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123", input="Click the login button"
886-
).__enter__()
882+
client.sessions.with_streaming_response.start(model_name="gpt-4o").__enter__()
887883

888884
assert _get_open_connections(client) == 0
889885

890886
@mock.patch("stagehand._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
891887
@pytest.mark.respx(base_url=base_url)
892888
def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client: Stagehand) -> None:
893-
respx_mock.post("/v1/sessions/c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123/act").mock(return_value=httpx.Response(500))
889+
respx_mock.post("/v1/sessions/start").mock(return_value=httpx.Response(500))
894890

895891
with pytest.raises(APIStatusError):
896-
client.sessions.with_streaming_response.act(
897-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123", input="Click the login button"
898-
).__enter__()
892+
client.sessions.with_streaming_response.start(model_name="gpt-4o").__enter__()
899893
assert _get_open_connections(client) == 0
900894

901895
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@@ -922,11 +916,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
922916
return httpx.Response(500)
923917
return httpx.Response(200)
924918

925-
respx_mock.post("/v1/sessions/c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123/act").mock(side_effect=retry_handler)
919+
respx_mock.post("/v1/sessions/start").mock(side_effect=retry_handler)
926920

927-
response = client.sessions.with_raw_response.act(
928-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123", input="Click the login button"
929-
)
921+
response = client.sessions.with_raw_response.start(model_name="gpt-4o")
930922

931923
assert response.retries_taken == failures_before_success
932924
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@@ -948,12 +940,10 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
948940
return httpx.Response(500)
949941
return httpx.Response(200)
950942

951-
respx_mock.post("/v1/sessions/c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123/act").mock(side_effect=retry_handler)
943+
respx_mock.post("/v1/sessions/start").mock(side_effect=retry_handler)
952944

953-
response = client.sessions.with_raw_response.act(
954-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
955-
input="Click the login button",
956-
extra_headers={"x-stainless-retry-count": Omit()},
945+
response = client.sessions.with_raw_response.start(
946+
model_name="gpt-4o", extra_headers={"x-stainless-retry-count": Omit()}
957947
)
958948

959949
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
@@ -975,12 +965,10 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
975965
return httpx.Response(500)
976966
return httpx.Response(200)
977967

978-
respx_mock.post("/v1/sessions/c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123/act").mock(side_effect=retry_handler)
968+
respx_mock.post("/v1/sessions/start").mock(side_effect=retry_handler)
979969

980-
response = client.sessions.with_raw_response.act(
981-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
982-
input="Click the login button",
983-
extra_headers={"x-stainless-retry-count": "42"},
970+
response = client.sessions.with_raw_response.start(
971+
model_name="gpt-4o", extra_headers={"x-stainless-retry-count": "42"}
984972
)
985973

986974
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
@@ -1856,14 +1844,10 @@ async def test_parse_retry_after_header(
18561844
async def test_retrying_timeout_errors_doesnt_leak(
18571845
self, respx_mock: MockRouter, async_client: AsyncStagehand
18581846
) -> None:
1859-
respx_mock.post("/v1/sessions/c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123/act").mock(
1860-
side_effect=httpx.TimeoutException("Test timeout error")
1861-
)
1847+
respx_mock.post("/v1/sessions/start").mock(side_effect=httpx.TimeoutException("Test timeout error"))
18621848

18631849
with pytest.raises(APITimeoutError):
1864-
await async_client.sessions.with_streaming_response.act(
1865-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123", input="Click the login button"
1866-
).__aenter__()
1850+
await async_client.sessions.with_streaming_response.start(model_name="gpt-4o").__aenter__()
18671851

18681852
assert _get_open_connections(async_client) == 0
18691853

@@ -1872,12 +1856,10 @@ async def test_retrying_timeout_errors_doesnt_leak(
18721856
async def test_retrying_status_errors_doesnt_leak(
18731857
self, respx_mock: MockRouter, async_client: AsyncStagehand
18741858
) -> None:
1875-
respx_mock.post("/v1/sessions/c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123/act").mock(return_value=httpx.Response(500))
1859+
respx_mock.post("/v1/sessions/start").mock(return_value=httpx.Response(500))
18761860

18771861
with pytest.raises(APIStatusError):
1878-
await async_client.sessions.with_streaming_response.act(
1879-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123", input="Click the login button"
1880-
).__aenter__()
1862+
await async_client.sessions.with_streaming_response.start(model_name="gpt-4o").__aenter__()
18811863
assert _get_open_connections(async_client) == 0
18821864

18831865
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@@ -1904,11 +1886,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
19041886
return httpx.Response(500)
19051887
return httpx.Response(200)
19061888

1907-
respx_mock.post("/v1/sessions/c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123/act").mock(side_effect=retry_handler)
1889+
respx_mock.post("/v1/sessions/start").mock(side_effect=retry_handler)
19081890

1909-
response = await client.sessions.with_raw_response.act(
1910-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123", input="Click the login button"
1911-
)
1891+
response = await client.sessions.with_raw_response.start(model_name="gpt-4o")
19121892

19131893
assert response.retries_taken == failures_before_success
19141894
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@@ -1930,12 +1910,10 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
19301910
return httpx.Response(500)
19311911
return httpx.Response(200)
19321912

1933-
respx_mock.post("/v1/sessions/c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123/act").mock(side_effect=retry_handler)
1913+
respx_mock.post("/v1/sessions/start").mock(side_effect=retry_handler)
19341914

1935-
response = await client.sessions.with_raw_response.act(
1936-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
1937-
input="Click the login button",
1938-
extra_headers={"x-stainless-retry-count": Omit()},
1915+
response = await client.sessions.with_raw_response.start(
1916+
model_name="gpt-4o", extra_headers={"x-stainless-retry-count": Omit()}
19391917
)
19401918

19411919
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
@@ -1957,12 +1935,10 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
19571935
return httpx.Response(500)
19581936
return httpx.Response(200)
19591937

1960-
respx_mock.post("/v1/sessions/c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123/act").mock(side_effect=retry_handler)
1938+
respx_mock.post("/v1/sessions/start").mock(side_effect=retry_handler)
19611939

1962-
response = await client.sessions.with_raw_response.act(
1963-
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
1964-
input="Click the login button",
1965-
extra_headers={"x-stainless-retry-count": "42"},
1940+
response = await client.sessions.with_raw_response.start(
1941+
model_name="gpt-4o", extra_headers={"x-stainless-retry-count": "42"}
19661942
)
19671943

19681944
assert response.http_request.headers.get("x-stainless-retry-count") == "42"

0 commit comments

Comments
 (0)