Skip to content

Commit de77533

Browse files
update agent with proxy
1 parent a3d5011 commit de77533

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

examples/agent_example.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from stagehand import Stagehand, StagehandConfig, AgentConfig, configure_logging
1111
from stagehand.schemas import AgentExecuteOptions, AgentProvider
1212

13+
from browserbase.types import SessionCreateParams as BrowserbaseSessionCreateParams
14+
1315
# Create a custom theme for consistent styling
1416
custom_theme = Theme(
1517
{
@@ -27,6 +29,11 @@
2729

2830
load_dotenv()
2931

32+
browserbase_session_create_params = BrowserbaseSessionCreateParams(
33+
project_id=os.getenv("BROWSERBASE_PROJECT_ID"),
34+
proxies=True,
35+
)
36+
3037
# Configure logging with the utility function
3138
configure_logging(
3239
level=logging.INFO, # Set to INFO for regular logs, DEBUG for detailed
@@ -40,6 +47,7 @@ async def main():
4047
# env="LOCAL",
4148
api_key=os.getenv("BROWSERBASE_API_KEY"),
4249
project_id=os.getenv("BROWSERBASE_PROJECT_ID"),
50+
browserbase_session_create_params=browserbase_session_create_params,
4351
model_name="gpt-4o",
4452
self_heal=True,
4553
system_prompt="You are a browser automation assistant that helps users navigate websites effectively.",
@@ -70,7 +78,7 @@ async def main():
7078
options={"apiKey": os.getenv("MODEL_API_KEY")}
7179
)
7280
agent_result = await agent.execute(
73-
instruction="Play a game of 2048",
81+
instruction="Search for the game 2048 and play one game.",
7482
max_steps=20,
7583
auto_screenshot=True,
7684
)

0 commit comments

Comments
 (0)