@@ -123,120 +123,76 @@ const peeler_complex = async () => {
123
123
124
124
return price !== null ;
125
125
} ;
126
+
126
127
const extract_collaborators_from_github_repository = async ( ) => {
127
- const stagehand = new Stagehand ( { env : "LOCAL" , verbose : 1 } ) ;
128
+ const stagehand = new Stagehand ( {
129
+ env : "LOCAL" ,
130
+ verbose : 1 ,
131
+ headless : process . env . HEADLESS !== "false" ,
132
+ } ) ;
128
133
await stagehand . init ( ) ;
129
134
130
- const timeoutPromise = new Promise ( ( _ , reject ) =>
131
- setTimeout ( ( ) => reject ( new Error ( "Operation timed out" ) ) , 60000 ) ,
132
- ) ;
133
-
134
135
try {
135
- const extractionPromise = ( async ( ) => {
136
- await stagehand . page . goto ( "https://github.com/facebook/react" ) ;
137
- await stagehand . act ( {
138
- action : "find the contributors section" ,
139
- } ) ;
140
-
141
- await stagehand . waitForSettledDom ( ) ;
142
-
143
- const { contributors } = await stagehand . extract ( {
144
- instruction : "Extract top 20 contributors of this repository" ,
145
- schema : z . object ( {
146
- contributors : z . array (
147
- z . object ( {
148
- github_username : z . string ( ) ,
149
- information : z . string ( ) ,
150
- } ) ,
151
- ) ,
152
- } ) ,
153
- modelName : "gpt-4o-2024-08-06" ,
154
- } ) ;
155
-
156
- console . log ( "Extracted collaborators:" , contributors ) ;
157
- return contributors . length === 20 ;
158
- } ) ( ) ;
159
-
160
- const result = await Promise . race ( [ extractionPromise , timeoutPromise ] ) ;
161
- await stagehand . context . close ( ) ;
162
- return result ;
163
- } catch ( error ) {
164
- console . error ( "Error or timeout occurred:" , error ) ;
165
- await stagehand . context . close ( ) ;
166
- return false ;
167
- }
168
- } ;
136
+ await stagehand . page . goto ( "https://github.com/facebook/react" ) ;
137
+ await stagehand . act ( {
138
+ action : "find the contributors section" ,
139
+ } ) ;
169
140
170
- const extract_last_twenty_github_commits = async ( ) => {
171
- const stagehand = new Stagehand ( { env : "LOCAL" , verbose : 1 } ) ;
172
- await stagehand . init ( ) ;
141
+ await stagehand . waitForSettledDom ( ) ;
173
142
174
- const timeoutPromise = new Promise ( ( _ , reject ) =>
175
- setTimeout ( ( ) => reject ( new Error ( "Operation timed out" ) ) , 60000 ) ,
176
- ) ;
143
+ const { contributors } = await stagehand . extract ( {
144
+ instruction : "Extract top 20 contributors of this repository" ,
145
+ schema : z . object ( {
146
+ contributors : z . array (
147
+ z . object ( {
148
+ github_username : z . string ( ) ,
149
+ information : z . string ( ) ,
150
+ } ) ,
151
+ ) ,
152
+ } ) ,
153
+ modelName : "gpt-4o-2024-08-06" ,
154
+ } ) ;
177
155
178
- try {
179
- const extractionPromise = ( async ( ) => {
180
- await stagehand . page . goto ( "https://github.com/facebook/react" ) ;
181
-
182
- await stagehand . waitForSettledDom ( ) ;
183
-
184
- const { commits } = await stagehand . extract ( {
185
- instruction : "Extract last 20 commits" ,
186
- schema : z . object ( {
187
- commits : z . array (
188
- z . object ( {
189
- commit_message : z . string ( ) ,
190
- commit_url : z . string ( ) ,
191
- commit_hash : z . string ( ) ,
192
- } ) ,
193
- ) ,
194
- } ) ,
195
- modelName : "gpt-4o-2024-08-06" ,
196
- } ) ;
197
-
198
- console . log ( "Extracted commits:" , commits ) ;
199
- return commits . length === 20 ;
200
- } ) ( ) ;
201
-
202
- const result = await Promise . race ( [ extractionPromise , timeoutPromise ] ) ;
156
+ console . log ( "Extracted collaborators:" , contributors ) ;
203
157
await stagehand . context . close ( ) ;
204
- return result ;
158
+ return contributors . length === 20 ;
205
159
} catch ( error ) {
206
160
console . error ( "Error or timeout occurred:" , error ) ;
207
161
await stagehand . context . close ( ) ;
208
162
return false ;
209
163
}
210
164
} ;
211
165
212
- const twitter_signup = async ( ) => {
213
- const stagehand = new Stagehand ( { env : "LOCAL" , verbose : 1 } ) ;
166
+ const extract_last_twenty_github_commits = async ( ) => {
167
+ const stagehand = new Stagehand ( {
168
+ env : "LOCAL" ,
169
+ verbose : 1 ,
170
+ headless : process . env . HEADLESS !== "false" ,
171
+ } ) ;
214
172
await stagehand . init ( ) ;
215
173
216
- const timeoutPromise = new Promise ( ( _ , reject ) =>
217
- setTimeout ( ( ) => reject ( new Error ( "Operation timed out" ) ) , 120000 ) ,
218
- ) ;
219
-
220
174
try {
221
- const signupPromise = ( async ( ) => {
222
- await stagehand . page . goto ( "https://twitter.com" ) ;
223
-
224
- await stagehand . act ( {
225
- action :
226
- 'sign up with email "{random 12 digit number}@gmail.com", password "TEstTEst.1234". Use whatever else you want for all other fields. You can only stop if you have reached the verification stage.' ,
227
- } ) ;
228
-
229
- await stagehand . waitForSettledDom ( ) ;
175
+ await stagehand . page . goto ( "https://github.com/facebook/react" ) ;
230
176
231
- // Add a check here to verify if signup was successful
232
- // For example, check if a certain element is visible after signup
177
+ await stagehand . waitForSettledDom ( ) ;
233
178
234
- return true ; // Return true if signup was successful
235
- } ) ( ) ;
179
+ const { commits } = await stagehand . extract ( {
180
+ instruction : "Extract last 20 commits" ,
181
+ schema : z . object ( {
182
+ commits : z . array (
183
+ z . object ( {
184
+ commit_message : z . string ( ) ,
185
+ commit_url : z . string ( ) ,
186
+ commit_hash : z . string ( ) ,
187
+ } ) ,
188
+ ) ,
189
+ } ) ,
190
+ modelName : "gpt-4o-2024-08-06" ,
191
+ } ) ;
236
192
237
- const result = await Promise . race ( [ signupPromise , timeoutPromise ] ) ;
193
+ console . log ( "Extracted commits:" , commits ) ;
238
194
await stagehand . context . close ( ) ;
239
- return result ;
195
+ return commits . length === 20 ;
240
196
} catch ( error ) {
241
197
console . error ( "Error or timeout occurred:" , error ) ;
242
198
await stagehand . context . close ( ) ;
@@ -396,7 +352,6 @@ const tasks = {
396
352
simple_google_search,
397
353
extract_collaborators_from_github_repository,
398
354
extract_last_twenty_github_commits,
399
- twitter_signup,
400
355
costar,
401
356
google_jobs,
402
357
} ;
@@ -406,7 +361,7 @@ const exactMatch = (args: { input; output; expected? }) => {
406
361
407
362
return {
408
363
name : "Exact match" ,
409
- score : Boolean ( args . output ) ? 1 : 0 ,
364
+ score : args . output === true || args . output ?. success == true ,
410
365
} ;
411
366
} ;
412
367
@@ -433,7 +388,6 @@ const testcases = [
433
388
{ input : { name : "simple_google_search" } } ,
434
389
{ input : { name : "extract_collaborators_from_github_repository" } } ,
435
390
{ input : { name : "extract_last_twenty_github_commits" } } ,
436
- { input : { name : "twitter_signup" } } ,
437
391
// { input: { name: "costar" } },
438
392
{ input : { name : "google_jobs" } } ,
439
393
...chosenBananalyzerEvals . map ( ( evalItem : any ) => ( {
@@ -496,4 +450,5 @@ Eval("stagehand", {
496
450
}
497
451
} ,
498
452
scores : [ exactMatch ] ,
453
+ // trialCount: 3,
499
454
} ) ;
0 commit comments