| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
… id to browserbase params before field validation
|
Hey Derek - here's the changes needed (formatting, and a test): diff --git a/stagehand/config.py b/stagehand/config.py
index bfe7395..e69faa2 100644
--- a/stagehand/config.py
+++ b/stagehand/config.py
@@ -71,7 +71,9 @@ class StagehandConfig(BaseModel):
alias="domSettleTimeoutMs",
description="Timeout for DOM to settle (in ms)",
)
- browserbase_session_create_params: Optional[Union[BrowserbaseSessionCreateParams, dict[str, Any]]] = Field(
+ browserbase_session_create_params: Optional[
+ Union[BrowserbaseSessionCreateParams, dict[str, Any]]
+ ] = Field(
None,
alias="browserbaseSessionCreateParams",
description="Browserbase session create params",
@@ -117,16 +119,16 @@ class StagehandConfig(BaseModel):
)
model_config = ConfigDict(populate_by_name=True)
-
- @field_validator('browserbase_session_create_params', mode='before')
+
+ @field_validator("browserbase_session_create_params", mode="before")
@classmethod
def validate_browserbase_params(cls, v, info):
"""Validate and convert browserbase session create params."""
- if isinstance(v, dict) and 'project_id' not in v:
+ if isinstance(v, dict) and "project_id" not in v:
values = info.data
- project_id = values.get('project_id') or values.get('projectId')
+ project_id = values.get("project_id") or values.get("projectId")
if project_id:
- v = {**v, 'project_id': project_id}
+ v = {**v, "project_id": project_id}
return v
def with_overrides(self, **overrides) -> "StagehandConfig":
diff --git a/tests/integration/local/test_core_local.py b/tests/integration/local/test_core_local.py
index 0eb11ab..c1190ea 100644
--- a/tests/integration/local/test_core_local.py
+++ b/tests/integration/local/test_core_local.py
@@ -20,7 +20,7 @@ class TestStagehandLocalIntegration:
self_heal=True,
wait_for_captcha_solves=False,
system_prompt="You are a browser automation assistant for testing purposes.",
- model_client_options={"apiKey": os.getenv("MODEL_API_KEY")},
+ model_client_options={"apiKey": os.getenv("MODEL_API_KEY") or os.getenv("OPENAI_API_KEY")},
use_api=False,
)
|
Sorry, something went wrong.
|
we should probably do this on the server side instead in stagehand-api |
Sorry, something went wrong.
| description="Timeout for DOM to settle (in ms)", | ||
| ) | ||
| browserbase_session_create_params: Optional[BrowserbaseSessionCreateParams] = Field( | ||
| browserbase_session_create_params: Optional[Union[BrowserbaseSessionCreateParams, dict[str, Any]]] = Field( |
There was a problem hiding this comment.
The underlying type provided by browserbase.types should be changed in the upstream repo instead of weakening the type to dict[str, Any] here.
If thats not possible, at least do something like:
class BBSessionCreateParamsWithOptionalProjectId(BrowserbaseSessionCreateParams):
project_id: str | None = None
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
why
if you add custom browserbase create params, you need to include the project id even if the project id is already passed to the stagehand instance
what changed
relaxed browserbase params definition and added a field validator to add project id from the stagehand config before validating structure
test plan
ran tests with shell command