retab 0.0.66__py3-none-any.whl → 0.0.68__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: retab
3
- Version: 0.0.66
3
+ Version: 0.0.68
4
4
  Summary: Retab official python library
5
5
  Home-page: https://github.com/retab-dev/retab
6
6
  Author: Retab
@@ -29,6 +29,8 @@ Requires-Dist: email_validator
29
29
  Requires-Dist: python-stdnum
30
30
  Requires-Dist: nanoid
31
31
  Requires-Dist: openai
32
+ Requires-Dist: anthropic
33
+ Requires-Dist: google-genai
32
34
  Requires-Dist: tiktoken
33
35
  Requires-Dist: truststore
34
36
  Dynamic: author
@@ -1,8 +1,8 @@
1
- retab/__init__.py,sha256=CfWHrp7ci-WqA6dZXzP7gFkpXAVro4nxeCOiCV83BIc,130
1
+ retab/__init__.py,sha256=s4GawWTRBYz4VY-CyAV5-ZdFtdw8V5oopGIYm9GgdSo,188
2
2
  retab/_resource.py,sha256=JfAU4UTa05ugWfbrpO7fsVr_pFewht99NkoIfK6kBQM,577
3
3
  retab/client copy.py,sha256=RqKYBvLB8Bp6QpS3DodOXffWQFdr36bobQRSU09vES0,27883
4
- retab/client.py,sha256=JisT6NGHgPEEOqIPygeC_tR0wNfZM_xq1sRzhbaW8Nw,27031
5
- retab/generate_types.py,sha256=Yj0ZgYftTYWQeX-RPW02ROfvanymDOpLpi_P1AVYOLA,8365
4
+ retab/client.py,sha256=wOiTAzGw6Hi7FVbrs-TwSuPR6tmgOLMYjY1eBgrgBBk,29929
5
+ retab/generate_types.py,sha256=cUu1IX65uU__MHivmEb_PZtzAi8DYsvppZvcY30hj90,8425
6
6
  retab/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  retab/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  retab/resources/models.py,sha256=4WidFBnTGZEA65DSn2pLP2SRnCVXkMTw7o_m8xVCFC4,2469
@@ -10,14 +10,12 @@ retab/resources/schemas.py,sha256=qWkOAZrimtbTHzhDof3z4PG72F7MIPrb3A495f6mrHE,50
10
10
  retab/resources/documents/__init__.py,sha256=OjXmngFN0RKqO4SI-mJBNzr6Ex6rMxfq0DxaqzP0RQs,89
11
11
  retab/resources/documents/client.py,sha256=7-BaveXUlwZqtMTvM3dNiltZS83jJVXDRuyfFMg_eGw,37446
12
12
  retab/resources/projects/__init__.py,sha256=tPR3_3tr7bsoYd618qmGjnYN2R23PmF5oCFd7Z5_HGY,85
13
- retab/resources/projects/client.py,sha256=8MygpRCBWqK5IXEKr3vvdLZhs2Quy4MUuPx78m-sgcI,15945
14
- retab/resources/projects/documents.py,sha256=pUgANQbfm1W-iXsa_4ffRAr3kVNt7KAy8AKb09IMH2w,10098
15
- retab/resources/projects/iterations.py,sha256=I5caQgotAGFijojr6KzOE3NWC8CTIwUSOzN2aivTnX4,16945
13
+ retab/resources/projects/client.py,sha256=-T5iSRp-jODNVg-cgQiQ3S6D53cwCTwNQsI0Rr9vqsU,14654
16
14
  retab/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
15
  retab/types/browser_canvas.py,sha256=LdW1SnaWb4WdFgFBCo8p9k78K2fmzV5YtloQtIR7hk0,82
18
16
  retab/types/chat.py,sha256=x9VbtPMa4w6Gc0HrFC3ILl6cCnfEn5ytDnwJtZmlcys,1436
19
17
  retab/types/inference_settings.py,sha256=co0C5ynGm7z7Bvi7gP3CFwhkRJUd-bMNBVbavFu7Iuo,939
20
- retab/types/mime.py,sha256=6TytTxtimrTCRutCFDMEnwFoV4EOQlwNASLefmmfbNo,10998
18
+ retab/types/mime.py,sha256=1k3REXEVJ4dlFErs27Xx05sIWHWr3KjLzuKSDXEMNQQ,11973
21
19
  retab/types/modality.py,sha256=4B8LctdUBZVgIjtS2FjrJpljn2Eyse0XE1bpFsGb9O4,131
22
20
  retab/types/pagination.py,sha256=-XrKILKX_5isTHTfShLiK3Kwp21Y6Wqy0Jci8lIFQig,109
23
21
  retab/types/standards.py,sha256=7aGtuvzzkKidvqY8JB2Cjfn43V80FeKwrTtp162kjKc,1477
@@ -26,19 +24,15 @@ retab/types/documents/correct_orientation.py,sha256=e-ivsslI6L6Gl0YkcslXw_DH620x
26
24
  retab/types/documents/create_messages.py,sha256=fibThBlJg1iKQfVkvIVL1QqZxrraIl9qeO0lJHLo_nQ,7509
27
25
  retab/types/documents/extract.py,sha256=KeEDnbvXTtgamrGvpBINsg5MJAue-Xf_lNi1a71M7oE,20067
28
26
  retab/types/documents/parse.py,sha256=ekXnjnFEx7adZ8dJKivo5QRtYnKBEUFzJiIM9WY-LPY,1454
29
- retab/types/projects/Untitled-2.py,sha256=bKFsPNfY6RloyZ1A1tX-3pOzvZ2OY_S-wle43BuAn98,1205610
30
- retab/types/projects/__init__.py,sha256=oIOBN_6-bpFxeZpvyPdXP-LHDNERreSS7TvjdNkVmIA,920
31
- retab/types/projects/documents.py,sha256=0N9HJIghObrHX6GWgFP4w7VlvCaYZqBnExH2ULRLo8I,2029
32
- retab/types/projects/iterations.py,sha256=2V4WFrLcuQklCuMx0rD0LUtYTZOvCaCnTnu2O5MH3QU,5782
27
+ retab/types/projects/__init__.py,sha256=I7P_dems5_LOLgYQ-4Bzt9B6P6jRlQwP-D_9GxRDhVk,155
33
28
  retab/types/projects/metrics.py,sha256=J8aZdVbqlszfxosAZyTB7l6lp9WgdL5QgLMlLrckN7k,1946
34
- retab/types/projects/model.py,sha256=Lwn1KUzjBZl-kqugWRcmcUbEoRPxnH0Mn4ycrEJ-7i4,2380
29
+ retab/types/projects/model.py,sha256=0He-lMiT4jX1SwukNowq41LFPeozWDnTVsbjlmCNWJw,4374
35
30
  retab/types/projects/predictions.py,sha256=GeQX-nCmbzKL50aaSFlSyn0sgnbzKserPK6DSQT8ACk,1114
36
- retab/types/projects/v2.py,sha256=8fNV5lH4Zn5D97AQK5pZVLjYFi-2MSBN9Su2eNoGVpM,6610
37
31
  retab/types/schemas/__init__.py,sha256=9ODWiC_4pUVKxoIKglYZjvRjRyd1ZCVxG8GBdQgHNbU,57
38
- retab/types/schemas/chat.py,sha256=U-zYbHtJ6HHxU2t56sfLkhLttoJpng0mjVN2tlccnig,21225
32
+ retab/types/schemas/chat.py,sha256=ppTidxsNslTKE5aBva04i9IxeARMqYpXYLjtR7V6pBc,21219
39
33
  retab/types/schemas/generate.py,sha256=DN4pMJihoADyAZgA2RW7BddFzhbNOoaEnfEjjjUyMKM,1007
40
34
  retab/types/schemas/layout.py,sha256=JLPwQGIWfPBoe1Y5r-MhiNDJigzZ-yKZnVGgox0uqMk,1487
41
- retab/types/schemas/model.py,sha256=lOaSEabXQUDJO7bQc_c4fDZp2o86zbJSRF2QfINM02s,69594
35
+ retab/types/schemas/model.py,sha256=MwiSrck_5NCDvxjDSqgiDtmenGowXnfoOZ7KTINKW34,69588
42
36
  retab/types/schemas/templates.py,sha256=XihWTHi6t_6QjxN07n_1dee5KdhHiuoHAYfmKwI7gQg,1708
43
37
  retab/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
38
  retab/utils/display.py,sha256=ZFPbiBnwEWGR-suS8e9Xilz9OqyYRDwsKYWfbFSJPJM,18868
@@ -48,7 +42,7 @@ retab/utils/mime.py,sha256=mTP_lqSPttOP5DYJxopiWaeFXrUCPjhwd7y53nCVGO4,6189
48
42
  retab/utils/stream_context_managers.py,sha256=gI1gVQSj3nWz6Mvjz7Ix5AiY0g6vSL-c2tPfuP04izo,2314
49
43
  retab/utils/usage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
44
  retab/utils/usage/json_schema.py,sha256=kRbL5E5OStlhlNlBXlxHNwaVHKd6MVhyqIb0y4aj8JA,84322
51
- retab-0.0.66.dist-info/METADATA,sha256=vGQMlgjUh8uANjfSUz041GSKUV00pmAjtjdXvqbeQ8A,4479
52
- retab-0.0.66.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
53
- retab-0.0.66.dist-info/top_level.txt,sha256=waQR0EGdhLIQtztoE3AXg7ik5ONQ9q_bsKVpyFuJdq0,6
54
- retab-0.0.66.dist-info/RECORD,,
45
+ retab-0.0.68.dist-info/METADATA,sha256=ZqKChL45ZWbRxN1B7QMPk-VWdz0qKezYOQOgPRhDFc0,4532
46
+ retab-0.0.68.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
47
+ retab-0.0.68.dist-info/top_level.txt,sha256=waQR0EGdhLIQtztoE3AXg7ik5ONQ9q_bsKVpyFuJdq0,6
48
+ retab-0.0.68.dist-info/RECORD,,
@@ -1,257 +0,0 @@
1
- from io import IOBase
2
- from pathlib import Path
3
- from typing import Any, Dict, List, Union
4
-
5
- import PIL.Image
6
- from pydantic import HttpUrl
7
-
8
- from ..._resource import AsyncAPIResource, SyncAPIResource
9
- from ...utils.mime import prepare_mime_document
10
- from ...types.projects import DocumentItem, ProjectDocument, PatchProjectDocumentRequest
11
- from ...types.projects.predictions import PredictionMetadata
12
- from ...types.mime import MIMEData
13
- from ...types.standards import PreparedRequest, DeleteResponse
14
- from ...types.documents.extract import RetabParsedChatCompletion
15
-
16
-
17
- class DocumentsMixin:
18
- def prepare_get(self, project_id: str, document_id: str) -> PreparedRequest:
19
- return PreparedRequest(method="GET", url=f"/v1/projects/{project_id}/documents/{document_id}")
20
-
21
- def prepare_create(self, project_id: str, document: MIMEData, annotation: dict[str, Any], annotation_metadata: dict[str, Any] | None = None, **extra_body: Any) -> PreparedRequest:
22
- # Serialize the MIMEData
23
- # Build known payload and merge extras
24
- payload: dict[str, Any] = {
25
- "mime_data": document,
26
- "annotation": annotation,
27
- "annotation_metadata": PredictionMetadata(**annotation_metadata) if annotation_metadata else None,
28
- }
29
- if extra_body:
30
- payload.update(extra_body)
31
- document_item = DocumentItem(**payload)
32
- return PreparedRequest(method="POST", url=f"/v1/projects/{project_id}/documents", data=document_item.model_dump(mode="json"))
33
-
34
- def prepare_list(self, project_id: str) -> PreparedRequest:
35
- return PreparedRequest(method="GET", url=f"/v1/projects/{project_id}/documents")
36
-
37
- def prepare_update(self, project_id: str, document_id: str, annotation: dict[str, Any], **extra_body: Any) -> PreparedRequest:
38
- body: dict[str, Any] = {"annotation": annotation}
39
- if extra_body:
40
- body.update(extra_body)
41
- update_request = PatchProjectDocumentRequest(**body)
42
- return PreparedRequest(method="PATCH", url=f"/v1/projects/{project_id}/documents/{document_id}", data=update_request.model_dump(mode="json", exclude_unset=True))
43
-
44
- def prepare_delete(self, project_id: str, document_id: str) -> PreparedRequest:
45
- return PreparedRequest(method="DELETE", url=f"/v1/projects/{project_id}/documents/{document_id}")
46
-
47
- def prepare_llm_annotate(self, project_id: str, document_id: str) -> PreparedRequest:
48
- return PreparedRequest(method="POST", url=f"/v1/projects/{project_id}/documents/{document_id}/llm-annotate", data={"stream": False})
49
-
50
-
51
- class Documents(SyncAPIResource, DocumentsMixin):
52
- """Documents API wrapper for projects"""
53
-
54
- def create(
55
- self,
56
- project_id: str,
57
- document: Union[Path, str, IOBase, MIMEData, PIL.Image.Image, HttpUrl],
58
- annotation: Dict[str, Any],
59
- annotation_metadata: Dict[str, Any] | None = None,
60
- **extra_body: Any,
61
- ) -> ProjectDocument:
62
- """
63
- Create a document for an project.
64
-
65
- Args:
66
- project_id: The ID of the project
67
- document: The document to process. Can be:
68
- - A file path (Path or str)
69
- - A file-like object (IOBase)
70
- - A MIMEData object
71
- - A PIL Image object
72
- - A URL (HttpUrl)
73
- annotation: The ground truth for the document
74
-
75
- Returns:
76
- ProjectDocument: The created document
77
- Raises:
78
- HTTPException if the request fails
79
- """
80
- # Convert document to MIME data format
81
- mime_document: MIMEData = prepare_mime_document(document)
82
-
83
- # Let prepare_create handle the serialization
84
- request = self.prepare_create(project_id, mime_document, annotation, annotation_metadata, **extra_body)
85
- response = self._client._prepared_request(request)
86
- return ProjectDocument(**response)
87
-
88
- def list(self, project_id: str) -> List[ProjectDocument]:
89
- """
90
- List documents for an project.
91
-
92
- Args:
93
- project_id: The ID of the project
94
-
95
- Returns:
96
- List[ProjectDocument]: List of documents
97
- Raises:
98
- HTTPException if the request fails
99
- """
100
- request = self.prepare_list(project_id)
101
- response = self._client._prepared_request(request)
102
- return [ProjectDocument(**item) for item in response.get("data", [])]
103
-
104
- def get(self, project_id: str, document_id: str) -> ProjectDocument:
105
- """
106
- Get a document by ID.
107
-
108
- Args:
109
- project_id: The ID of the project
110
- document_id: The ID of the document
111
-
112
- Returns:
113
- ProjectDocument: The document
114
- Raises:
115
- HTTPException if the request fails
116
- """
117
- request = self.prepare_get(project_id, document_id)
118
- response = self._client._prepared_request(request)
119
- return ProjectDocument(**response)
120
-
121
- def update(self, project_id: str, document_id: str, annotation: dict[str, Any], **extra_body: Any) -> ProjectDocument:
122
- """
123
- Update a document.
124
-
125
- Args:
126
- project_id: The ID of the project
127
- document_id: The ID of the document
128
- annotation: The ground truth for the document
129
- Returns:
130
- ProjectDocument: The updated document
131
- Raises:
132
- HTTPException if the request fails
133
- """
134
- request = self.prepare_update(project_id, document_id, annotation=annotation, **extra_body)
135
- response = self._client._prepared_request(request)
136
- return ProjectDocument(**response)
137
-
138
- def delete(self, project_id: str, document_id: str) -> DeleteResponse:
139
- """
140
- Delete a document.
141
-
142
- Args:
143
- project_id: The ID of the project
144
- document_id: The ID of the document
145
-
146
- Returns:
147
- DeleteResponse: The response containing success status and ID
148
- Raises:
149
- HTTPException if the request fails
150
- """
151
- request = self.prepare_delete(project_id, document_id)
152
- return self._client._prepared_request(request)
153
-
154
- def llm_annotate(self, project_id: str, document_id: str) -> RetabParsedChatCompletion:
155
- """
156
- Annotate a document with an LLM. This method updates the document (within the project) with the latest extraction.
157
- """
158
- request = self.prepare_llm_annotate(project_id, document_id)
159
- response = self._client._prepared_request(request)
160
- return RetabParsedChatCompletion(**response)
161
-
162
-
163
- class AsyncDocuments(AsyncAPIResource, DocumentsMixin):
164
- """Async Documents API wrapper for projects"""
165
-
166
- async def create(
167
- self,
168
- project_id: str,
169
- document: Union[Path, str, IOBase, MIMEData, PIL.Image.Image, HttpUrl],
170
- annotation: Dict[str, Any],
171
- annotation_metadata: Dict[str, Any] | None = None,
172
- **extra_body: Any,
173
- ) -> ProjectDocument:
174
- """
175
- Create a document for an project.
176
-
177
- Args:
178
- project_id: The ID of the project
179
- document: The document to process. Can be:
180
- - A file path (Path or str)
181
- - A file-like object (IOBase)
182
- - A MIMEData object
183
- - A PIL Image object
184
- - A URL (HttpUrl)
185
- annotation: The ground truth for the document
186
- annotation_metadata: The metadata of the annotation
187
- Returns:
188
- ProjectDocument: The created document
189
- Raises:
190
- HTTPException if the request fails
191
- """
192
- # Convert document to MIME data format
193
- mime_document: MIMEData = prepare_mime_document(document)
194
-
195
- # Let prepare_create handle the serialization
196
- request = self.prepare_create(project_id, mime_document, annotation, annotation_metadata, **extra_body)
197
- response = await self._client._prepared_request(request)
198
- return ProjectDocument(**response)
199
-
200
- async def list(self, project_id: str) -> List[ProjectDocument]:
201
- """
202
- List documents for an project.
203
-
204
- Args:
205
- project_id: The ID of the project
206
-
207
- Returns:
208
- List[ProjectDocument]: List of documents
209
- Raises:
210
- HTTPException if the request fails
211
- """
212
- request = self.prepare_list(project_id)
213
- response = await self._client._prepared_request(request)
214
- return [ProjectDocument(**item) for item in response.get("data", [])]
215
-
216
- async def update(self, project_id: str, document_id: str, annotation: dict[str, Any], **extra_body: Any) -> ProjectDocument:
217
- """
218
- Update a document.
219
-
220
- Args:
221
- project_id: The ID of the project
222
- document_id: The ID of the document
223
- annotation: The ground truth for the document
224
-
225
- Returns:
226
- ProjectDocument: The updated document
227
- Raises:
228
- HTTPException if the request fails
229
- """
230
- request = self.prepare_update(project_id, document_id, annotation, **extra_body)
231
- response = await self._client._prepared_request(request)
232
- return ProjectDocument(**response)
233
-
234
- async def delete(self, project_id: str, document_id: str) -> DeleteResponse:
235
- """
236
- Delete a document.
237
-
238
- Args:
239
- project_id: The ID of the project
240
- document_id: The ID of the document
241
-
242
- Returns:
243
- DeleteResponse: The response containing success status and ID
244
- Raises:
245
- HTTPException if the request fails
246
- """
247
- request = self.prepare_delete(project_id, document_id)
248
- return await self._client._prepared_request(request)
249
-
250
- async def llm_annotate(self, project_id: str, document_id: str) -> RetabParsedChatCompletion:
251
- """
252
- Annotate a document with an LLM.
253
- This method updates the document (within the project) with the latest extraction.
254
- """
255
- request = self.prepare_llm_annotate(project_id, document_id)
256
- response = await self._client._prepared_request(request)
257
- return RetabParsedChatCompletion(**response)