File tree Expand file tree Collapse file tree 4 files changed +16
-2
lines changed Expand file tree Collapse file tree 4 files changed +16
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @browserbasehq/stagehand " : patch
3
+ ---
4
+
5
+ support api usage for extract with no args
Original file line number Diff line number Diff line change @@ -547,6 +547,9 @@ export class StagehandPage {
547
547
548
548
// check if user called extract() with no arguments
549
549
if ( ! instructionOrOptions ) {
550
+ if ( this . api ) {
551
+ return this . api . extract < T > ( { } ) ;
552
+ }
550
553
return this . extractHandler . extract ( ) ;
551
554
}
552
555
Original file line number Diff line number Diff line change @@ -91,6 +91,12 @@ export class StagehandAPI {
91
91
async extract < T extends z . AnyZodObject > (
92
92
options : ExtractOptions < T > ,
93
93
) : Promise < ExtractResult < T > > {
94
+ if ( ! options . schema ) {
95
+ return this . execute < ExtractResult < T > > ( {
96
+ method : "extract" ,
97
+ args : { } ,
98
+ } ) ;
99
+ }
94
100
const parsedSchema = zodToJsonSchema ( options . schema ) ;
95
101
return this . execute < ExtractResult < T > > ( {
96
102
method : "extract" ,
Original file line number Diff line number Diff line change @@ -98,8 +98,8 @@ export interface ActResult {
98
98
}
99
99
100
100
export interface ExtractOptions < T extends z . AnyZodObject > {
101
- instruction : string ;
102
- schema : T ;
101
+ instruction ? : string ;
102
+ schema ? : T ;
103
103
modelName ?: AvailableModel ;
104
104
modelClientOptions ?: ClientOptions ;
105
105
domSettleTimeoutMs ?: number ;
You can’t perform that action at this time.
0 commit comments