landingai-ade 0.14.1__py3-none-any.whl → 0.21.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,462 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Mapping, Optional, cast
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ..types import parse_job_list_params, parse_job_create_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 (
16
+ to_raw_response_wrapper,
17
+ to_streamed_response_wrapper,
18
+ async_to_raw_response_wrapper,
19
+ async_to_streamed_response_wrapper,
20
+ )
21
+ from .._base_client import make_request_options
22
+ from ..types.parse_job_get_response import ParseJobGetResponse
23
+ from ..types.parse_job_list_response import ParseJobListResponse
24
+ from ..types.parse_job_create_response import ParseJobCreateResponse
25
+
26
+ __all__ = ["ParseJobsResource", "AsyncParseJobsResource"]
27
+
28
+
29
+ class ParseJobsResource(SyncAPIResource):
30
+ @cached_property
31
+ def with_raw_response(self) -> ParseJobsResourceWithRawResponse:
32
+ """
33
+ This property can be used as a prefix for any HTTP method call to return
34
+ the raw response object instead of the parsed content.
35
+
36
+ For more information, see https://www.github.com/landing-ai/ade-python#accessing-raw-response-data-eg-headers
37
+ """
38
+ return ParseJobsResourceWithRawResponse(self)
39
+
40
+ @cached_property
41
+ def with_streaming_response(self) -> ParseJobsResourceWithStreamingResponse:
42
+ """
43
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
44
+
45
+ For more information, see https://www.github.com/landing-ai/ade-python#with_streaming_response
46
+ """
47
+ return ParseJobsResourceWithStreamingResponse(self)
48
+
49
+ def create(
50
+ self,
51
+ *,
52
+ document: Optional[FileTypes] | Omit = omit,
53
+ document_url: Optional[str] | Omit = omit,
54
+ model: Optional[str] | Omit = omit,
55
+ output_save_url: Optional[str] | Omit = omit,
56
+ split: Optional[Literal["page"]] | Omit = omit,
57
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
58
+ # The extra values given here take precedence over values defined on the client or passed to this method.
59
+ extra_headers: Headers | None = None,
60
+ extra_query: Query | None = None,
61
+ extra_body: Body | None = None,
62
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
63
+ ) -> ParseJobCreateResponse:
64
+ """
65
+ Parse documents asynchronously.
66
+
67
+ This endpoint creates a job that handles the processing for both large documents
68
+ and large batches of documents.
69
+
70
+ For EU users, use this endpoint:
71
+
72
+ `https://api.va.eu-west-1.landing.ai/v1/ade/parse/jobs`.
73
+
74
+ Args:
75
+ document: A file to be parsed. The file can be a PDF or an image. See the list of
76
+ supported file types here: https://docs.landing.ai/ade/ade-file-types. Either
77
+ this parameter or the `document_url` parameter must be provided.
78
+
79
+ document_url: The URL to the file to be parsed. The file can be a PDF or an image. See the
80
+ list of supported file types here: https://docs.landing.ai/ade/ade-file-types.
81
+ Either this parameter or the `document` parameter must be provided.
82
+
83
+ model: The version of the model to use for parsing.
84
+
85
+ output_save_url: If zero data retention (ZDR) is enabled, you must enter a URL for the parsed
86
+ output to be saved to. When ZDR is enabled, the parsed content will not be in
87
+ the API response.
88
+
89
+ split: If you want to split documents into smaller sections, include the split
90
+ parameter. Set the parameter to page to split documents at the page level. The
91
+ splits object in the API output will contain a set of data for each page.
92
+
93
+ extra_headers: Send extra headers
94
+
95
+ extra_query: Add additional query parameters to the request
96
+
97
+ extra_body: Add additional JSON properties to the request
98
+
99
+ timeout: Override the client-level default timeout for this request, in seconds
100
+ """
101
+ body = deepcopy_minimal(
102
+ {
103
+ "document": document,
104
+ "document_url": document_url,
105
+ "model": model,
106
+ "output_save_url": output_save_url,
107
+ "split": split,
108
+ }
109
+ )
110
+ files = extract_files(cast(Mapping[str, object], body), paths=[["document"]])
111
+ # It should be noted that the actual Content-Type header that will be
112
+ # sent to the server will contain a `boundary` parameter, e.g.
113
+ # multipart/form-data; boundary=---abc--
114
+ extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
115
+ return self._post(
116
+ "/v1/ade/parse/jobs",
117
+ body=maybe_transform(body, parse_job_create_params.ParseJobCreateParams),
118
+ files=files,
119
+ options=make_request_options(
120
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
121
+ ),
122
+ cast_to=ParseJobCreateResponse,
123
+ )
124
+
125
+ def list(
126
+ self,
127
+ *,
128
+ page: int | Omit = omit,
129
+ page_size: int | Omit = omit,
130
+ status: Optional[Literal["cancelled", "completed", "failed", "pending", "processing"]] | Omit = omit,
131
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
132
+ # The extra values given here take precedence over values defined on the client or passed to this method.
133
+ extra_headers: Headers | None = None,
134
+ extra_query: Query | None = None,
135
+ extra_body: Body | None = None,
136
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
137
+ ) -> ParseJobListResponse:
138
+ """List all async parse jobs associated with your API key.
139
+
140
+ Returns the list of jobs
141
+ or an error response. For EU users, use this endpoint:
142
+
143
+ `https://api.va.eu-west-1.landing.ai/v1/ade/parse/jobs`.
144
+
145
+ Args:
146
+ page: Page number (0-indexed)
147
+
148
+ page_size: Number of items per page
149
+
150
+ status: Filter by job status.
151
+
152
+ extra_headers: Send extra headers
153
+
154
+ extra_query: Add additional query parameters to the request
155
+
156
+ extra_body: Add additional JSON properties to the request
157
+
158
+ timeout: Override the client-level default timeout for this request, in seconds
159
+ """
160
+ return self._get(
161
+ "/v1/ade/parse/jobs",
162
+ options=make_request_options(
163
+ extra_headers=extra_headers,
164
+ extra_query=extra_query,
165
+ extra_body=extra_body,
166
+ timeout=timeout,
167
+ query=maybe_transform(
168
+ {
169
+ "page": page,
170
+ "page_size": page_size,
171
+ "status": status,
172
+ },
173
+ parse_job_list_params.ParseJobListParams,
174
+ ),
175
+ ),
176
+ cast_to=ParseJobListResponse,
177
+ )
178
+
179
+ def get(
180
+ self,
181
+ job_id: str,
182
+ *,
183
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
184
+ # The extra values given here take precedence over values defined on the client or passed to this method.
185
+ extra_headers: Headers | None = None,
186
+ extra_query: Query | None = None,
187
+ extra_body: Body | None = None,
188
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
189
+ ) -> ParseJobGetResponse:
190
+ """
191
+ Get the status for an async parse job.
192
+
193
+ Returns the job status or an error response. For EU users, use this endpoint:
194
+
195
+ `https://api.va.eu-west-1.landing.ai/v1/ade/parse/jobs/{job_id}`.
196
+
197
+ Args:
198
+ extra_headers: Send extra headers
199
+
200
+ extra_query: Add additional query parameters to the request
201
+
202
+ extra_body: Add additional JSON properties to the request
203
+
204
+ timeout: Override the client-level default timeout for this request, in seconds
205
+ """
206
+ if not job_id:
207
+ raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}")
208
+ return self._get(
209
+ f"/v1/ade/parse/jobs/{job_id}",
210
+ options=make_request_options(
211
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
212
+ ),
213
+ cast_to=ParseJobGetResponse,
214
+ )
215
+
216
+
217
+ class AsyncParseJobsResource(AsyncAPIResource):
218
+ @cached_property
219
+ def with_raw_response(self) -> AsyncParseJobsResourceWithRawResponse:
220
+ """
221
+ This property can be used as a prefix for any HTTP method call to return
222
+ the raw response object instead of the parsed content.
223
+
224
+ For more information, see https://www.github.com/landing-ai/ade-python#accessing-raw-response-data-eg-headers
225
+ """
226
+ return AsyncParseJobsResourceWithRawResponse(self)
227
+
228
+ @cached_property
229
+ def with_streaming_response(self) -> AsyncParseJobsResourceWithStreamingResponse:
230
+ """
231
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
232
+
233
+ For more information, see https://www.github.com/landing-ai/ade-python#with_streaming_response
234
+ """
235
+ return AsyncParseJobsResourceWithStreamingResponse(self)
236
+
237
+ async def create(
238
+ self,
239
+ *,
240
+ document: Optional[FileTypes] | Omit = omit,
241
+ document_url: Optional[str] | Omit = omit,
242
+ model: Optional[str] | Omit = omit,
243
+ output_save_url: Optional[str] | Omit = omit,
244
+ split: Optional[Literal["page"]] | Omit = omit,
245
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
246
+ # The extra values given here take precedence over values defined on the client or passed to this method.
247
+ extra_headers: Headers | None = None,
248
+ extra_query: Query | None = None,
249
+ extra_body: Body | None = None,
250
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
251
+ ) -> ParseJobCreateResponse:
252
+ """
253
+ Parse documents asynchronously.
254
+
255
+ This endpoint creates a job that handles the processing for both large documents
256
+ and large batches of documents.
257
+
258
+ For EU users, use this endpoint:
259
+
260
+ `https://api.va.eu-west-1.landing.ai/v1/ade/parse/jobs`.
261
+
262
+ Args:
263
+ document: A file to be parsed. The file can be a PDF or an image. See the list of
264
+ supported file types here: https://docs.landing.ai/ade/ade-file-types. Either
265
+ this parameter or the `document_url` parameter must be provided.
266
+
267
+ document_url: The URL to the file to be parsed. The file can be a PDF or an image. See the
268
+ list of supported file types here: https://docs.landing.ai/ade/ade-file-types.
269
+ Either this parameter or the `document` parameter must be provided.
270
+
271
+ model: The version of the model to use for parsing.
272
+
273
+ output_save_url: If zero data retention (ZDR) is enabled, you must enter a URL for the parsed
274
+ output to be saved to. When ZDR is enabled, the parsed content will not be in
275
+ the API response.
276
+
277
+ split: If you want to split documents into smaller sections, include the split
278
+ parameter. Set the parameter to page to split documents at the page level. The
279
+ splits object in the API output will contain a set of data for each page.
280
+
281
+ extra_headers: Send extra headers
282
+
283
+ extra_query: Add additional query parameters to the request
284
+
285
+ extra_body: Add additional JSON properties to the request
286
+
287
+ timeout: Override the client-level default timeout for this request, in seconds
288
+ """
289
+ body = deepcopy_minimal(
290
+ {
291
+ "document": document,
292
+ "document_url": document_url,
293
+ "model": model,
294
+ "output_save_url": output_save_url,
295
+ "split": split,
296
+ }
297
+ )
298
+ files = extract_files(cast(Mapping[str, object], body), paths=[["document"]])
299
+ # It should be noted that the actual Content-Type header that will be
300
+ # sent to the server will contain a `boundary` parameter, e.g.
301
+ # multipart/form-data; boundary=---abc--
302
+ extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
303
+ return await self._post(
304
+ "/v1/ade/parse/jobs",
305
+ body=await async_maybe_transform(body, parse_job_create_params.ParseJobCreateParams),
306
+ files=files,
307
+ options=make_request_options(
308
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
309
+ ),
310
+ cast_to=ParseJobCreateResponse,
311
+ )
312
+
313
+ async def list(
314
+ self,
315
+ *,
316
+ page: int | Omit = omit,
317
+ page_size: int | Omit = omit,
318
+ status: Optional[Literal["cancelled", "completed", "failed", "pending", "processing"]] | Omit = omit,
319
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
320
+ # The extra values given here take precedence over values defined on the client or passed to this method.
321
+ extra_headers: Headers | None = None,
322
+ extra_query: Query | None = None,
323
+ extra_body: Body | None = None,
324
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
325
+ ) -> ParseJobListResponse:
326
+ """List all async parse jobs associated with your API key.
327
+
328
+ Returns the list of jobs
329
+ or an error response. For EU users, use this endpoint:
330
+
331
+ `https://api.va.eu-west-1.landing.ai/v1/ade/parse/jobs`.
332
+
333
+ Args:
334
+ page: Page number (0-indexed)
335
+
336
+ page_size: Number of items per page
337
+
338
+ status: Filter by job status.
339
+
340
+ extra_headers: Send extra headers
341
+
342
+ extra_query: Add additional query parameters to the request
343
+
344
+ extra_body: Add additional JSON properties to the request
345
+
346
+ timeout: Override the client-level default timeout for this request, in seconds
347
+ """
348
+ return await self._get(
349
+ "/v1/ade/parse/jobs",
350
+ options=make_request_options(
351
+ extra_headers=extra_headers,
352
+ extra_query=extra_query,
353
+ extra_body=extra_body,
354
+ timeout=timeout,
355
+ query=await async_maybe_transform(
356
+ {
357
+ "page": page,
358
+ "page_size": page_size,
359
+ "status": status,
360
+ },
361
+ parse_job_list_params.ParseJobListParams,
362
+ ),
363
+ ),
364
+ cast_to=ParseJobListResponse,
365
+ )
366
+
367
+ async def get(
368
+ self,
369
+ job_id: str,
370
+ *,
371
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
372
+ # The extra values given here take precedence over values defined on the client or passed to this method.
373
+ extra_headers: Headers | None = None,
374
+ extra_query: Query | None = None,
375
+ extra_body: Body | None = None,
376
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
377
+ ) -> ParseJobGetResponse:
378
+ """
379
+ Get the status for an async parse job.
380
+
381
+ Returns the job status or an error response. For EU users, use this endpoint:
382
+
383
+ `https://api.va.eu-west-1.landing.ai/v1/ade/parse/jobs/{job_id}`.
384
+
385
+ Args:
386
+ extra_headers: Send extra headers
387
+
388
+ extra_query: Add additional query parameters to the request
389
+
390
+ extra_body: Add additional JSON properties to the request
391
+
392
+ timeout: Override the client-level default timeout for this request, in seconds
393
+ """
394
+ if not job_id:
395
+ raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}")
396
+ return await self._get(
397
+ f"/v1/ade/parse/jobs/{job_id}",
398
+ options=make_request_options(
399
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
400
+ ),
401
+ cast_to=ParseJobGetResponse,
402
+ )
403
+
404
+
405
+ class ParseJobsResourceWithRawResponse:
406
+ def __init__(self, parse_jobs: ParseJobsResource) -> None:
407
+ self._parse_jobs = parse_jobs
408
+
409
+ self.create = to_raw_response_wrapper(
410
+ parse_jobs.create,
411
+ )
412
+ self.list = to_raw_response_wrapper(
413
+ parse_jobs.list,
414
+ )
415
+ self.get = to_raw_response_wrapper(
416
+ parse_jobs.get,
417
+ )
418
+
419
+
420
+ class AsyncParseJobsResourceWithRawResponse:
421
+ def __init__(self, parse_jobs: AsyncParseJobsResource) -> None:
422
+ self._parse_jobs = parse_jobs
423
+
424
+ self.create = async_to_raw_response_wrapper(
425
+ parse_jobs.create,
426
+ )
427
+ self.list = async_to_raw_response_wrapper(
428
+ parse_jobs.list,
429
+ )
430
+ self.get = async_to_raw_response_wrapper(
431
+ parse_jobs.get,
432
+ )
433
+
434
+
435
+ class ParseJobsResourceWithStreamingResponse:
436
+ def __init__(self, parse_jobs: ParseJobsResource) -> None:
437
+ self._parse_jobs = parse_jobs
438
+
439
+ self.create = to_streamed_response_wrapper(
440
+ parse_jobs.create,
441
+ )
442
+ self.list = to_streamed_response_wrapper(
443
+ parse_jobs.list,
444
+ )
445
+ self.get = to_streamed_response_wrapper(
446
+ parse_jobs.get,
447
+ )
448
+
449
+
450
+ class AsyncParseJobsResourceWithStreamingResponse:
451
+ def __init__(self, parse_jobs: AsyncParseJobsResource) -> None:
452
+ self._parse_jobs = parse_jobs
453
+
454
+ self.create = async_to_streamed_response_wrapper(
455
+ parse_jobs.create,
456
+ )
457
+ self.list = async_to_streamed_response_wrapper(
458
+ parse_jobs.list,
459
+ )
460
+ self.get = async_to_streamed_response_wrapper(
461
+ parse_jobs.get,
462
+ )
@@ -2,7 +2,13 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from .shared import ParseMetadata as ParseMetadata, ParseGroundingBox as ParseGroundingBox
5
6
  from .parse_response import ParseResponse as ParseResponse
6
7
  from .extract_response import ExtractResponse as ExtractResponse
7
8
  from .client_parse_params import ClientParseParams as ClientParseParams
8
9
  from .client_extract_params import ClientExtractParams as ClientExtractParams
10
+ from .parse_job_list_params import ParseJobListParams as ParseJobListParams
11
+ from .parse_job_get_response import ParseJobGetResponse as ParseJobGetResponse
12
+ from .parse_job_create_params import ParseJobCreateParams as ParseJobCreateParams
13
+ from .parse_job_list_response import ParseJobListResponse as ParseJobListResponse
14
+ from .parse_job_create_response import ParseJobCreateResponse as ParseJobCreateResponse
@@ -3,7 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  from typing import Optional
6
- from typing_extensions import Literal, Required, TypedDict
6
+ from typing_extensions import Required, TypedDict
7
7
 
8
8
  from .._types import FileTypes
9
9
 
@@ -25,5 +25,8 @@ class ClientExtractParams(TypedDict, total=False):
25
25
  markdown_url: Optional[str]
26
26
  """The URL to the Markdown file to extract data from."""
27
27
 
28
- model: Optional[Literal["extract-20250630", "extract-20250930"]]
29
- """The version of the model to use for extraction."""
28
+ model: Optional[str]
29
+ """The version of the model to use for extraction.
30
+
31
+ Use `extract-latest` to use the latest version.
32
+ """
@@ -20,6 +20,13 @@ class Metadata(BaseModel):
20
20
 
21
21
  version: Optional[str] = None
22
22
 
23
+ schema_violation_error: Optional[str] = None
24
+ """
25
+ A detailed error message shows why the extracted data does not fully conform to
26
+ the input schema. Null means the extraction result is consistent with the input
27
+ schema.
28
+ """
29
+
23
30
 
24
31
  class ExtractResponse(BaseModel):
25
32
  extraction: object
@@ -0,0 +1,45 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+ from typing_extensions import Literal, TypedDict
7
+
8
+ from .._types import FileTypes
9
+
10
+ __all__ = ["ParseJobCreateParams"]
11
+
12
+
13
+ class ParseJobCreateParams(TypedDict, total=False):
14
+ document: Optional[FileTypes]
15
+ """A file to be parsed.
16
+
17
+ The file can be a PDF or an image. See the list of supported file types here:
18
+ https://docs.landing.ai/ade/ade-file-types. Either this parameter or the
19
+ `document_url` parameter must be provided.
20
+ """
21
+
22
+ document_url: Optional[str]
23
+ """The URL to the file to be parsed.
24
+
25
+ The file can be a PDF or an image. See the list of supported file types here:
26
+ https://docs.landing.ai/ade/ade-file-types. Either this parameter or the
27
+ `document` parameter must be provided.
28
+ """
29
+
30
+ model: Optional[str]
31
+ """The version of the model to use for parsing."""
32
+
33
+ output_save_url: Optional[str]
34
+ """
35
+ If zero data retention (ZDR) is enabled, you must enter a URL for the parsed
36
+ output to be saved to. When ZDR is enabled, the parsed content will not be in
37
+ the API response.
38
+ """
39
+
40
+ split: Optional[Literal["page"]]
41
+ """
42
+ If you want to split documents into smaller sections, include the split
43
+ parameter. Set the parameter to page to split documents at the page level. The
44
+ splits object in the API output will contain a set of data for each page.
45
+ """
@@ -0,0 +1,9 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from .._models import BaseModel
4
+
5
+ __all__ = ["ParseJobCreateResponse"]
6
+
7
+
8
+ class ParseJobCreateResponse(BaseModel):
9
+ job_id: str