Skip to content

Commit cbf9c43

Browse files
feat(api): api update
1 parent 06c5d6c commit cbf9c43

12 files changed

Lines changed: 76 additions & 28 deletions

‎.stats.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 38
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-b5a46cf886759797353b250da971e46cf66804b825ded9c51609f34d72d1169c.yml
3-
openapi_spec_hash: 1947de2a731ddab05bfb781f37cd42b6
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-3ecc6285243f60f7619d543cac59991015fbb0a156648741e7e42e619e0cbc5c.yml
3+
openapi_spec_hash: 0130f29a501366c63cbd3a446c5eb109
44
config_hash: bff282047fafdad771fb7ec685f56944

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,8 @@ def search(
12881288
) -> BrandSearchResponse:
12891289
"""
12901290
Search brands by name or domain and get back up to 10 lightweight matches
1291-
(domain, name, logo), most popular first: by Tranco rank, then market cap for
1291+
(domain, name, logo). Name matches rank ahead of domain matches; within each
1292+
group the most popular brands come first: by Tranco rank, then market cap for
12921293
brands outside the Tranco list, with text relevance breaking ties. Matching is
12931294
prefix-based with no typo tolerance, so it is suited to autocomplete. Only
12941295
brands already in the Context.dev index are returned — use /brand/retrieve to
@@ -2592,7 +2593,8 @@ async def search(
25922593
) -> BrandSearchResponse:
25932594
"""
25942595
Search brands by name or domain and get back up to 10 lightweight matches
2595-
(domain, name, logo), most popular first: by Tranco rank, then market cap for
2596+
(domain, name, logo). Name matches rank ahead of domain matches; within each
2597+
group the most popular brands come first: by Tranco rank, then market cap for
25962598
brands outside the Tranco list, with text relevance breaking ties. Matching is
25972599
prefix-based with no typo tolerance, so it is suited to autocomplete. Only
25982600
brands already in the Context.dev index are returned — use /brand/retrieve to

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,11 @@ def handle(
165165
166166
include_links: Preserve hyperlinks in Markdown output
167167
168-
ocr: When true for PDF inputs, detect and OCR images embedded in the selected pages,
169-
inserting recognized text at each image's position in page reading order while
170-
preserving the PDF text layer. pdf.start/pdf.end limit the inclusive page range.
171-
When false, no OCR runs.
168+
ocr: When true for PDF inputs, OCR the selected pages that have no usable text layer
169+
(scans), replacing each recovered page's text with the OCR result while pages
170+
with a real text layer keep it. pdf.start/pdf.end limit the inclusive page
171+
range. Billed at 1 credit per page OCR actually recovered, on top of the base
172+
request cost. When false, no OCR runs.
172173
173174
pdf: PDF page-range options as a JSON object, e.g. {"start": 2, "end": 5}.
174175
@@ -349,10 +350,11 @@ async def handle(
349350
350351
include_links: Preserve hyperlinks in Markdown output
351352
352-
ocr: When true for PDF inputs, detect and OCR images embedded in the selected pages,
353-
inserting recognized text at each image's position in page reading order while
354-
preserving the PDF text layer. pdf.start/pdf.end limit the inclusive page range.
355-
When false, no OCR runs.
353+
ocr: When true for PDF inputs, OCR the selected pages that have no usable text layer
354+
(scans), replacing each recovered page's text with the OCR result while pages
355+
with a real text layer keep it. pdf.start/pdf.end limit the inclusive page
356+
range. Billed at 1 credit per page OCR actually recovered, on top of the base
357+
request cost. When false, no OCR runs.
356358
357359
pdf: PDF page-range options as a JSON object, e.g. {"start": 2, "end": 5}.
358360

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ class DataOk(BaseModel):
127127
meta: Optional[Dict[str, object]] = None
128128
"""Caller-supplied metadata echoed from submission."""
129129

130+
ocr_pages: Optional[int] = None
131+
"""PDF pages of this document recovered by OCR (pdf.ocr=true).
132+
133+
Each recovered page bills 1 credit on top of the page base credit; absent when
134+
no OCR ran.
135+
"""
136+
130137

131138
class DataError(BaseModel):
132139
"""A page the batch could not fetch."""

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ class DataCredits(BaseModel):
2525
"""What this batch has done to your credit balance."""
2626

2727
net: int
28-
"""`reserved` minus `refunded` — what the batch has cost so far.
28+
"""`reserved` minus `refunded` plus `ocr_charged` — what the batch has cost so far.
2929
3030
Equal to `reserved` until the batch settles.
3131
"""
3232

33+
ocr_charged: int
34+
"""
35+
Credits charged for PDF pages recovered by OCR (pdf.ocr=true), 1 per recovered
36+
page, on top of `reserved`. Stays 0 until the batch settles.
37+
"""
38+
3339
refunded: int
3440
"""Credits returned for pages that did not succeed.
3541

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ class Credits(BaseModel):
2525
"""What this batch has done to your credit balance."""
2626

2727
net: int
28-
"""`reserved` minus `refunded` — what the batch has cost so far.
28+
"""`reserved` minus `refunded` plus `ocr_charged` — what the batch has cost so far.
2929
3030
Equal to `reserved` until the batch settles.
3131
"""
3232

33+
ocr_charged: int
34+
"""
35+
Credits charged for PDF pages recovered by OCR (pdf.ocr=true), 1 per recovered
36+
page, on top of `reserved`. Stays 0 until the batch settles.
37+
"""
38+
3339
refunded: int
3440
"""Credits returned for pages that did not succeed.
3541

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"BrandBackdropColor",
1414
"BrandBackdropResolution",
1515
"BrandColor",
16+
"BrandEmployees",
1617
"BrandIndustries",
1718
"BrandIndustriesEic",
1819
"BrandLinks",
@@ -90,6 +91,20 @@ class BrandColor(BaseModel):
9091
"""Name of the color"""
9192

9293

94+
class BrandEmployees(BaseModel):
95+
"""Employee headcount information for the brand (will be null if unknown)"""
96+
97+
exact: Optional[int] = None
98+
"""Exact employee count when a precise headcount is known"""
99+
100+
range: Optional[
101+
Literal[
102+
"1 to 10", "11 to 50", "51 to 200", "201 to 500", "501 to 1000", "1001 to 5000", "5001 to 10000", "10001+"
103+
]
104+
] = None
105+
"""Employee count range for the brand (e.g. '11 to 50')"""
106+
107+
93108
class BrandIndustriesEic(BaseModel):
94109
industry: Literal[
95110
"Aerospace & Defense",
@@ -490,6 +505,9 @@ class Brand(BaseModel):
490505
email: Optional[str] = None
491506
"""Company email address"""
492507

508+
employees: Optional[BrandEmployees] = None
509+
"""Employee headcount information for the brand (will be null if unknown)"""
510+
493511
industries: Optional[BrandIndustries] = None
494512
"""Industry classification information for the brand"""
495513

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ class KeyMetadata(BaseModel):
3636

3737
class BrandSearchResponse(BaseModel):
3838
results: List[Result]
39-
"""Up to 10 matching brands, most popular first. Empty when nothing matches."""
39+
"""
40+
Up to 10 matching brands, name matches first, then domain matches, most popular
41+
first within each group. Empty when nothing matches.
42+
"""
4043

4144
key_metadata: Optional[KeyMetadata] = None
4245
"""Metadata about the API key used for the request.

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ class ParseHandleParams(TypedDict, total=False):
100100

101101
ocr: Union[bool, Literal["true", "false"]]
102102
"""
103-
When true for PDF inputs, detect and OCR images embedded in the selected pages,
104-
inserting recognized text at each image's position in page reading order while
105-
preserving the PDF text layer. pdf.start/pdf.end limit the inclusive page range.
106-
When false, no OCR runs.
103+
When true for PDF inputs, OCR the selected pages that have no usable text layer
104+
(scans), replacing each recovered page's text with the OCR result while pages
105+
with a real text layer keep it. pdf.start/pdf.end limit the inclusive page
106+
range. Billed at 1 credit per page OCR actually recovered, on top of the base
107+
request cost. When false, no OCR runs.
107108
"""
108109

109110
pdf: Pdf

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,10 @@ class Pdf(TypedDict, total=False):
346346

347347
ocr: bool
348348
"""
349-
When true, detect and OCR images embedded in the selected PDF pages, inserting
350-
recognized text at each image's position in page reading order while preserving
351-
the PDF text layer. This is separate from automatic scanned-PDF OCR fallback.
349+
When true, OCR the selected PDF pages that have no usable text layer (scans),
350+
replacing each recovered page's text with the OCR result while pages with a real
351+
text layer keep it. Billed at 1 credit per page OCR actually recovered, on top
352+
of the base request cost.
352353
"""
353354

354355
should_parse: Annotated[bool, PropertyInfo(alias="shouldParse")]

0 commit comments

Comments
 (0)