Skip to content

Commit 27fa631

Browse files
author
stlc-bot
committed
fix(scrape): derive the /web/scrape request spec from its zod schema (#2044)
Stainless-Generated-From: ca75d4ad4dad949ac5808c11d10b7ca8f98ee9c1
1 parent eb65b3e commit 27fa631

5 files changed

Lines changed: 34 additions & 21 deletions

File tree

‎src/context/dev/resources/web.py‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,9 @@ def scrape(
413413
414414
shared_params: Browser and content settings shared by all outputs.
415415
416-
tags: Labels for tracking request usage. Not retained when zdr is enabled.
416+
tags: Labels for filtering usage in the dashboard.
417417
418-
timeout_opts: Deadline for the whole request. Defaults to 90000 ms with `fail`. Fixed waits
419-
must end before it.
418+
timeout_opts: Request deadline and what to return when it passes.
420419
421420
zdr: `enabled` turns on zero data retention. Your organization must have ZDR enabled.
422421
@@ -1952,10 +1951,9 @@ async def scrape(
19521951
19531952
shared_params: Browser and content settings shared by all outputs.
19541953
1955-
tags: Labels for tracking request usage. Not retained when zdr is enabled.
1954+
tags: Labels for filtering usage in the dashboard.
19561955
1957-
timeout_opts: Deadline for the whole request. Defaults to 90000 ms with `fail`. Fixed waits
1958-
must end before it.
1956+
timeout_opts: Request deadline and what to return when it passes.
19591957
19601958
zdr: `enabled` turns on zero data retention. Your organization must have ZDR enabled.
19611959

‎src/context/dev/types/batch_submit_params.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,9 @@ class InputScrapeDataBatchUnifiedScrapeDataProductParams(TypedDict, total=False)
10001000
dedupe_images: Annotated[bool, PropertyInfo(alias="dedupeImages")]
10011001
"""Drop visually duplicate product images, keeping the largest copy."""
10021002

1003+
use_ai_fallback: Annotated[bool, PropertyInfo(alias="useAIFallback")]
1004+
"""Ignored. The AI fallback runs automatically."""
1005+
10031006

10041007
class InputScrapeDataBatchUnifiedScrapeDataScreenshotParamsAreaElement(TypedDict, total=False):
10051008
selector: Required[str]
@@ -1293,7 +1296,7 @@ class InputScrapeDataBatchUnifiedScrapeData(TypedDict, total=False):
12931296
"""Browser and content settings shared by all outputs."""
12941297

12951298
tags: SequenceNotStr[str]
1296-
"""Labels for tracking request usage. Not retained when zdr is enabled."""
1299+
"""Labels for filtering usage in the dashboard."""
12971300

12981301
timeout_opts: Annotated[InputScrapeDataBatchUnifiedScrapeDataTimeoutOpts, PropertyInfo(alias="timeoutOpts")]
12991302
"""
@@ -2637,6 +2640,9 @@ class InputCrawlDataBatchUnifiedCrawlDataProductParams(TypedDict, total=False):
26372640
dedupe_images: Annotated[bool, PropertyInfo(alias="dedupeImages")]
26382641
"""Drop visually duplicate product images, keeping the largest copy."""
26392642

2643+
use_ai_fallback: Annotated[bool, PropertyInfo(alias="useAIFallback")]
2644+
"""Ignored. The AI fallback runs automatically."""
2645+
26402646

26412647
class InputCrawlDataBatchUnifiedCrawlDataScreenshotParamsAreaElement(TypedDict, total=False):
26422648
selector: Required[str]
@@ -2927,7 +2933,7 @@ class InputCrawlDataBatchUnifiedCrawlData(TypedDict, total=False):
29272933
"""Browser and content settings shared by all outputs."""
29282934

29292935
tags: SequenceNotStr[str]
2930-
"""Labels for tracking request usage. Not retained when zdr is enabled."""
2936+
"""Labels for filtering usage in the dashboard."""
29312937

29322938
timeout_opts: Annotated[InputCrawlDataBatchUnifiedCrawlDataTimeoutOpts, PropertyInfo(alias="timeoutOpts")]
29332939
"""

‎src/context/dev/types/web_scrape_params.py‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,10 @@ class WebScrapeParams(TypedDict, total=False):
8383
"""Browser and content settings shared by all outputs."""
8484

8585
tags: SequenceNotStr[str]
86-
"""Labels for tracking request usage. Not retained when zdr is enabled."""
86+
"""Labels for filtering usage in the dashboard."""
8787

8888
timeout_opts: Annotated[TimeoutOpts, PropertyInfo(alias="timeoutOpts")]
89-
"""Deadline for the whole request.
90-
91-
Defaults to 90000 ms with `fail`. Fixed waits must end before it.
92-
"""
89+
"""Request deadline and what to return when it passes."""
9390

9491
zdr: Literal["enabled", "disabled"]
9592
"""`enabled` turns on zero data retention.
@@ -337,6 +334,9 @@ class ProductParams(TypedDict, total=False):
337334
dedupe_images: Annotated[bool, PropertyInfo(alias="dedupeImages")]
338335
"""Drop visually duplicate product images, keeping the largest copy."""
339336

337+
use_ai_fallback: Annotated[bool, PropertyInfo(alias="useAIFallback")]
338+
"""Ignored. The AI fallback runs automatically."""
339+
340340

341341
class ScreenshotParamsAreaElement(TypedDict, total=False):
342342
selector: Required[str]
@@ -557,10 +557,7 @@ class SharedParams(TypedDict, total=False):
557557

558558

559559
class TimeoutOpts(TypedDict, total=False):
560-
"""Deadline for the whole request.
561-
562-
Defaults to 90000 ms with `fail`. Fixed waits must end before it.
563-
"""
560+
"""Request deadline and what to return when it passes."""
564561

565562
milliseconds: Required[int]
566563
"""Deadline in milliseconds."""

‎tests/api_resources/test_batch.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ def test_method_submit_with_all_params(self, client: ContextDev) -> None:
325325
},
326326
"type": "custom",
327327
},
328-
"product_params": {"dedupe_images": True},
328+
"product_params": {
329+
"dedupe_images": True,
330+
"use_ai_fallback": True,
331+
},
329332
"screenshot_params": {
330333
"area": "viewport",
331334
"format": "png",
@@ -736,7 +739,10 @@ async def test_method_submit_with_all_params(self, async_client: AsyncContextDev
736739
},
737740
"type": "custom",
738741
},
739-
"product_params": {"dedupe_images": True},
742+
"product_params": {
743+
"dedupe_images": True,
744+
"use_ai_fallback": True,
745+
},
740746
"screenshot_params": {
741747
"area": "viewport",
742748
"format": "png",

‎tests/api_resources/test_web.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,10 @@ def test_method_scrape_with_all_params(self, client: ContextDev) -> None:
292292
"type": "custom",
293293
},
294294
policies=["pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e"],
295-
product_params={"dedupe_images": True},
295+
product_params={
296+
"dedupe_images": True,
297+
"use_ai_fallback": True,
298+
},
296299
screenshot_params={
297300
"area": "viewport",
298301
"format": "png",
@@ -851,7 +854,10 @@ async def test_method_scrape_with_all_params(self, async_client: AsyncContextDev
851854
"type": "custom",
852855
},
853856
policies=["pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e"],
854-
product_params={"dedupe_images": True},
857+
product_params={
858+
"dedupe_images": True,
859+
"use_ai_fallback": True,
860+
},
855861
screenshot_params={
856862
"area": "viewport",
857863
"format": "png",

0 commit comments

Comments
 (0)