Skip to content

Commit cee4e51

Browse files
feat(api): api update
1 parent 9cfaf51 commit cee4e51

14 files changed

Lines changed: 150 additions & 134 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 2
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nanonets%2Fdocstrange-3843cc83cc328a1c86126018a4309fbcd13aac4df5fd9afefd652e21e59530ab.yml
3-
openapi_spec_hash: b4046d95714426b15edb8ac003f904c6
4-
config_hash: aed0d6cc8b4cffa1f02021baec0a6da3
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nanonets%2Fdocstrange-eed2d21f54dac82f72faa7f05408973593e5a6338717864d4f37bf2333274518.yml
3+
openapi_spec_hash: 47cb78aa2caa018fe58742fc19b0a49c
4+
config_hash: 6f0ab1fd6c4433590ee82d88ab5298a7

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ client = Docstrange()
127127

128128
client.extract.sync(
129129
file=Path("/path/to/file"),
130-
output_format="output_format",
130+
output_format="markdown",
131131
)
132132
```
133133

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ from docstrange.types import ExtractResponse
88

99
Methods:
1010

11-
- <code title="post /api/v1/extract/sync">client.extract.<a href="./src/docstrange/resources/extract/extract.py">sync</a>(\*\*<a href="src/docstrange/types/extract_sync_params.py">params</a>) -> <a href="./src/docstrange/types/extract_response.py">ExtractResponse</a></code>
11+
- <code title="post /api/v1/extract/sync">client.extract.<a href="./src/docstrange/resources/extract.py">sync</a>(\*\*<a href="src/docstrange/types/extract_sync_params.py">params</a>) -> <a href="./src/docstrange/types/extract_response.py">ExtractResponse</a></code>
1212

1313
# Classify
1414

src/docstrange/_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232

3333
if TYPE_CHECKING:
3434
from .resources import extract, classify
35+
from .resources.extract import ExtractResource, AsyncExtractResource
3536
from .resources.classify import ClassifyResource, AsyncClassifyResource
36-
from .resources.extract.extract import ExtractResource, AsyncExtractResource
3737

3838
__all__ = [
3939
"Timeout",

src/docstrange/pagination.py

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/docstrange/resources/classify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def sync(
5959
Classify a single document.
6060
6161
Args:
62-
categories: JSON array of categories
62+
categories: JSON array of category objects
6363
6464
file: File to classify
6565
@@ -129,7 +129,7 @@ async def sync(
129129
Classify a single document.
130130
131131
Args:
132-
categories: JSON array of categories
132+
categories: JSON array of category objects
133133
134134
file: File to classify
135135

src/docstrange/resources/extract/extract.py renamed to src/docstrange/resources/extract.py

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@
33
from __future__ import annotations
44

55
from typing import Mapping, cast
6+
from typing_extensions import Literal
67

78
import httpx
89

9-
from ...types import extract_sync_params
10-
from ..._types import Body, Query, Headers, NotGiven, FileTypes, not_given
11-
from ..._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
12-
from ..._compat import cached_property
13-
from ..._resource import SyncAPIResource, AsyncAPIResource
14-
from ..._response import (
10+
from ..types import extract_sync_params
11+
from .._types import Body, Omit, Query, Headers, NotGiven, FileTypes, omit, not_given
12+
from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
13+
from .._compat import cached_property
14+
from .._resource import SyncAPIResource, AsyncAPIResource
15+
from .._response import (
1516
to_raw_response_wrapper,
1617
to_streamed_response_wrapper,
1718
async_to_raw_response_wrapper,
1819
async_to_streamed_response_wrapper,
1920
)
20-
from ..._base_client import make_request_options
21-
from ...types.extract_response import ExtractResponse
21+
from .._base_client import make_request_options
22+
from ..types.extract_response import ExtractResponse
2223

2324
__all__ = ["ExtractResource", "AsyncExtractResource"]
2425

@@ -48,6 +49,13 @@ def sync(
4849
*,
4950
file: FileTypes,
5051
output_format: str,
52+
csv_options: str | Omit = omit,
53+
custom_instructions: str | Omit = omit,
54+
file_base64: str | Omit = omit,
55+
file_url: str | Omit = omit,
56+
include_metadata: str | Omit = omit,
57+
json_options: str | Omit = omit,
58+
prompt_mode: Literal["append", "replace"] | Omit = omit,
5159
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5260
# The extra values given here take precedence over values defined on the client or passed to this method.
5361
extra_headers: Headers | None = None,
@@ -59,9 +67,23 @@ def sync(
5967
Process a document and return extracted content immediately.
6068
6169
Args:
62-
file: File to upload
70+
file: File to upload (PDF, Word, Excel, PowerPoint, images)
6371
64-
output_format: Output format
72+
output_format: Output format(s): markdown, html, json, csv.
73+
74+
csv_options: CSV extraction options
75+
76+
custom_instructions: Custom extraction instructions
77+
78+
file_base64: Base64-encoded file content
79+
80+
file_url: URL to download file from
81+
82+
include_metadata: Comma-separated metadata types
83+
84+
json_options: JSON extraction options
85+
86+
prompt_mode: append or replace
6587
6688
extra_headers: Send extra headers
6789
@@ -75,6 +97,13 @@ def sync(
7597
{
7698
"file": file,
7799
"output_format": output_format,
100+
"csv_options": csv_options,
101+
"custom_instructions": custom_instructions,
102+
"file_base64": file_base64,
103+
"file_url": file_url,
104+
"include_metadata": include_metadata,
105+
"json_options": json_options,
106+
"prompt_mode": prompt_mode,
78107
}
79108
)
80109
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
@@ -118,6 +147,13 @@ async def sync(
118147
*,
119148
file: FileTypes,
120149
output_format: str,
150+
csv_options: str | Omit = omit,
151+
custom_instructions: str | Omit = omit,
152+
file_base64: str | Omit = omit,
153+
file_url: str | Omit = omit,
154+
include_metadata: str | Omit = omit,
155+
json_options: str | Omit = omit,
156+
prompt_mode: Literal["append", "replace"] | Omit = omit,
121157
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
122158
# The extra values given here take precedence over values defined on the client or passed to this method.
123159
extra_headers: Headers | None = None,
@@ -129,9 +165,23 @@ async def sync(
129165
Process a document and return extracted content immediately.
130166
131167
Args:
132-
file: File to upload
168+
file: File to upload (PDF, Word, Excel, PowerPoint, images)
169+
170+
output_format: Output format(s): markdown, html, json, csv.
171+
172+
csv_options: CSV extraction options
173+
174+
custom_instructions: Custom extraction instructions
175+
176+
file_base64: Base64-encoded file content
177+
178+
file_url: URL to download file from
179+
180+
include_metadata: Comma-separated metadata types
181+
182+
json_options: JSON extraction options
133183
134-
output_format: Output format
184+
prompt_mode: append or replace
135185
136186
extra_headers: Send extra headers
137187
@@ -145,6 +195,13 @@ async def sync(
145195
{
146196
"file": file,
147197
"output_format": output_format,
198+
"csv_options": csv_options,
199+
"custom_instructions": custom_instructions,
200+
"file_base64": file_base64,
201+
"file_url": file_url,
202+
"include_metadata": include_metadata,
203+
"json_options": json_options,
204+
"prompt_mode": prompt_mode,
148205
}
149206
)
150207
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])

src/docstrange/resources/extract/__init__.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/docstrange/types/classify_sync_params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class ClassifySyncParams(TypedDict, total=False):
1313
categories: Required[str]
14-
"""JSON array of categories"""
14+
"""JSON array of category objects"""
1515

1616
file: Required[FileTypes]
1717
"""File to classify"""

src/docstrange/types/extract/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)