22from typing import BinaryIO , Dict , Optional , Type
33
44from mindee .documents import (
5+ CropperV1 ,
56 CustomV1 ,
67 FinancialV1 ,
78 InvoiceV3 ,
@@ -53,19 +54,33 @@ def parse(
5354 include_words : bool = False ,
5455 close_file : bool = True ,
5556 page_options : Optional [PageOptions ] = None ,
57+ cropper : bool = False ,
5658 ) -> PredictResponse [TypeDocument ]:
5759 """
5860 Call prediction API on the document and parse the results.
5961
6062 :param document_class: The document class to use.
61- The response object will be instanced based on this parameter.
62- :param endpoint_name: For custom documents, the "API name" field
63- in the "Settings" page of the API Builder.
64- :param account_name: API username, the endpoint owner
65- :param include_words: Include all the words of the document in the response
63+ The response object will be instantiated based on this parameter.
64+
65+ :param endpoint_name: For custom endpoints, the "API name" field in the "Settings" page of the API Builder.
66+ Do not set for standard (off the shelf) endpoints.
67+
68+ :param account_name: For custom endpoints, your account or organization username on the API Builder.
69+ This is normally not required unless you have a custom endpoint which has the
70+ same name as standard (off the shelf) endpoint.
71+ Do not set for standard (off the shelf) endpoints.
72+
73+ :param include_words: Whether to include the full text for each page.
74+ This performs a full OCR operation on the server and will increase response time.
75+
6676 :param close_file: Whether to ``close()`` the file after parsing it.
6777 Set to ``False`` if you need to access the file after this operation.
68- :param page_options: Options for preparing multipage documents.
78+
79+ :param page_options: If set, remove pages from the document as specified.
80+ This is done before sending the file to the server and is useful to avoid page limitations.
81+
82+ :param cropper: Whether to include cropper results for each page.
83+ This performs a cropping operation on the server and will increase response time.
6984 """
7085 bound_classname = get_bound_classname (document_class )
7186 if bound_classname != CustomV1 .__name__ :
@@ -108,14 +123,17 @@ def parse(
108123 page_options .on_min_pages ,
109124 page_options .page_indexes ,
110125 )
111- return self ._make_request (document_class , doc_config , include_words , close_file )
126+ return self ._make_request (
127+ document_class , doc_config , include_words , close_file , cropper
128+ )
112129
113130 def _make_request (
114131 self ,
115132 document_class : TypeDocument ,
116133 doc_config : DocumentConfig ,
117134 include_words : bool ,
118135 close_file : bool ,
136+ cropper : bool ,
119137 ) -> PredictResponse [TypeDocument ]:
120138 if get_bound_classname (document_class ) != doc_config .document_class .__name__ :
121139 raise RuntimeError ("Document class mismatch!" )
@@ -125,6 +143,7 @@ def _make_request(
125143 self .input_doc ,
126144 include_words = include_words ,
127145 close_file = close_file ,
146+ cropper = cropper ,
128147 )
129148
130149 dict_response = response .json ()
@@ -228,6 +247,15 @@ def _init_default_endpoints(self) -> None:
228247 )
229248 ],
230249 ),
250+ (OTS_OWNER , CropperV1 .__name__ ): DocumentConfig (
251+ document_type = "cropper_v1" ,
252+ document_class = CropperV1 ,
253+ endpoints = [
254+ StandardEndpoint (
255+ url_name = "cropper" , version = "1" , api_key = self .api_key
256+ )
257+ ],
258+ ),
231259 }
232260
233261 def add_endpoint (
0 commit comments