Skip to content

Commit 71ad00b

Browse files
author
stlc-bot
committed
fix(scrape): reuse legacy caches across all output formats (#1197)
Stainless-Generated-From: 89f722a
1 parent cfec05f commit 71ad00b

2 files changed

Lines changed: 30 additions & 19 deletions

File tree

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

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -519,13 +519,16 @@ def scrape(
519519
extra_body: Body | None = None,
520520
timeout: float | httpx.Timeout | None | NotGiven = not_given,
521521
) -> WebScrapeResponse:
522-
"""Capture the requested formats from one page visit.
522+
"""Reuse cached outputs independently and capture missing formats in one page
523+
visit.
523524
524-
Shared settings apply once.
525-
HTML-only requests use the existing fast acquisition path. One credit per
526-
capture, or two with browser actions; PDF OCR adds one credit per recovered
527-
page. Original response bytes and screenshots are limited to 20 MiB each,
528-
screenshots to 40 megapixels, and the combined browser capture to 60 MiB.
525+
Each cache key includes only the settings that affect that output. HTML
526+
is shared with Markdown and parsed fields. Cached outputs can come from
527+
different visits within maxAgeMs; use 0 for a fresh capture. HTML-only requests
528+
use the existing fast acquisition path. One credit per request, including cache
529+
hits, or two with browser actions; PDF OCR adds one credit per recovered page on
530+
fresh extraction. Original response bytes and screenshots are limited to 20 MiB
531+
each, screenshots to 40 megapixels, and the combined browser capture to 60 MiB.
529532
530533
Args:
531534
formats: Outputs to return. Enable at least one; omitted formats are false.
@@ -536,8 +539,10 @@ def scrape(
536539
537540
markdown_params: Markdown options. Requires formats.markdown: true.
538541
539-
max_age_ms: Maximum age for the entire capture, including bytes. Defaults to 1 day; 0
540-
fetches fresh. Captures with hosted image files refresh after 23 hours.
542+
max_age_ms: Maximum age of each cached output. Defaults to 1 day; 0 fetches fresh and
543+
updates the requested outputs. Compatible outputs are shared with the individual
544+
scrape endpoints. Image results with hosted files refresh after 23 hours; other
545+
outputs retain their own freshness.
541546
542547
parse_params: Required when formats.parse is true.
543548
@@ -3871,13 +3876,16 @@ async def scrape(
38713876
extra_body: Body | None = None,
38723877
timeout: float | httpx.Timeout | None | NotGiven = not_given,
38733878
) -> WebScrapeResponse:
3874-
"""Capture the requested formats from one page visit.
3879+
"""Reuse cached outputs independently and capture missing formats in one page
3880+
visit.
38753881
3876-
Shared settings apply once.
3877-
HTML-only requests use the existing fast acquisition path. One credit per
3878-
capture, or two with browser actions; PDF OCR adds one credit per recovered
3879-
page. Original response bytes and screenshots are limited to 20 MiB each,
3880-
screenshots to 40 megapixels, and the combined browser capture to 60 MiB.
3882+
Each cache key includes only the settings that affect that output. HTML
3883+
is shared with Markdown and parsed fields. Cached outputs can come from
3884+
different visits within maxAgeMs; use 0 for a fresh capture. HTML-only requests
3885+
use the existing fast acquisition path. One credit per request, including cache
3886+
hits, or two with browser actions; PDF OCR adds one credit per recovered page on
3887+
fresh extraction. Original response bytes and screenshots are limited to 20 MiB
3888+
each, screenshots to 40 megapixels, and the combined browser capture to 60 MiB.
38813889
38823890
Args:
38833891
formats: Outputs to return. Enable at least one; omitted formats are false.
@@ -3888,8 +3896,10 @@ async def scrape(
38883896
38893897
markdown_params: Markdown options. Requires formats.markdown: true.
38903898
3891-
max_age_ms: Maximum age for the entire capture, including bytes. Defaults to 1 day; 0
3892-
fetches fresh. Captures with hosted image files refresh after 23 hours.
3899+
max_age_ms: Maximum age of each cached output. Defaults to 1 day; 0 fetches fresh and
3900+
updates the requested outputs. Compatible outputs are shared with the individual
3901+
scrape endpoints. Image results with hosted files refresh after 23 hours; other
3902+
outputs retain their own freshness.
38933903
38943904
parse_params: Required when formats.parse is true.
38953905

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ class WebScrapeParams(TypedDict, total=False):
4646
"""Markdown options. Requires formats.markdown: true."""
4747

4848
max_age_ms: Annotated[int, PropertyInfo(alias="maxAgeMs")]
49-
"""Maximum age for the entire capture, including bytes.
49+
"""Maximum age of each cached output.
5050
51-
Defaults to 1 day; 0 fetches fresh. Captures with hosted image files refresh
52-
after 23 hours.
51+
Defaults to 1 day; 0 fetches fresh and updates the requested outputs. Compatible
52+
outputs are shared with the individual scrape endpoints. Image results with
53+
hosted files refresh after 23 hours; other outputs retain their own freshness.
5354
"""
5455

5556
parse_params: Annotated[ParseParams, PropertyInfo(alias="parseParams")]

0 commit comments

Comments
 (0)