upgrade stagehand:2.4.3 and switch to gpt-5

This commit is contained in:
Krishav Raj Singh 2025-08-21 03:57:30 +05:30
parent 0335d6d36d
commit ea9531d1d2
4 changed files with 8 additions and 12 deletions

View File

@ -150,7 +150,7 @@ class BrowserTool(SandboxToolsBase):
return True
else:
# If the browser api is not healthy, we need to restart the browser api
model_api_key = config.ANTHROPIC_API_KEY
model_api_key = config.OPENAI_API_KEY
response = await self.sandbox.process.exec(f"curl -X POST 'http://localhost:8004/api/init' -H 'Content-Type: application/json' -d '{{\"api_key\": \"{model_api_key}\"}}'", timeout=90)
if response.exit_code == 0:

View File

@ -19,12 +19,10 @@ class BrowserAutomation {
private stagehand: Stagehand | null;
public browserInitialized: boolean;
private currentApiKey: string | null;
private page: Page | null;
constructor() {
this.router = express.Router();
this.browserInitialized = false;
this.currentApiKey = null;
this.stagehand = null;
this.page = null;
@ -38,7 +36,6 @@ class BrowserAutomation {
async init(apiKey: string): Promise<{status: string, message: string}> {
try{
if (!this.browserInitialized) {
this.currentApiKey = apiKey;
console.log("Initializing browser with api key");
this.stagehand = new Stagehand({
env: "LOCAL",
@ -47,7 +44,7 @@ class BrowserAutomation {
logger: (logLine: LogLine) => {
console.log(`[${logLine.category}] ${logLine.message}`);
},
modelName: "claude-3-7-sonnet-20250219",
modelName: "openai/gpt-5",
modelClientOptions: {
apiKey
},
@ -129,7 +126,6 @@ class BrowserAutomation {
this.stagehand?.close();
this.stagehand = null;
this.page = null;
this.currentApiKey = null;
return {
status: "shutdown",
message: "Browser shutdown"

View File

@ -9,7 +9,7 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@browserbasehq/stagehand": "^2.4.2",
"@browserbasehq/stagehand": "^2.4.3",
"express": "^5.1.0",
"tsx": "^4.19.2",
"typescript": "^5.9.2"
@ -359,9 +359,9 @@
"license": "MIT"
},
"node_modules/@browserbasehq/stagehand": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/@browserbasehq/stagehand/-/stagehand-2.4.2.tgz",
"integrity": "sha512-JEneBRa7Xanc5L6Z7iucseWoTUqAqW6z0/IC6VUpgGMCY5k38+voz7pBxI12hWOtWpvyy9wTaVkLY8YiWZrBUw==",
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/@browserbasehq/stagehand/-/stagehand-2.4.3.tgz",
"integrity": "sha512-iloQM/SbDH2ip7RC7yO/fbRoDPtdoaHbOeob3US0OvFBiSb6rMMLP2PQ+euEGhsc7sNMcs9+UJiA1Ts5H+jhiA==",
"license": "MIT",
"dependencies": {
"@anthropic-ai/sdk": "0.39.0",
@ -394,7 +394,7 @@
"peerDependencies": {
"deepmerge": "^4.3.1",
"dotenv": "^16.4.5",
"zod": "^3.23.8"
"zod": ">=3.25.0 <4.1.0"
}
},
"node_modules/@esbuild/aix-ppc64": {

View File

@ -10,7 +10,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@browserbasehq/stagehand": "^2.4.2",
"@browserbasehq/stagehand": "^2.4.3",
"express": "^5.1.0",
"tsx": "^4.19.2",
"typescript": "^5.9.2"