Skip to content

Commit 3c379d5

Browse files
authored
Merge branch 'main' into local_change1
2 parents f14a8af + ad95605 commit 3c379d5

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Stagehand Python Changelog
22

3+
## 0.5.3
4+
5+
### Patch Changes
6+
7+
[#196](https://github.com/browserbase/stagehand-python/pull/196) [`93f5c97`](https://github.com/browserbase/stagehand-python/commit/93f5c97) Thanks @chrisreadsf, @miguelg719 and Derek Meegan! - remove duplicate project id if already passed to Stagehand
8+
[#203](https://github.com/browserbase/stagehand-python/pull/203) [`82c6fed`](https://github.com/browserbase/stagehand-python/commit/82c6fed) Thanks @miguelg719! - Bump openai dependency version
9+
[#198](https://github.com/browserbase/stagehand-python/pull/198) [`057b38b`](https://github.com/browserbase/stagehand-python/commit/057b38b) Thanks @Zach10za! - Fix draw_overlay on env:LOCAL
10+
311
## 0.5.2
412

513
### Patch Changes

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "stagehand"
7-
version = "0.5.2"
7+
version = "0.5.3"
88
description = "Python SDK for Stagehand"
99
readme = "README.md"
1010
classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent",]
1111
requires-python = ">=3.9"
12-
dependencies = [ "python-dotenv>=1.0.0", "pydantic>=1.10.0", "playwright>=1.42.1", "rich>=13.7.0", "openai>=1.83.0,<1.99.6", "anthropic>=0.51.0", "litellm>=1.72.0,<1.75.0", "nest-asyncio>=1.6.0",]
12+
dependencies = [ "httpx>=0.24.0", "python-dotenv>=1.0.0", "pydantic>=1.10.0", "playwright>=1.42.1", "requests>=2.31.0", "browserbase>=1.4.0", "rich>=13.7.0", "openai>=1.99.6", "anthropic>=0.51.0", "litellm>=1.72.0,<1.75.0", "nest-asyncio>=1.6.0",]
1313
[[project.authors]]
1414
name = "Browserbase, Inc."
1515

stagehand/config.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
2-
from typing import Any, Callable, Optional
3-
from urllib.parse import urlparse
2+
from typing import Any, Callable, Literal, Optional, Union
43

4+
from browserbase.types import SessionCreateParams as BrowserbaseSessionCreateParams
55
from pydantic import BaseModel, ConfigDict, Field, field_validator, ValidationError
66

77
from stagehand.schemas import AvailableModel
@@ -78,7 +78,14 @@ class StagehandConfig(BaseModel):
7878
dom_settle_timeout_ms: Optional[int] = Field(
7979
3000,
8080
alias="domSettleTimeoutMs",
81-
description="Timeout in milliseconds to wait for DOM to settle after actions",
81+
description="Timeout for DOM to settle (in ms)",
82+
)
83+
browserbase_session_create_params: Optional[
84+
Union[BrowserbaseSessionCreateParams, dict[str, Any]]
85+
] = Field(
86+
None,
87+
alias="browserbaseSessionCreateParams",
88+
description="Browserbase session create params",
8289
)
8390
enable_caching: Optional[bool] = Field(
8491
False,
@@ -171,6 +178,16 @@ def validate_dom_settle_timeout(cls, v):
171178
"""Validate DOM settle timeout is positive."""
172179
if v is not None and v < 0:
173180
raise ValueError("dom_settle_timeout_ms must be non-negative")
181+
182+
@field_validator("browserbase_session_create_params", mode="before")
183+
@classmethod
184+
def validate_browserbase_params(cls, v, info):
185+
"""Validate and convert browserbase session create params."""
186+
if isinstance(v, dict) and "project_id" not in v:
187+
values = info.data
188+
project_id = values.get("project_id") or values.get("projectId")
189+
if project_id:
190+
v = {**v, "project_id": project_id}
174191
return v
175192

176193
def with_overrides(self, **overrides) -> "StagehandConfig":

stagehand/handlers/observe_handler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ async def observe(
118118

119119
# Draw overlay if requested
120120
if options.draw_overlay:
121-
await draw_observe_overlay(self.stagehand_page, elements_with_selectors)
121+
await draw_observe_overlay(
122+
page=self.stagehand_page,
123+
elements=[el.model_dump() for el in elements_with_selectors],
124+
)
122125

123126
# Return the list of results without trying to attach _llm_response
124127
return elements_with_selectors

stagehand/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def format_simplified_tree(node: AccessibilityNode, level: int = 0) -> str:
7979
return result
8080

8181

82-
async def draw_observe_overlay(page, elements):
82+
async def draw_observe_overlay(page, elements: list[dict]):
8383
"""
8484
Draw an overlay on the page highlighting the observed elements.
8585

0 commit comments

Comments
 (0)