unsiloed-apimatic-sdk 0.0.2__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.
- unsiloed_ai_document_processing_api/__init__.py +14 -0
- unsiloed_ai_document_processing_api/apis/__init__.py +24 -0
- unsiloed_ai_document_processing_api/apis/classify.py +264 -0
- unsiloed_ai_document_processing_api/apis/extract.py +387 -0
- unsiloed_ai_document_processing_api/apis/health.py +102 -0
- unsiloed_ai_document_processing_api/apis/organization.py +97 -0
- unsiloed_ai_document_processing_api/apis/parse_v2_presigned_upload.py +147 -0
- unsiloed_ai_document_processing_api/apis/parse_vision_api_compatible.py +1222 -0
- unsiloed_ai_document_processing_api/apis/split.py +285 -0
- unsiloed_ai_document_processing_api/async_client.py +98 -0
- unsiloed_ai_document_processing_api/auth.py +15 -0
- unsiloed_ai_document_processing_api/base_client.py +30 -0
- unsiloed_ai_document_processing_api/client.py +96 -0
- unsiloed_ai_document_processing_api/core/__init__.py +345 -0
- unsiloed_ai_document_processing_api/core/_internal/__init__.py +7 -0
- unsiloed_ai_document_processing_api/core/_internal/content_disposition.py +154 -0
- unsiloed_ai_document_processing_api/core/_internal/flattening.py +139 -0
- unsiloed_ai_document_processing_api/core/_internal/headers.py +144 -0
- unsiloed_ai_document_processing_api/core/_internal/urls.py +166 -0
- unsiloed_ai_document_processing_api/core/_internal/wire.py +173 -0
- unsiloed_ai_document_processing_api/core/adapters.py +177 -0
- unsiloed_ai_document_processing_api/core/auth/__init__.py +70 -0
- unsiloed_ai_document_processing_api/core/auth/composition.py +175 -0
- unsiloed_ai_document_processing_api/core/auth/models.py +217 -0
- unsiloed_ai_document_processing_api/core/auth/protocols.py +103 -0
- unsiloed_ai_document_processing_api/core/auth/schemes/__init__.py +94 -0
- unsiloed_ai_document_processing_api/core/auth/schemes/api_key_auth.py +53 -0
- unsiloed_ai_document_processing_api/core/auth/schemes/basic_auth.py +73 -0
- unsiloed_ai_document_processing_api/core/auth/schemes/bearer_auth.py +21 -0
- unsiloed_ai_document_processing_api/core/auth/schemes/oauth2_authorization_code.py +393 -0
- unsiloed_ai_document_processing_api/core/auth/schemes/oauth2_client_credentials.py +127 -0
- unsiloed_ai_document_processing_api/core/auth/schemes/oauth2_password.py +142 -0
- unsiloed_ai_document_processing_api/core/auth/schemes/oauth2_schemes.py +300 -0
- unsiloed_ai_document_processing_api/core/base_raw_response.py +49 -0
- unsiloed_ai_document_processing_api/core/bodies.py +563 -0
- unsiloed_ai_document_processing_api/core/converters/__init__.py +68 -0
- unsiloed_ai_document_processing_api/core/converters/date_time.py +237 -0
- unsiloed_ai_document_processing_api/core/converters/encoded_bytes.py +273 -0
- unsiloed_ai_document_processing_api/core/converters/open_enum.py +35 -0
- unsiloed_ai_document_processing_api/core/decoding.py +263 -0
- unsiloed_ai_document_processing_api/core/discriminators.py +128 -0
- unsiloed_ai_document_processing_api/core/exceptions.py +41 -0
- unsiloed_ai_document_processing_api/core/file_responses.py +324 -0
- unsiloed_ai_document_processing_api/core/files.py +173 -0
- unsiloed_ai_document_processing_api/core/httpx_transport.py +766 -0
- unsiloed_ai_document_processing_api/core/models.py +143 -0
- unsiloed_ai_document_processing_api/core/optionality.py +130 -0
- unsiloed_ai_document_processing_api/core/params.py +161 -0
- unsiloed_ai_document_processing_api/core/raw_client.py +388 -0
- unsiloed_ai_document_processing_api/core/request_options.py +94 -0
- unsiloed_ai_document_processing_api/core/results.py +110 -0
- unsiloed_ai_document_processing_api/core/runtime_env.py +43 -0
- unsiloed_ai_document_processing_api/core/servers.py +33 -0
- unsiloed_ai_document_processing_api/core/transport.py +248 -0
- unsiloed_ai_document_processing_api/errors/__init__.py +39 -0
- unsiloed_ai_document_processing_api/errors/classify_document_error.py +28 -0
- unsiloed_ai_document_processing_api/errors/create_parse_task_error.py +37 -0
- unsiloed_ai_document_processing_api/errors/create_parse_task_excel_error.py +37 -0
- unsiloed_ai_document_processing_api/errors/create_presigned_upload_error.py +30 -0
- unsiloed_ai_document_processing_api/errors/extract_data_error.py +25 -0
- unsiloed_ai_document_processing_api/errors/get_classification_job_status_error.py +27 -0
- unsiloed_ai_document_processing_api/errors/get_extraction_job_status_error.py +27 -0
- unsiloed_ai_document_processing_api/errors/get_organization_usage_error.py +25 -0
- unsiloed_ai_document_processing_api/errors/get_parse_task_error.py +24 -0
- unsiloed_ai_document_processing_api/errors/get_split_status_error.py +25 -0
- unsiloed_ai_document_processing_api/errors/split_document_error.py +25 -0
- unsiloed_ai_document_processing_api/models/__init__.py +260 -0
- unsiloed_ai_document_processing_api/models/auto_generation_config.py +34 -0
- unsiloed_ai_document_processing_api/models/bounding_box.py +28 -0
- unsiloed_ai_document_processing_api/models/category.py +19 -0
- unsiloed_ai_document_processing_api/models/chunk.py +30 -0
- unsiloed_ai_document_processing_api/models/chunk_processing.py +25 -0
- unsiloed_ai_document_processing_api/models/classify402_error.py +14 -0
- unsiloed_ai_document_processing_api/models/classify402_error1.py +14 -0
- unsiloed_ai_document_processing_api/models/classify_response.py +26 -0
- unsiloed_ai_document_processing_api/models/classify_response1.py +32 -0
- unsiloed_ai_document_processing_api/models/configuration.py +183 -0
- unsiloed_ai_document_processing_api/models/configuration1.py +186 -0
- unsiloed_ai_document_processing_api/models/detail.py +16 -0
- unsiloed_ai_document_processing_api/models/detail_error.py +17 -0
- unsiloed_ai_document_processing_api/models/detail_error_error.py +17 -0
- unsiloed_ai_document_processing_api/models/details.py +20 -0
- unsiloed_ai_document_processing_api/models/enums/__init__.py +186 -0
- unsiloed_ai_document_processing_api/models/enums/agentic_ocr.py +16 -0
- unsiloed_ai_document_processing_api/models/enums/agentic_ocr2.py +16 -0
- unsiloed_ai_document_processing_api/models/enums/content_source.py +19 -0
- unsiloed_ai_document_processing_api/models/enums/content_source1.py +19 -0
- unsiloed_ai_document_processing_api/models/enums/content_source7.py +19 -0
- unsiloed_ai_document_processing_api/models/enums/cropping_strategy.py +19 -0
- unsiloed_ai_document_processing_api/models/enums/embed_source.py +16 -0
- unsiloed_ai_document_processing_api/models/enums/engine.py +14 -0
- unsiloed_ai_document_processing_api/models/enums/error_handling.py +17 -0
- unsiloed_ai_document_processing_api/models/enums/error_handling1.py +16 -0
- unsiloed_ai_document_processing_api/models/enums/error_handling2.py +17 -0
- unsiloed_ai_document_processing_api/models/enums/error_handling_strategy.py +20 -0
- unsiloed_ai_document_processing_api/models/enums/export_format.py +19 -0
- unsiloed_ai_document_processing_api/models/enums/generation_strategy.py +14 -0
- unsiloed_ai_document_processing_api/models/enums/layout_analysis.py +20 -0
- unsiloed_ai_document_processing_api/models/enums/layout_analysis1.py +19 -0
- unsiloed_ai_document_processing_api/models/enums/layout_analysis2.py +19 -0
- unsiloed_ai_document_processing_api/models/enums/model.py +14 -0
- unsiloed_ai_document_processing_api/models/enums/model1.py +18 -0
- unsiloed_ai_document_processing_api/models/enums/ocr_engine.py +20 -0
- unsiloed_ai_document_processing_api/models/enums/ocr_engine1.py +17 -0
- unsiloed_ai_document_processing_api/models/enums/ocr_strategy.py +19 -0
- unsiloed_ai_document_processing_api/models/enums/ocr_strategy1.py +17 -0
- unsiloed_ai_document_processing_api/models/enums/ocr_strategy2.py +16 -0
- unsiloed_ai_document_processing_api/models/enums/ocr_strategy3.py +17 -0
- unsiloed_ai_document_processing_api/models/enums/picture_cropping_strategy.py +22 -0
- unsiloed_ai_document_processing_api/models/enums/pii_block_severity.py +22 -0
- unsiloed_ai_document_processing_api/models/enums/pii_block_severity1.py +19 -0
- unsiloed_ai_document_processing_api/models/enums/pii_block_severity2.py +23 -0
- unsiloed_ai_document_processing_api/models/enums/pii_block_severity3.py +18 -0
- unsiloed_ai_document_processing_api/models/enums/pii_block_severity4.py +18 -0
- unsiloed_ai_document_processing_api/models/enums/pii_engine.py +18 -0
- unsiloed_ai_document_processing_api/models/enums/pii_engine1.py +17 -0
- unsiloed_ai_document_processing_api/models/enums/pii_engine2.py +21 -0
- unsiloed_ai_document_processing_api/models/enums/pii_engine3.py +16 -0
- unsiloed_ai_document_processing_api/models/enums/pii_engine4.py +16 -0
- unsiloed_ai_document_processing_api/models/enums/response_profile.py +24 -0
- unsiloed_ai_document_processing_api/models/enums/response_profile1.py +29 -0
- unsiloed_ai_document_processing_api/models/enums/response_profile2.py +24 -0
- unsiloed_ai_document_processing_api/models/enums/response_profile3.py +29 -0
- unsiloed_ai_document_processing_api/models/enums/response_profile4.py +19 -0
- unsiloed_ai_document_processing_api/models/enums/segment_type.py +30 -0
- unsiloed_ai_document_processing_api/models/enums/segment_type_naming.py +17 -0
- unsiloed_ai_document_processing_api/models/enums/segment_type_naming1.py +16 -0
- unsiloed_ai_document_processing_api/models/enums/segment_type_naming2.py +17 -0
- unsiloed_ai_document_processing_api/models/enums/segment_type_naming_convention.py +22 -0
- unsiloed_ai_document_processing_api/models/enums/segment_type_naming_convention2.py +18 -0
- unsiloed_ai_document_processing_api/models/enums/segmentation_strategy.py +25 -0
- unsiloed_ai_document_processing_api/models/enums/segmentation_version.py +21 -0
- unsiloed_ai_document_processing_api/models/enums/segmentation_version1.py +17 -0
- unsiloed_ai_document_processing_api/models/enums/segmentation_version3.py +17 -0
- unsiloed_ai_document_processing_api/models/enums/severity.py +16 -0
- unsiloed_ai_document_processing_api/models/enums/status.py +21 -0
- unsiloed_ai_document_processing_api/models/enums/status1.py +18 -0
- unsiloed_ai_document_processing_api/models/enums/status2.py +19 -0
- unsiloed_ai_document_processing_api/models/enums/status3.py +21 -0
- unsiloed_ai_document_processing_api/models/enums/table_clustering.py +17 -0
- unsiloed_ai_document_processing_api/models/enums/tokenizer.py +18 -0
- unsiloed_ai_document_processing_api/models/enums/tokenizer2.py +18 -0
- unsiloed_ai_document_processing_api/models/enums/translation_provider.py +15 -0
- unsiloed_ai_document_processing_api/models/enums/translation_provider2.py +18 -0
- unsiloed_ai_document_processing_api/models/error.py +22 -0
- unsiloed_ai_document_processing_api/models/error_envelope.py +16 -0
- unsiloed_ai_document_processing_api/models/error_envelope_error.py +16 -0
- unsiloed_ai_document_processing_api/models/excel_configuration.py +68 -0
- unsiloed_ai_document_processing_api/models/excel_configuration2.py +65 -0
- unsiloed_ai_document_processing_api/models/excel_parse_create_request.py +67 -0
- unsiloed_ai_document_processing_api/models/excel_parse_url_request.py +59 -0
- unsiloed_ai_document_processing_api/models/extract_job_created.py +28 -0
- unsiloed_ai_document_processing_api/models/extraction_citation.py +23 -0
- unsiloed_ai_document_processing_api/models/extraction_job.py +38 -0
- unsiloed_ai_document_processing_api/models/file.py +36 -0
- unsiloed_ai_document_processing_api/models/file_too_large_error.py +19 -0
- unsiloed_ai_document_processing_api/models/file_too_large_error_error.py +19 -0
- unsiloed_ai_document_processing_api/models/formula_generation_config.py +45 -0
- unsiloed_ai_document_processing_api/models/health_response.py +13 -0
- unsiloed_ai_document_processing_api/models/insufficient_quota_error.py +18 -0
- unsiloed_ai_document_processing_api/models/insufficient_quota_error_error.py +18 -0
- unsiloed_ai_document_processing_api/models/key_value_pair_generation_config.py +45 -0
- unsiloed_ai_document_processing_api/models/legacy_field.py +17 -0
- unsiloed_ai_document_processing_api/models/llm_generation_config.py +43 -0
- unsiloed_ai_document_processing_api/models/metadata.py +24 -0
- unsiloed_ai_document_processing_api/models/ocrresult.py +32 -0
- unsiloed_ai_document_processing_api/models/org_get_usage401_error.py +13 -0
- unsiloed_ai_document_processing_api/models/org_get_usage401_error1.py +13 -0
- unsiloed_ai_document_processing_api/models/org_get_usage404_error.py +13 -0
- unsiloed_ai_document_processing_api/models/org_get_usage404_error1.py +13 -0
- unsiloed_ai_document_processing_api/models/org_get_usage_response.py +34 -0
- unsiloed_ai_document_processing_api/models/output_fields_config.py +50 -0
- unsiloed_ai_document_processing_api/models/output_fields_config2.py +50 -0
- unsiloed_ai_document_processing_api/models/page_bbox.py +24 -0
- unsiloed_ai_document_processing_api/models/page_result.py +34 -0
- unsiloed_ai_document_processing_api/models/parameters.py +30 -0
- unsiloed_ai_document_processing_api/models/parse_create_request.py +195 -0
- unsiloed_ai_document_processing_api/models/parse_create_response.py +45 -0
- unsiloed_ai_document_processing_api/models/parse_get_response.py +97 -0
- unsiloed_ai_document_processing_api/models/picture_generation_config.py +46 -0
- unsiloed_ai_document_processing_api/models/pii_blocked_response.py +44 -0
- unsiloed_ai_document_processing_api/models/presigned_upload_request.py +175 -0
- unsiloed_ai_document_processing_api/models/presigned_upload_response.py +44 -0
- unsiloed_ai_document_processing_api/models/quota_data.py +13 -0
- unsiloed_ai_document_processing_api/models/quota_data1.py +15 -0
- unsiloed_ai_document_processing_api/models/rate_limit_error.py +18 -0
- unsiloed_ai_document_processing_api/models/rate_limit_error_error.py +18 -0
- unsiloed_ai_document_processing_api/models/result.py +15 -0
- unsiloed_ai_document_processing_api/models/result1.py +46 -0
- unsiloed_ai_document_processing_api/models/result2.py +25 -0
- unsiloed_ai_document_processing_api/models/score.py +18 -0
- unsiloed_ai_document_processing_api/models/scored_field.py +21 -0
- unsiloed_ai_document_processing_api/models/segment.py +88 -0
- unsiloed_ai_document_processing_api/models/segment_processing.py +46 -0
- unsiloed_ai_document_processing_api/models/splitter_response.py +22 -0
- unsiloed_ai_document_processing_api/models/splitter_response1.py +46 -0
- unsiloed_ai_document_processing_api/models/table_generation_config.py +45 -0
- unsiloed_ai_document_processing_api/models/text_color.py +21 -0
- unsiloed_ai_document_processing_api/models/text_color2.py +21 -0
- unsiloed_ai_document_processing_api/models/tokenizer_type.py +18 -0
- unsiloed_ai_document_processing_api/models/tokenizer_type1.py +17 -0
- unsiloed_ai_document_processing_api/models/translation_config.py +30 -0
- unsiloed_ai_document_processing_api/models/translation_config1.py +32 -0
- unsiloed_ai_document_processing_api/models/unions/__init__.py +21 -0
- unsiloed_ai_document_processing_api/models/unions/detail1.py +8 -0
- unsiloed_ai_document_processing_api/models/unions/extracted_field.py +13 -0
- unsiloed_ai_document_processing_api/models/unions/segment_type1.py +11 -0
- unsiloed_ai_document_processing_api/models/unions/tokenizer_type2.py +11 -0
- unsiloed_ai_document_processing_api/models/unions/tokenizer_type21.py +15 -0
- unsiloed_ai_document_processing_api/models/unions/v2_extract_response.py +10 -0
- unsiloed_ai_document_processing_api/models/v2_parse_upload400_error.py +13 -0
- unsiloed_ai_document_processing_api/models/v2_parse_upload400_error1.py +13 -0
- unsiloed_ai_document_processing_api/py.typed +0 -0
- unsiloed_ai_document_processing_api/server/__init__.py +5 -0
- unsiloed_ai_document_processing_api/server/environment.py +11 -0
- unsiloed_ai_document_processing_api/server/server.py +16 -0
- unsiloed_ai_document_processing_api/server/server_config.py +26 -0
- unsiloed_apimatic_sdk-0.0.2.dist-info/METADATA +156 -0
- unsiloed_apimatic_sdk-0.0.2.dist-info/RECORD +221 -0
- unsiloed_apimatic_sdk-0.0.2.dist-info/WHEEL +4 -0
- unsiloed_apimatic_sdk-0.0.2.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from . import models
|
|
2
|
+
from .async_client import AsyncClient, AsyncUnsiloedAiDocumentProcessingApiClient
|
|
3
|
+
from .client import Client, UnsiloedAiDocumentProcessingApiClient
|
|
4
|
+
from .server import Environment, ServerConfig
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"models",
|
|
8
|
+
"AsyncClient",
|
|
9
|
+
"AsyncUnsiloedAiDocumentProcessingApiClient",
|
|
10
|
+
"Client",
|
|
11
|
+
"Environment",
|
|
12
|
+
"ServerConfig",
|
|
13
|
+
"UnsiloedAiDocumentProcessingApiClient",
|
|
14
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from .classify import AsyncClassify, Classify
|
|
2
|
+
from .extract import AsyncExtract, Extract
|
|
3
|
+
from .health import AsyncHealth, Health
|
|
4
|
+
from .organization import AsyncOrganization, Organization
|
|
5
|
+
from .parse_v2_presigned_upload import AsyncParseV2PresignedUpload, ParseV2PresignedUpload
|
|
6
|
+
from .parse_vision_api_compatible import AsyncParseVisionApiCompatible, ParseVisionApiCompatible
|
|
7
|
+
from .split import AsyncSplit, Split
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"AsyncClassify",
|
|
11
|
+
"AsyncExtract",
|
|
12
|
+
"AsyncHealth",
|
|
13
|
+
"AsyncOrganization",
|
|
14
|
+
"AsyncParseV2PresignedUpload",
|
|
15
|
+
"AsyncParseVisionApiCompatible",
|
|
16
|
+
"AsyncSplit",
|
|
17
|
+
"Classify",
|
|
18
|
+
"Extract",
|
|
19
|
+
"Health",
|
|
20
|
+
"Organization",
|
|
21
|
+
"ParseV2PresignedUpload",
|
|
22
|
+
"ParseVisionApiCompatible",
|
|
23
|
+
"Split",
|
|
24
|
+
]
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from uuid import UUID, uuid4
|
|
4
|
+
|
|
5
|
+
from ..auth import AsyncAuthSchemes, AuthSchemes
|
|
6
|
+
from ..core import (
|
|
7
|
+
ApiResult,
|
|
8
|
+
AsyncFileInput,
|
|
9
|
+
AsyncRawClient,
|
|
10
|
+
FileInput,
|
|
11
|
+
RawClient,
|
|
12
|
+
RequestOptionsOrDict,
|
|
13
|
+
SecuredRawResponse,
|
|
14
|
+
file_part,
|
|
15
|
+
json_decoder,
|
|
16
|
+
multipart_body,
|
|
17
|
+
param,
|
|
18
|
+
)
|
|
19
|
+
from ..errors.classify_document_error import ClassifyDocumentErrorBody, classify_document_error_mapper
|
|
20
|
+
from ..errors.get_classification_job_status_error import (
|
|
21
|
+
GetClassificationJobStatusErrorBody,
|
|
22
|
+
get_classification_job_status_error_mapper,
|
|
23
|
+
)
|
|
24
|
+
from ..models.classify_response import ClassifyResponse
|
|
25
|
+
from ..models.classify_response1 import ClassifyResponse1
|
|
26
|
+
from ..server.server import Server
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Classify:
|
|
30
|
+
def __init__(self, client: RawClient, server: Server, auth: AuthSchemes) -> None:
|
|
31
|
+
self._with_raw_response = ClassifyWithRawResponse(client, server, auth)
|
|
32
|
+
|
|
33
|
+
def classify_document(
|
|
34
|
+
self,
|
|
35
|
+
categories: str,
|
|
36
|
+
*,
|
|
37
|
+
pdf_file: FileInput | None = None,
|
|
38
|
+
file_url: str | None = None,
|
|
39
|
+
request_options: RequestOptionsOrDict | None = None,
|
|
40
|
+
) -> ClassifyResponse:
|
|
41
|
+
"""Classify PDF and image documents into predefined categories
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
categories: JSON string containing an array of category objects with a required name. Example:
|
|
45
|
+
[{"name":"invoice"},{"name":"contract"},{"name":"receipt"}]. A "description" key is accepted for
|
|
46
|
+
compatibility but is not used by classification.
|
|
47
|
+
pdf_file: The document to classify: a PDF or an image (JPG, PNG, GIF, WebP, BMP, TIFF). Provide either
|
|
48
|
+
pdf_file or file_url, not both. Maximum file size: 500MB.
|
|
49
|
+
file_url: URL to a document to classify (PDF or image). Provide either pdf_file or file_url, not both.
|
|
50
|
+
request_options: Per-call overrides for this one request, such as a timeout or extra headers.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
Accepted - classification job started
|
|
54
|
+
|
|
55
|
+
Raises:
|
|
56
|
+
ApiError: Bad request, e.g. neither ``pdf_file`` nor ``file_url`` provided, or invalid schema. Missing or
|
|
57
|
+
invalid API key. Insufficient quota. Missing or malformed form fields. Rate limit exceeded. Service
|
|
58
|
+
unavailable. Either the job queue is full (``error.details.reason`` = ``queue_full``, ``Retry-After``
|
|
59
|
+
5-60 s) or the platform-wide capacity limit was hit (``Retry-After: 5``, no ``details``). ``error`` is
|
|
60
|
+
``DetailError | Classify402Error1 | ErrorEnvelope | RawError``."""
|
|
61
|
+
return self._with_raw_response.classify_document(
|
|
62
|
+
categories, pdf_file=pdf_file, file_url=file_url, request_options=request_options
|
|
63
|
+
).unwrap()
|
|
64
|
+
|
|
65
|
+
def get_classification_job_status(
|
|
66
|
+
self, job_id: str, *, request_options: RequestOptionsOrDict | None = None
|
|
67
|
+
) -> ClassifyResponse1:
|
|
68
|
+
"""Check the status and progress of classification jobs and retrieve results
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
job_id: The unique identifier of the classification job
|
|
72
|
+
request_options: Per-call overrides for this one request, such as a timeout or extra headers.
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
Classification job status retrieved successfully
|
|
76
|
+
|
|
77
|
+
Raises:
|
|
78
|
+
ApiError: Job not found. Service unavailable: platform-wide capacity limit reached. Retry after the
|
|
79
|
+
``Retry-After`` header (5 s). ``error`` is ``DetailError | ErrorEnvelope | RawError``."""
|
|
80
|
+
return self._with_raw_response.get_classification_job_status(job_id, request_options=request_options).unwrap()
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def with_raw_response(self) -> ClassifyWithRawResponse:
|
|
84
|
+
return self._with_raw_response
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class AsyncClassify:
|
|
88
|
+
def __init__(self, client: AsyncRawClient, server: Server, auth: AsyncAuthSchemes) -> None:
|
|
89
|
+
self._with_raw_response = AsyncClassifyWithRawResponse(client, server, auth)
|
|
90
|
+
|
|
91
|
+
async def classify_document(
|
|
92
|
+
self,
|
|
93
|
+
categories: str,
|
|
94
|
+
*,
|
|
95
|
+
pdf_file: AsyncFileInput | None = None,
|
|
96
|
+
file_url: str | None = None,
|
|
97
|
+
request_options: RequestOptionsOrDict | None = None,
|
|
98
|
+
) -> ClassifyResponse:
|
|
99
|
+
"""Classify PDF and image documents into predefined categories
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
categories: JSON string containing an array of category objects with a required name. Example:
|
|
103
|
+
[{"name":"invoice"},{"name":"contract"},{"name":"receipt"}]. A "description" key is accepted for
|
|
104
|
+
compatibility but is not used by classification.
|
|
105
|
+
pdf_file: The document to classify: a PDF or an image (JPG, PNG, GIF, WebP, BMP, TIFF). Provide either
|
|
106
|
+
pdf_file or file_url, not both. Maximum file size: 500MB.
|
|
107
|
+
file_url: URL to a document to classify (PDF or image). Provide either pdf_file or file_url, not both.
|
|
108
|
+
request_options: Per-call overrides for this one request, such as a timeout or extra headers.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
Accepted - classification job started
|
|
112
|
+
|
|
113
|
+
Raises:
|
|
114
|
+
ApiError: Bad request, e.g. neither ``pdf_file`` nor ``file_url`` provided, or invalid schema. Missing or
|
|
115
|
+
invalid API key. Insufficient quota. Missing or malformed form fields. Rate limit exceeded. Service
|
|
116
|
+
unavailable. Either the job queue is full (``error.details.reason`` = ``queue_full``, ``Retry-After``
|
|
117
|
+
5-60 s) or the platform-wide capacity limit was hit (``Retry-After: 5``, no ``details``). ``error`` is
|
|
118
|
+
``DetailError | Classify402Error1 | ErrorEnvelope | RawError``."""
|
|
119
|
+
return (
|
|
120
|
+
await self._with_raw_response.classify_document(
|
|
121
|
+
categories, pdf_file=pdf_file, file_url=file_url, request_options=request_options
|
|
122
|
+
)
|
|
123
|
+
).unwrap()
|
|
124
|
+
|
|
125
|
+
async def get_classification_job_status(
|
|
126
|
+
self, job_id: str, *, request_options: RequestOptionsOrDict | None = None
|
|
127
|
+
) -> ClassifyResponse1:
|
|
128
|
+
"""Check the status and progress of classification jobs and retrieve results
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
job_id: The unique identifier of the classification job
|
|
132
|
+
request_options: Per-call overrides for this one request, such as a timeout or extra headers.
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
Classification job status retrieved successfully
|
|
136
|
+
|
|
137
|
+
Raises:
|
|
138
|
+
ApiError: Job not found. Service unavailable: platform-wide capacity limit reached. Retry after the
|
|
139
|
+
``Retry-After`` header (5 s). ``error`` is ``DetailError | ErrorEnvelope | RawError``."""
|
|
140
|
+
return (
|
|
141
|
+
await self._with_raw_response.get_classification_job_status(job_id, request_options=request_options)
|
|
142
|
+
).unwrap()
|
|
143
|
+
|
|
144
|
+
@property
|
|
145
|
+
def with_raw_response(self) -> AsyncClassifyWithRawResponse:
|
|
146
|
+
return self._with_raw_response
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class ClassifyWithRawResponse(SecuredRawResponse[RawClient, Server, AuthSchemes]):
|
|
150
|
+
def classify_document(
|
|
151
|
+
self,
|
|
152
|
+
categories: str,
|
|
153
|
+
*,
|
|
154
|
+
pdf_file: FileInput | None = None,
|
|
155
|
+
file_url: str | None = None,
|
|
156
|
+
request_options: RequestOptionsOrDict | None = None,
|
|
157
|
+
) -> ApiResult[ClassifyResponse, ClassifyDocumentErrorBody]:
|
|
158
|
+
"""Classify PDF and image documents into predefined categories
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
categories: JSON string containing an array of category objects with a required name. Example:
|
|
162
|
+
[{"name":"invoice"},{"name":"contract"},{"name":"receipt"}]. A "description" key is accepted for
|
|
163
|
+
compatibility but is not used by classification.
|
|
164
|
+
pdf_file: The document to classify: a PDF or an image (JPG, PNG, GIF, WebP, BMP, TIFF). Provide either
|
|
165
|
+
pdf_file or file_url, not both. Maximum file size: 500MB.
|
|
166
|
+
file_url: URL to a document to classify (PDF or image). Provide either pdf_file or file_url, not both.
|
|
167
|
+
request_options: Per-call overrides for this one request, such as a timeout or extra headers.
|
|
168
|
+
|
|
169
|
+
Returns:
|
|
170
|
+
An ``ApiResult`` holding the deserialized response or the error body."""
|
|
171
|
+
return self._client.execute(
|
|
172
|
+
http_method="POST",
|
|
173
|
+
url_template=self._server.default("/classify"),
|
|
174
|
+
headers=[param[UUID]("Idempotency-Key", uuid4())],
|
|
175
|
+
body=multipart_body(
|
|
176
|
+
param[str]("categories", categories),
|
|
177
|
+
file_part("pdf_file", pdf_file) if pdf_file is not None else None,
|
|
178
|
+
param[str | None]("file_url", file_url),
|
|
179
|
+
),
|
|
180
|
+
auth_scheme=self._auth.api_key_auth,
|
|
181
|
+
decoder=json_decoder[ClassifyResponse],
|
|
182
|
+
error_mapper=classify_document_error_mapper,
|
|
183
|
+
request_options=request_options,
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
def get_classification_job_status(
|
|
187
|
+
self, job_id: str, *, request_options: RequestOptionsOrDict | None = None
|
|
188
|
+
) -> ApiResult[ClassifyResponse1, GetClassificationJobStatusErrorBody]:
|
|
189
|
+
"""Check the status and progress of classification jobs and retrieve results
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
job_id: The unique identifier of the classification job
|
|
193
|
+
request_options: Per-call overrides for this one request, such as a timeout or extra headers.
|
|
194
|
+
|
|
195
|
+
Returns:
|
|
196
|
+
An ``ApiResult`` holding the deserialized response or the error body."""
|
|
197
|
+
return self._client.execute(
|
|
198
|
+
http_method="GET",
|
|
199
|
+
url_template=self._server.default("/classify/{job_id}"),
|
|
200
|
+
path_params=[param[str]("job_id", job_id)],
|
|
201
|
+
auth_scheme=self._auth.api_key_auth,
|
|
202
|
+
decoder=json_decoder[ClassifyResponse1],
|
|
203
|
+
error_mapper=get_classification_job_status_error_mapper,
|
|
204
|
+
request_options=request_options,
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class AsyncClassifyWithRawResponse(SecuredRawResponse[AsyncRawClient, Server, AsyncAuthSchemes]):
|
|
209
|
+
async def classify_document(
|
|
210
|
+
self,
|
|
211
|
+
categories: str,
|
|
212
|
+
*,
|
|
213
|
+
pdf_file: AsyncFileInput | None = None,
|
|
214
|
+
file_url: str | None = None,
|
|
215
|
+
request_options: RequestOptionsOrDict | None = None,
|
|
216
|
+
) -> ApiResult[ClassifyResponse, ClassifyDocumentErrorBody]:
|
|
217
|
+
"""Classify PDF and image documents into predefined categories
|
|
218
|
+
|
|
219
|
+
Args:
|
|
220
|
+
categories: JSON string containing an array of category objects with a required name. Example:
|
|
221
|
+
[{"name":"invoice"},{"name":"contract"},{"name":"receipt"}]. A "description" key is accepted for
|
|
222
|
+
compatibility but is not used by classification.
|
|
223
|
+
pdf_file: The document to classify: a PDF or an image (JPG, PNG, GIF, WebP, BMP, TIFF). Provide either
|
|
224
|
+
pdf_file or file_url, not both. Maximum file size: 500MB.
|
|
225
|
+
file_url: URL to a document to classify (PDF or image). Provide either pdf_file or file_url, not both.
|
|
226
|
+
request_options: Per-call overrides for this one request, such as a timeout or extra headers.
|
|
227
|
+
|
|
228
|
+
Returns:
|
|
229
|
+
An ``ApiResult`` holding the deserialized response or the error body."""
|
|
230
|
+
return await self._client.execute(
|
|
231
|
+
http_method="POST",
|
|
232
|
+
url_template=self._server.default("/classify"),
|
|
233
|
+
headers=[param[UUID]("Idempotency-Key", uuid4())],
|
|
234
|
+
body=multipart_body(
|
|
235
|
+
param[str]("categories", categories),
|
|
236
|
+
file_part("pdf_file", pdf_file) if pdf_file is not None else None,
|
|
237
|
+
param[str | None]("file_url", file_url),
|
|
238
|
+
),
|
|
239
|
+
auth_scheme=self._auth.api_key_auth,
|
|
240
|
+
decoder=json_decoder[ClassifyResponse],
|
|
241
|
+
error_mapper=classify_document_error_mapper,
|
|
242
|
+
request_options=request_options,
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
async def get_classification_job_status(
|
|
246
|
+
self, job_id: str, *, request_options: RequestOptionsOrDict | None = None
|
|
247
|
+
) -> ApiResult[ClassifyResponse1, GetClassificationJobStatusErrorBody]:
|
|
248
|
+
"""Check the status and progress of classification jobs and retrieve results
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
job_id: The unique identifier of the classification job
|
|
252
|
+
request_options: Per-call overrides for this one request, such as a timeout or extra headers.
|
|
253
|
+
|
|
254
|
+
Returns:
|
|
255
|
+
An ``ApiResult`` holding the deserialized response or the error body."""
|
|
256
|
+
return await self._client.execute(
|
|
257
|
+
http_method="GET",
|
|
258
|
+
url_template=self._server.default("/classify/{job_id}"),
|
|
259
|
+
path_params=[param[str]("job_id", job_id)],
|
|
260
|
+
auth_scheme=self._auth.api_key_auth,
|
|
261
|
+
decoder=json_decoder[ClassifyResponse1],
|
|
262
|
+
error_mapper=get_classification_job_status_error_mapper,
|
|
263
|
+
request_options=request_options,
|
|
264
|
+
)
|