@@ -635,6 +635,7 @@ private constructor(
635635 private constructor (
636636 private val ignoreSelectors: JsonField <List <String >>,
637637 private val model: JsonField <Model >,
638+ private val screenshot: JsonField <Boolean >,
638639 private val selector: JsonField <String >,
639640 private val timeout: JsonField <Double >,
640641 private val additionalProperties: MutableMap <String , JsonValue >,
@@ -646,11 +647,14 @@ private constructor(
646647 @ExcludeMissing
647648 ignoreSelectors: JsonField <List <String >> = JsonMissing .of(),
648649 @JsonProperty(" model" ) @ExcludeMissing model: JsonField <Model > = JsonMissing .of(),
650+ @JsonProperty(" screenshot" )
651+ @ExcludeMissing
652+ screenshot: JsonField <Boolean > = JsonMissing .of(),
649653 @JsonProperty(" selector" )
650654 @ExcludeMissing
651655 selector: JsonField <String > = JsonMissing .of(),
652656 @JsonProperty(" timeout" ) @ExcludeMissing timeout: JsonField <Double > = JsonMissing .of(),
653- ) : this (ignoreSelectors, model, selector, timeout, mutableMapOf ())
657+ ) : this (ignoreSelectors, model, screenshot, selector, timeout, mutableMapOf ())
654658
655659 /* *
656660 * Selectors for elements and subtrees that should be excluded from extraction
@@ -669,6 +673,15 @@ private constructor(
669673 */
670674 fun model (): Optional <Model > = model.getOptional(" model" )
671675
676+ /* *
677+ * When true, include a screenshot of the current viewport in the extraction LLM call.
678+ * Defaults to false.
679+ *
680+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
681+ * the server responded with an unexpected value).
682+ */
683+ fun screenshot (): Optional <Boolean > = screenshot.getOptional(" screenshot" )
684+
672685 /* *
673686 * CSS selector to scope extraction to a specific element
674687 *
@@ -702,6 +715,15 @@ private constructor(
702715 */
703716 @JsonProperty(" model" ) @ExcludeMissing fun _model (): JsonField <Model > = model
704717
718+ /* *
719+ * Returns the raw JSON value of [screenshot].
720+ *
721+ * Unlike [screenshot], this method doesn't throw if the JSON field has an unexpected type.
722+ */
723+ @JsonProperty(" screenshot" )
724+ @ExcludeMissing
725+ fun _screenshot (): JsonField <Boolean > = screenshot
726+
705727 /* *
706728 * Returns the raw JSON value of [selector].
707729 *
@@ -739,6 +761,7 @@ private constructor(
739761
740762 private var ignoreSelectors: JsonField <MutableList <String >>? = null
741763 private var model: JsonField <Model > = JsonMissing .of()
764+ private var screenshot: JsonField <Boolean > = JsonMissing .of()
742765 private var selector: JsonField <String > = JsonMissing .of()
743766 private var timeout: JsonField <Double > = JsonMissing .of()
744767 private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
@@ -747,6 +770,7 @@ private constructor(
747770 internal fun from (options : Options ) = apply {
748771 ignoreSelectors = options.ignoreSelectors.map { it.toMutableList() }
749772 model = options.model
773+ screenshot = options.screenshot
750774 selector = options.selector
751775 timeout = options.timeout
752776 additionalProperties = options.additionalProperties.toMutableMap()
@@ -797,6 +821,21 @@ private constructor(
797821 /* * Alias for calling [model] with `Model.ofString(string)`. */
798822 fun model (string : String ) = model(Model .ofString(string))
799823
824+ /* *
825+ * When true, include a screenshot of the current viewport in the extraction LLM call.
826+ * Defaults to false.
827+ */
828+ fun screenshot (screenshot : Boolean ) = screenshot(JsonField .of(screenshot))
829+
830+ /* *
831+ * Sets [Builder.screenshot] to an arbitrary JSON value.
832+ *
833+ * You should usually call [Builder.screenshot] with a well-typed [Boolean] value
834+ * instead. This method is primarily for setting the field to an undocumented or not yet
835+ * supported value.
836+ */
837+ fun screenshot (screenshot : JsonField <Boolean >) = apply { this .screenshot = screenshot }
838+
800839 /* * CSS selector to scope extraction to a specific element */
801840 fun selector (selector : String ) = selector(JsonField .of(selector))
802841
@@ -849,6 +888,7 @@ private constructor(
849888 Options (
850889 (ignoreSelectors ? : JsonMissing .of()).map { it.toImmutable() },
851890 model,
891+ screenshot,
852892 selector,
853893 timeout,
854894 additionalProperties.toMutableMap(),
@@ -873,6 +913,7 @@ private constructor(
873913
874914 ignoreSelectors()
875915 model().ifPresent { it.validate() }
916+ screenshot()
876917 selector()
877918 timeout()
878919 validated = true
@@ -896,6 +937,7 @@ private constructor(
896937 internal fun validity (): Int =
897938 (ignoreSelectors.asKnown().getOrNull()?.size ? : 0 ) +
898939 (model.asKnown().getOrNull()?.validity() ? : 0 ) +
940+ (if (screenshot.asKnown().isPresent) 1 else 0 ) +
899941 (if (selector.asKnown().isPresent) 1 else 0 ) +
900942 (if (timeout.asKnown().isPresent) 1 else 0 )
901943
@@ -1119,19 +1161,27 @@ private constructor(
11191161 return other is Options &&
11201162 ignoreSelectors == other.ignoreSelectors &&
11211163 model == other.model &&
1164+ screenshot == other.screenshot &&
11221165 selector == other.selector &&
11231166 timeout == other.timeout &&
11241167 additionalProperties == other.additionalProperties
11251168 }
11261169
11271170 private val hashCode: Int by lazy {
1128- Objects .hash(ignoreSelectors, model, selector, timeout, additionalProperties)
1171+ Objects .hash(
1172+ ignoreSelectors,
1173+ model,
1174+ screenshot,
1175+ selector,
1176+ timeout,
1177+ additionalProperties,
1178+ )
11291179 }
11301180
11311181 override fun hashCode (): Int = hashCode
11321182
11331183 override fun toString () =
1134- " Options{ignoreSelectors=$ignoreSelectors , model=$model , selector=$selector , timeout=$timeout , additionalProperties=$additionalProperties }"
1184+ " Options{ignoreSelectors=$ignoreSelectors , model=$model , screenshot= $screenshot , selector=$selector , timeout=$timeout , additionalProperties=$additionalProperties }"
11351185 }
11361186
11371187 /* * JSON Schema defining the structure of data to extract */
0 commit comments