Skip to content

Commit f1246b7

Browse files
release: 0.7.0 (#85)
Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent e7c850a commit f1246b7

14 files changed

+166
-95
lines changed

.release-please-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.6.0"
2+
".": "0.7.0"
33
}

.stats.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 52
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-17bdb8a33fb4fcade827bba868bd65cd30c64b1d09b4a6d83c3e37a8439ed37f.yml
3-
openapi_spec_hash: bc325b52f3b20d8c56e0be5de88f2dc3
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-8d75c58c83d13f67b6a125c3eb4639d213c91aec7dbb6e06f0cd5bdfc074d54e.yml
3+
openapi_spec_hash: 47795284631814d0f8eb42f6a0d5a3b3
44
config_hash: 1ecef0ff4fd125bbc00eec65e3dd4798

CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## 0.7.0 (2025-05-13)
4+
5+
Full Changelog: [v0.6.0...v0.7.0](https://github.com/ContextualAI/contextual-client-python/compare/v0.6.0...v0.7.0)
6+
7+
### Features
8+
9+
* **api:** update via SDK Studio ([656a0e1](https://github.com/ContextualAI/contextual-client-python/commit/656a0e19d78fe677a1a859bff114511acd58fa87))
10+
11+
12+
### Bug Fixes
13+
14+
* **package:** support direct resource imports ([109de24](https://github.com/ContextualAI/contextual-client-python/commit/109de24d9c76aaa1d90fff8dfc816e5cfbfab50a))
15+
* **tests:** correct number examples ([cb94e10](https://github.com/ContextualAI/contextual-client-python/commit/cb94e101a87b8abec57d46667fecef7a3079765f))
16+
17+
18+
### Chores
19+
20+
* **internal:** avoid errors for isinstance checks on proxies ([581e581](https://github.com/ContextualAI/contextual-client-python/commit/581e581480ac98e0fed61eacc36e90a44e3b99fc))
21+
322
## 0.6.0 (2025-05-08)
423

524
Full Changelog: [v0.5.1...v0.6.0](https://github.com/ContextualAI/contextual-client-python/compare/v0.5.1...v0.6.0)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "contextual-client"
3-
version = "0.6.0"
3+
version = "0.7.0"
44
description = "The official Python library for the Contextual AI API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

src/contextual/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
import typing as _t
4+
35
from . import types
46
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
57
from ._utils import file_from_path
@@ -78,6 +80,9 @@
7880
"DefaultAsyncHttpxClient",
7981
]
8082

83+
if not _t.TYPE_CHECKING:
84+
from ._utils._resources_proxy import resources as resources
85+
8186
_setup_logging()
8287

8388
# Update the __module__ attribute for exported symbols so that

src/contextual/_utils/_proxy.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ def __dir__(self) -> Iterable[str]:
4646
@property # type: ignore
4747
@override
4848
def __class__(self) -> type: # pyright: ignore
49-
proxied = self.__get_proxied__()
49+
try:
50+
proxied = self.__get_proxied__()
51+
except Exception:
52+
return type(self)
5053
if issubclass(type(proxied), LazyProxy):
5154
return type(proxied)
5255
return proxied.__class__
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from __future__ import annotations
2+
3+
from typing import Any
4+
from typing_extensions import override
5+
6+
from ._proxy import LazyProxy
7+
8+
9+
class ResourcesProxy(LazyProxy[Any]):
10+
"""A proxy for the `contextual.resources` module.
11+
12+
This is used so that we can lazily import `contextual.resources` only when
13+
needed *and* so that users can just import `contextual` and reference `contextual.resources`
14+
"""
15+
16+
@override
17+
def __load__(self) -> Any:
18+
import importlib
19+
20+
mod = importlib.import_module("contextual.resources")
21+
return mod
22+
23+
24+
resources = ResourcesProxy().__as_proxied__()

src/contextual/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
__title__ = "contextual"
4-
__version__ = "0.6.0" # x-release-please-version
4+
__version__ = "0.7.0" # x-release-please-version

src/contextual/resources/parse.py

+46-40
Original file line numberDiff line numberDiff line change
@@ -65,39 +65,42 @@ def create(
6565
extra_body: Body | None = None,
6666
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
6767
) -> ParseCreateResponse:
68-
"""Parse a file into a structured Markdown representation.
68+
"""Parse a file into a structured Markdown and/or JSON.
6969
70-
The file size must be
71-
less than 100MB and the number of pages must be less than 400.
70+
Files must be less than
71+
100MB and 400 pages. We use LibreOffice to convert DOC(X) and PPT(X) files to
72+
PDF, which may affect page count.
7273
74+
See our [blog post](https://contextual.ai/blog/document-parser-for-rag) and
75+
[code examples](https://github.com/ContextualAI/examples/blob/main/03-standalone-api/04-parse/parse.ipynb).
7376
Email [parse-feedback@contextual.ai](mailto:parse-feedback@contextual.ai) with
7477
any feedback or questions.
7578
7679
Args:
7780
raw_file: The file to be parsed. The file type must be PDF, DOC / DOCX, PPT / PPTX.
7881
79-
enable_document_hierarchy: Controls parsing heading levels (e.g. H1, H2, H3) at higher quality. Adds a
80-
table of contents to the output with the structure of the entire parsed
81-
document. Not permitted in 'basic' parsing_mode, or if page_range is not
82-
continuous and/or does not start from page zero.
82+
enable_document_hierarchy: Adds a table of contents to the output with the structure of the entire parsed
83+
document. This feature is in beta. Controls parsing heading levels (e.g. H1, H2,
84+
H3) at higher quality. Not permitted in `basic` parsing_mode, or if page_range
85+
is not continuous and/or does not start from page zero.
8386
8487
enable_split_tables: Controls whether tables are split into multiple tables by row with the headers
8588
propagated. Use for improving LLM comprehension of very large tables. Not
86-
permitted in 'basic' parsing_mode.
89+
permitted in `basic` parsing_mode.
8790
88-
figure_caption_mode: Controls how thorough figure captions are. 'concise' is short and minimizes
89-
chances of hallucinations. 'detailed' is more thorough and can include
90-
commentary. Not permitted in 'basic' parsing_mode.
91+
figure_caption_mode: Controls how thorough figure captions are. `concise` is short and minimizes
92+
chances of hallucinations. `detailed` is more thorough and can include
93+
commentary; this mode is in beta. Not permitted in `basic` parsing_mode.
9194
9295
max_split_table_cells: Threshold number of table cells beyond which large tables are split if
93-
`enable_split_tables` is True. Not permitted in 'basic' parsing_mode.
96+
`enable_split_tables` is True. Not permitted in `basic` parsing_mode.
9497
9598
page_range: Optional string representing page range to be parsed. Format: comma-separated
96-
indexes (0-based) e.g. '0,1,2,5,6' or ranges (inclusive of both ends) e.g.
97-
'0-2,5,6'
99+
indexes (0-based, e.g. `0,1,2,5,6`), or ranges inclusive of both ends (e.g.
100+
`0-2,5,6`)
98101
99-
parse_mode: The settings to use for parsing. 'basic' is for simple, text-only documents.
100-
'standard' is for complex documents with images, complex hierarchy, and/or no
102+
parse_mode: The settings to use for parsing. `basic` is for simple, text-only documents.
103+
`standard` is for complex documents with images, complex hierarchy, and/or no
101104
natively encoded textual data (e.g. for scanned documents).
102105
103106
extra_headers: Send extra headers
@@ -156,11 +159,11 @@ def job_results(
156159
job_id: Unique ID of the parse job
157160
158161
output_types: The desired output format(s) of the parsed file. Must be `markdown-document`,
159-
`markdown-per-page`, and/or `blocks-per-page`. `markdown-document` parses the
160-
whole document into a single concatenated markdown output. `markdown-per-page`
161-
provides markdown output per page. `blocks-per-page` provides a structured JSON
162+
`markdown-per-page`, and/or `blocks-per-page`. Specify multiple values to get
163+
multiple formats in the response. `markdown-document` parses the whole document
164+
into a single concatenated markdown output. `markdown-per-page` provides
165+
markdown output per page. `blocks-per-page` provides a structured JSON
162166
representation of the content blocks on each page, sorted by reading order.
163-
Specify multiple values to get multiple formats in the response.
164167
165168
extra_headers: Send extra headers
166169
@@ -298,39 +301,42 @@ async def create(
298301
extra_body: Body | None = None,
299302
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
300303
) -> ParseCreateResponse:
301-
"""Parse a file into a structured Markdown representation.
304+
"""Parse a file into a structured Markdown and/or JSON.
302305
303-
The file size must be
304-
less than 100MB and the number of pages must be less than 400.
306+
Files must be less than
307+
100MB and 400 pages. We use LibreOffice to convert DOC(X) and PPT(X) files to
308+
PDF, which may affect page count.
305309
310+
See our [blog post](https://contextual.ai/blog/document-parser-for-rag) and
311+
[code examples](https://github.com/ContextualAI/examples/blob/main/03-standalone-api/04-parse/parse.ipynb).
306312
Email [parse-feedback@contextual.ai](mailto:parse-feedback@contextual.ai) with
307313
any feedback or questions.
308314
309315
Args:
310316
raw_file: The file to be parsed. The file type must be PDF, DOC / DOCX, PPT / PPTX.
311317
312-
enable_document_hierarchy: Controls parsing heading levels (e.g. H1, H2, H3) at higher quality. Adds a
313-
table of contents to the output with the structure of the entire parsed
314-
document. Not permitted in 'basic' parsing_mode, or if page_range is not
315-
continuous and/or does not start from page zero.
318+
enable_document_hierarchy: Adds a table of contents to the output with the structure of the entire parsed
319+
document. This feature is in beta. Controls parsing heading levels (e.g. H1, H2,
320+
H3) at higher quality. Not permitted in `basic` parsing_mode, or if page_range
321+
is not continuous and/or does not start from page zero.
316322
317323
enable_split_tables: Controls whether tables are split into multiple tables by row with the headers
318324
propagated. Use for improving LLM comprehension of very large tables. Not
319-
permitted in 'basic' parsing_mode.
325+
permitted in `basic` parsing_mode.
320326
321-
figure_caption_mode: Controls how thorough figure captions are. 'concise' is short and minimizes
322-
chances of hallucinations. 'detailed' is more thorough and can include
323-
commentary. Not permitted in 'basic' parsing_mode.
327+
figure_caption_mode: Controls how thorough figure captions are. `concise` is short and minimizes
328+
chances of hallucinations. `detailed` is more thorough and can include
329+
commentary; this mode is in beta. Not permitted in `basic` parsing_mode.
324330
325331
max_split_table_cells: Threshold number of table cells beyond which large tables are split if
326-
`enable_split_tables` is True. Not permitted in 'basic' parsing_mode.
332+
`enable_split_tables` is True. Not permitted in `basic` parsing_mode.
327333
328334
page_range: Optional string representing page range to be parsed. Format: comma-separated
329-
indexes (0-based) e.g. '0,1,2,5,6' or ranges (inclusive of both ends) e.g.
330-
'0-2,5,6'
335+
indexes (0-based, e.g. `0,1,2,5,6`), or ranges inclusive of both ends (e.g.
336+
`0-2,5,6`)
331337
332-
parse_mode: The settings to use for parsing. 'basic' is for simple, text-only documents.
333-
'standard' is for complex documents with images, complex hierarchy, and/or no
338+
parse_mode: The settings to use for parsing. `basic` is for simple, text-only documents.
339+
`standard` is for complex documents with images, complex hierarchy, and/or no
334340
natively encoded textual data (e.g. for scanned documents).
335341
336342
extra_headers: Send extra headers
@@ -389,11 +395,11 @@ async def job_results(
389395
job_id: Unique ID of the parse job
390396
391397
output_types: The desired output format(s) of the parsed file. Must be `markdown-document`,
392-
`markdown-per-page`, and/or `blocks-per-page`. `markdown-document` parses the
393-
whole document into a single concatenated markdown output. `markdown-per-page`
394-
provides markdown output per page. `blocks-per-page` provides a structured JSON
398+
`markdown-per-page`, and/or `blocks-per-page`. Specify multiple values to get
399+
multiple formats in the response. `markdown-document` parses the whole document
400+
into a single concatenated markdown output. `markdown-per-page` provides
401+
markdown output per page. `blocks-per-page` provides a structured JSON
395402
representation of the content blocks on each page, sorted by reading order.
396-
Specify multiple values to get multiple formats in the response.
397403
398404
extra_headers: Send extra headers
399405

src/contextual/types/parse_create_params.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,45 @@ class ParseCreateParams(TypedDict, total=False):
1414
"""The file to be parsed. The file type must be PDF, DOC / DOCX, PPT / PPTX."""
1515

1616
enable_document_hierarchy: bool
17-
"""Controls parsing heading levels (e.g.
18-
19-
H1, H2, H3) at higher quality. Adds a table of contents to the output with the
20-
structure of the entire parsed document. Not permitted in 'basic' parsing_mode,
21-
or if page_range is not continuous and/or does not start from page zero.
17+
"""
18+
Adds a table of contents to the output with the structure of the entire parsed
19+
document. This feature is in beta. Controls parsing heading levels (e.g. H1, H2,
20+
H3) at higher quality. Not permitted in `basic` parsing_mode, or if page_range
21+
is not continuous and/or does not start from page zero.
2222
"""
2323

2424
enable_split_tables: bool
2525
"""
2626
Controls whether tables are split into multiple tables by row with the headers
2727
propagated. Use for improving LLM comprehension of very large tables. Not
28-
permitted in 'basic' parsing_mode.
28+
permitted in `basic` parsing_mode.
2929
"""
3030

3131
figure_caption_mode: Literal["concise", "detailed"]
3232
"""Controls how thorough figure captions are.
3333
34-
'concise' is short and minimizes chances of hallucinations. 'detailed' is more
35-
thorough and can include commentary. Not permitted in 'basic' parsing_mode.
34+
`concise` is short and minimizes chances of hallucinations. `detailed` is more
35+
thorough and can include commentary; this mode is in beta. Not permitted in
36+
`basic` parsing_mode.
3637
"""
3738

3839
max_split_table_cells: int
3940
"""
4041
Threshold number of table cells beyond which large tables are split if
41-
`enable_split_tables` is True. Not permitted in 'basic' parsing_mode.
42+
`enable_split_tables` is True. Not permitted in `basic` parsing_mode.
4243
"""
4344

4445
page_range: str
4546
"""Optional string representing page range to be parsed.
4647
47-
Format: comma-separated indexes (0-based) e.g. '0,1,2,5,6' or ranges (inclusive
48-
of both ends) e.g. '0-2,5,6'
48+
Format: comma-separated indexes (0-based, e.g. `0,1,2,5,6`), or ranges inclusive
49+
of both ends (e.g. `0-2,5,6`)
4950
"""
5051

5152
parse_mode: Literal["basic", "standard"]
5253
"""The settings to use for parsing.
5354
54-
'basic' is for simple, text-only documents. 'standard' is for complex documents
55+
`basic` is for simple, text-only documents. `standard` is for complex documents
5556
with images, complex hierarchy, and/or no natively encoded textual data (e.g.
5657
for scanned documents).
5758
"""

src/contextual/types/parse_job_results_params.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class ParseJobResultsParams(TypedDict, total=False):
1313
"""The desired output format(s) of the parsed file.
1414
1515
Must be `markdown-document`, `markdown-per-page`, and/or `blocks-per-page`.
16+
Specify multiple values to get multiple formats in the response.
1617
`markdown-document` parses the whole document into a single concatenated
1718
markdown output. `markdown-per-page` provides markdown output per page.
1819
`blocks-per-page` provides a structured JSON representation of the content
19-
blocks on each page, sorted by reading order. Specify multiple values to get
20-
multiple formats in the response.
20+
blocks on each page, sorted by reading order.
2121
"""

0 commit comments

Comments
 (0)