Skip to content

Commit 7b65ca7

Browse files
feat: Add screenshot option to Extract
1 parent 4b65f22 commit 7b65ca7

4 files changed

Lines changed: 35 additions & 3 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 8
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-e77d6b15f0a94b16a54ef87a84d2cabe49eb11cff5ceba76f00dd788ff483eab.yml
3-
openapi_spec_hash: a1dab7fe72a772d188a15305124ebd73
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-80502d74c1be605e77d45ff2b54297fe34ce85dbad1e8f2dfa30ba6d09601219.yml
3+
openapi_spec_hash: fd62f768756a400c3ecd695bfcf3845a
44
config_hash: 1fb12ae9b478488bc1e56bfbdc210b01

lib/stagehand/models/session_extract_params.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ class Options < Stagehand::Internal::Type::BaseModel
7272
# @return [Stagehand::Models::ModelConfig, String, nil]
7373
optional :model, union: -> { Stagehand::SessionExtractParams::Options::Model }
7474

75+
# @!attribute screenshot
76+
# When true, include a screenshot of the current viewport in the extraction LLM
77+
# call. Defaults to false.
78+
#
79+
# @return [Boolean, nil]
80+
optional :screenshot, Stagehand::Internal::Type::Boolean
81+
7582
# @!attribute selector
7683
# CSS selector to scope extraction to a specific element
7784
#
@@ -84,11 +91,16 @@ class Options < Stagehand::Internal::Type::BaseModel
8491
# @return [Float, nil]
8592
optional :timeout, Float
8693

87-
# @!method initialize(ignore_selectors: nil, model: nil, selector: nil, timeout: nil)
94+
# @!method initialize(ignore_selectors: nil, model: nil, screenshot: nil, selector: nil, timeout: nil)
95+
# Some parameter documentations has been truncated, see
96+
# {Stagehand::Models::SessionExtractParams::Options} for more details.
97+
#
8898
# @param ignore_selectors [Array<String>] Selectors for elements and subtrees that should be excluded from extraction
8999
#
90100
# @param model [Stagehand::Models::ModelConfig, String] Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
91101
#
102+
# @param screenshot [Boolean] When true, include a screenshot of the current viewport in the extraction LLM ca
103+
#
92104
# @param selector [String] CSS selector to scope extraction to a specific element
93105
#
94106
# @param timeout [Float] Timeout in ms for the extraction

rbi/stagehand/models/session_extract_params.rbi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ module Stagehand
127127
end
128128
attr_writer :model
129129

130+
# When true, include a screenshot of the current viewport in the extraction LLM
131+
# call. Defaults to false.
132+
sig { returns(T.nilable(T::Boolean)) }
133+
attr_reader :screenshot
134+
135+
sig { params(screenshot: T::Boolean).void }
136+
attr_writer :screenshot
137+
130138
# CSS selector to scope extraction to a specific element
131139
sig { returns(T.nilable(String)) }
132140
attr_reader :selector
@@ -145,6 +153,7 @@ module Stagehand
145153
params(
146154
ignore_selectors: T::Array[String],
147155
model: T.any(Stagehand::ModelConfig::OrHash, String),
156+
screenshot: T::Boolean,
148157
selector: String,
149158
timeout: Float
150159
).returns(T.attached_class)
@@ -154,6 +163,9 @@ module Stagehand
154163
ignore_selectors: nil,
155164
# Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
156165
model: nil,
166+
# When true, include a screenshot of the current viewport in the extraction LLM
167+
# call. Defaults to false.
168+
screenshot: nil,
157169
# CSS selector to scope extraction to a specific element
158170
selector: nil,
159171
# Timeout in ms for the extraction
@@ -166,6 +178,7 @@ module Stagehand
166178
{
167179
ignore_selectors: T::Array[String],
168180
model: T.any(Stagehand::ModelConfig, String),
181+
screenshot: T::Boolean,
169182
selector: String,
170183
timeout: Float
171184
}

sig/stagehand/models/session_extract_params.rbs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ module Stagehand
6363
{
6464
ignore_selectors: ::Array[String],
6565
model: Stagehand::Models::SessionExtractParams::Options::model,
66+
screenshot: bool,
6667
selector: String,
6768
timeout: Float
6869
}
@@ -78,6 +79,10 @@ module Stagehand
7879
Stagehand::Models::SessionExtractParams::Options::model
7980
) -> Stagehand::Models::SessionExtractParams::Options::model
8081

82+
attr_reader screenshot: bool?
83+
84+
def screenshot=: (bool) -> bool
85+
8186
attr_reader selector: String?
8287

8388
def selector=: (String) -> String
@@ -89,13 +94,15 @@ module Stagehand
8994
def initialize: (
9095
?ignore_selectors: ::Array[String],
9196
?model: Stagehand::Models::SessionExtractParams::Options::model,
97+
?screenshot: bool,
9298
?selector: String,
9399
?timeout: Float
94100
) -> void
95101

96102
def to_hash: -> {
97103
ignore_selectors: ::Array[String],
98104
model: Stagehand::Models::SessionExtractParams::Options::model,
105+
screenshot: bool,
99106
selector: String,
100107
timeout: Float
101108
}

0 commit comments

Comments
 (0)