Skip to content

Commit d002c89

Browse files
author
stlc-bot
committed
feat(highlights): preserve Markdown structure in scrape excerpts (#1236)
Stainless-Generated-From: eb9b996
1 parent e1761c5 commit d002c89

3 files changed

Lines changed: 38 additions & 37 deletions

File tree

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

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -417,21 +417,21 @@ def scrape(
417417
is shared with Markdown, parsed fields, product data, highlights, and JSON
418418
extraction. Cached outputs can come from different visits within maxAgeMs; use 0
419419
for a fresh capture. HTML-only requests use the existing fast acquisition path.
420-
Highlights return the plain-text passages most relevant to
421-
highlightsParams.query. Requests with at least one successful output cost one
422-
base credit, including cache hits, or two with browser actions. All-failed
423-
responses are unbilled except missing pages, which retain the base price and the
424-
one-credit product charge when product was requested. Highlights add 3 credits
425-
when passages are returned. JSON extraction runs an LLM over nonempty page
426-
Markdown and adds four credits only when its result is returned successfully.
427-
PDF OCR adds one credit per recovered page on fresh extraction. Product adds one
428-
credit when its successful result is returned, plus six if that result used the
429-
specialized model. Original response bytes and screenshots are limited to 20 MiB
430-
each, screenshots to 40 megapixels, and the combined response to 60 MiB. An
431-
oversized output has success: false and data: null. If the combined response
432-
exceeds its limit, the largest outputs are marked failed until the remaining
433-
outputs fit. Valid captured pieces may still be cached when omitted to meet the
434-
response size limit.
420+
Highlights return Markdown excerpts most relevant to highlightsParams.query.
421+
Requests with at least one successful output cost one base credit, including
422+
cache hits, or two with browser actions. All-failed responses are unbilled
423+
except missing pages, which retain the base price and the one-credit product
424+
charge when product was requested. Highlights add 3 credits when passages are
425+
returned. JSON extraction runs an LLM over nonempty page Markdown and adds four
426+
credits only when its result is returned successfully. PDF OCR adds one credit
427+
per recovered page on fresh extraction. Product adds one credit when its
428+
successful result is returned, plus six if that result used the specialized
429+
model. Original response bytes and screenshots are limited to 20 MiB each,
430+
screenshots to 40 megapixels, and the combined response to 60 MiB. An oversized
431+
output has success: false and data: null. If the combined response exceeds its
432+
limit, the largest outputs are marked failed until the remaining outputs fit.
433+
Valid captured pieces may still be cached when omitted to meet the response size
434+
limit.
435435
436436
Args:
437437
formats: Outputs to return. Enable at least one; omitted formats are false.
@@ -1922,21 +1922,21 @@ async def scrape(
19221922
is shared with Markdown, parsed fields, product data, highlights, and JSON
19231923
extraction. Cached outputs can come from different visits within maxAgeMs; use 0
19241924
for a fresh capture. HTML-only requests use the existing fast acquisition path.
1925-
Highlights return the plain-text passages most relevant to
1926-
highlightsParams.query. Requests with at least one successful output cost one
1927-
base credit, including cache hits, or two with browser actions. All-failed
1928-
responses are unbilled except missing pages, which retain the base price and the
1929-
one-credit product charge when product was requested. Highlights add 3 credits
1930-
when passages are returned. JSON extraction runs an LLM over nonempty page
1931-
Markdown and adds four credits only when its result is returned successfully.
1932-
PDF OCR adds one credit per recovered page on fresh extraction. Product adds one
1933-
credit when its successful result is returned, plus six if that result used the
1934-
specialized model. Original response bytes and screenshots are limited to 20 MiB
1935-
each, screenshots to 40 megapixels, and the combined response to 60 MiB. An
1936-
oversized output has success: false and data: null. If the combined response
1937-
exceeds its limit, the largest outputs are marked failed until the remaining
1938-
outputs fit. Valid captured pieces may still be cached when omitted to meet the
1939-
response size limit.
1925+
Highlights return Markdown excerpts most relevant to highlightsParams.query.
1926+
Requests with at least one successful output cost one base credit, including
1927+
cache hits, or two with browser actions. All-failed responses are unbilled
1928+
except missing pages, which retain the base price and the one-credit product
1929+
charge when product was requested. Highlights add 3 credits when passages are
1930+
returned. JSON extraction runs an LLM over nonempty page Markdown and adds four
1931+
credits only when its result is returned successfully. PDF OCR adds one credit
1932+
per recovered page on fresh extraction. Product adds one credit when its
1933+
successful result is returned, plus six if that result used the specialized
1934+
model. Original response bytes and screenshots are limited to 20 MiB each,
1935+
screenshots to 40 megapixels, and the combined response to 60 MiB. An oversized
1936+
output has success: false and data: null. If the combined response exceeds its
1937+
limit, the largest outputs are marked failed until the remaining outputs fit.
1938+
Valid captured pieces may still be cached when omitted to meet the response size
1939+
limit.
19401940
19411941
Args:
19421942
formats: Outputs to return. Enable at least one; omitted formats are false.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ class Formats(TypedDict, total=False):
112112

113113
highlights: bool
114114
"""
115-
Relevant passages for your question or topic, with headings included when needed
116-
for context. Adds 3 credits when passages are returned.
115+
Relevant Markdown excerpts for your question or topic, preserving code, lists,
116+
and tables, with headings included when needed for context. Adds 3 credits when
117+
passages are returned.
117118
"""
118119

119120
html: bool

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ class CacheMetadata(BaseModel):
7272

7373

7474
class Highlights(BaseModel):
75-
"""Relevant passages for your question or topic, in page order.
75+
"""Relevant Markdown excerpts for your question or topic, in page order.
7676
77-
A heading in square brackets is included when needed to interpret a passage. Empty when the page has no text.
77+
Headings in square brackets supply necessary context; ellipses mark omitted portions. Empty when the page has no text.
7878
"""
7979

8080
data: Optional[List[str]] = None
@@ -376,10 +376,10 @@ class WebScrapeResponse(BaseModel):
376376
"""
377377

378378
highlights: Highlights
379-
"""Relevant passages for your question or topic, in page order.
379+
"""Relevant Markdown excerpts for your question or topic, in page order.
380380
381-
A heading in square brackets is included when needed to interpret a passage.
382-
Empty when the page has no text.
381+
Headings in square brackets supply necessary context; ellipses mark omitted
382+
portions. Empty when the page has no text.
383383
"""
384384

385385
html: HTML

0 commit comments

Comments
 (0)