retab 0.0.70__py3-none-any.whl → 0.0.71__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.
- retab/resources/documents/client.py +16 -0
- retab/types/documents/extract.py +1 -0
- {retab-0.0.70.dist-info → retab-0.0.71.dist-info}/METADATA +1 -1
- {retab-0.0.70.dist-info → retab-0.0.71.dist-info}/RECORD +6 -6
- {retab-0.0.70.dist-info → retab-0.0.71.dist-info}/WHEEL +0 -0
- {retab-0.0.70.dist-info → retab-0.0.71.dist-info}/top_level.txt +0 -0
|
@@ -12,6 +12,7 @@ from ..._resource import AsyncAPIResource, SyncAPIResource
|
|
|
12
12
|
from ...utils.mime import prepare_mime_document
|
|
13
13
|
from ...utils.stream_context_managers import as_async_context_manager, as_context_manager
|
|
14
14
|
from ...types.documents.create_messages import DocumentCreateInputRequest, DocumentCreateMessageRequest, DocumentMessage
|
|
15
|
+
from ...types.chat import ChatCompletionRetabMessage
|
|
15
16
|
from ...types.documents.extract import DocumentExtractRequest, RetabParsedChatCompletion, RetabParsedChatCompletionChunk, RetabParsedChoice, maybe_parse_to_pydantic
|
|
16
17
|
from ...types.documents.parse import ParseRequest, ParseResult, TableParsingFormat
|
|
17
18
|
from ...types.mime import MIMEData
|
|
@@ -125,6 +126,7 @@ class BaseDocumentsMixin:
|
|
|
125
126
|
stream: bool = FieldUnset,
|
|
126
127
|
store: bool = FieldUnset,
|
|
127
128
|
metadata: dict[str, str] = FieldUnset,
|
|
129
|
+
additional_messages: list[ChatCompletionRetabMessage] = FieldUnset,
|
|
128
130
|
**extra_body: Any,
|
|
129
131
|
) -> PreparedRequest:
|
|
130
132
|
loaded_schema = load_json_schema(json_schema)
|
|
@@ -155,6 +157,8 @@ class BaseDocumentsMixin:
|
|
|
155
157
|
request_dict["image_resolution_dpi"] = image_resolution_dpi
|
|
156
158
|
if metadata is not FieldUnset:
|
|
157
159
|
request_dict["metadata"] = metadata
|
|
160
|
+
if additional_messages is not FieldUnset:
|
|
161
|
+
request_dict["additional_messages"] = additional_messages
|
|
158
162
|
|
|
159
163
|
# Merge any extra fields provided by the caller
|
|
160
164
|
if extra_body:
|
|
@@ -240,6 +244,7 @@ class Documents(SyncAPIResource, BaseDocumentsMixin):
|
|
|
240
244
|
n_consensus: int = FieldUnset,
|
|
241
245
|
store: bool = FieldUnset,
|
|
242
246
|
metadata: dict[str, str] = FieldUnset,
|
|
247
|
+
additional_messages: list[ChatCompletionRetabMessage] = FieldUnset,
|
|
243
248
|
**extra_body: Any,
|
|
244
249
|
) -> RetabParsedChatCompletion:
|
|
245
250
|
"""
|
|
@@ -257,6 +262,7 @@ class Documents(SyncAPIResource, BaseDocumentsMixin):
|
|
|
257
262
|
n_consensus: Number of consensus extractions to perform
|
|
258
263
|
store: Whether to store the document in the Retab database
|
|
259
264
|
metadata: User-defined metadata to associate with this extraction
|
|
265
|
+
additional_messages: Additional chat messages to append after the document content messages
|
|
260
266
|
|
|
261
267
|
Returns:
|
|
262
268
|
RetabParsedChatCompletion: Parsed response from the API
|
|
@@ -275,6 +281,7 @@ class Documents(SyncAPIResource, BaseDocumentsMixin):
|
|
|
275
281
|
n_consensus=n_consensus,
|
|
276
282
|
store=store,
|
|
277
283
|
metadata=metadata,
|
|
284
|
+
additional_messages=additional_messages,
|
|
278
285
|
**extra_body,
|
|
279
286
|
)
|
|
280
287
|
response = self._client._prepared_request(request)
|
|
@@ -381,6 +388,7 @@ class Documents(SyncAPIResource, BaseDocumentsMixin):
|
|
|
381
388
|
n_consensus: int = FieldUnset,
|
|
382
389
|
store: bool = FieldUnset,
|
|
383
390
|
metadata: dict[str, str] = FieldUnset,
|
|
391
|
+
additional_messages: list[ChatCompletionRetabMessage] = FieldUnset,
|
|
384
392
|
**extra_body: Any,
|
|
385
393
|
) -> Generator[RetabParsedChatCompletion, None, None]:
|
|
386
394
|
"""
|
|
@@ -396,6 +404,7 @@ class Documents(SyncAPIResource, BaseDocumentsMixin):
|
|
|
396
404
|
n_consensus: Number of consensus extractions to perform (default: 1 which computes a single extraction and the likelihoods comes from the model logprobs)
|
|
397
405
|
store: Whether to store the document in the Retab database
|
|
398
406
|
metadata: User-defined metadata to associate with this extraction
|
|
407
|
+
additional_messages: Additional chat messages to append after the document content messages
|
|
399
408
|
|
|
400
409
|
Returns:
|
|
401
410
|
Generator[RetabParsedChatCompletion]: Stream of parsed responses
|
|
@@ -420,6 +429,7 @@ class Documents(SyncAPIResource, BaseDocumentsMixin):
|
|
|
420
429
|
n_consensus=n_consensus,
|
|
421
430
|
store=store,
|
|
422
431
|
metadata=metadata,
|
|
432
|
+
additional_messages=additional_messages,
|
|
423
433
|
**extra_body,
|
|
424
434
|
)
|
|
425
435
|
schema = load_json_schema(json_schema)
|
|
@@ -572,6 +582,7 @@ class AsyncDocuments(AsyncAPIResource, BaseDocumentsMixin):
|
|
|
572
582
|
n_consensus: int = FieldUnset,
|
|
573
583
|
store: bool = FieldUnset,
|
|
574
584
|
metadata: dict[str, str] = FieldUnset,
|
|
585
|
+
additional_messages: list[ChatCompletionRetabMessage] = FieldUnset,
|
|
575
586
|
**extra_body: Any,
|
|
576
587
|
) -> RetabParsedChatCompletion:
|
|
577
588
|
"""
|
|
@@ -589,6 +600,7 @@ class AsyncDocuments(AsyncAPIResource, BaseDocumentsMixin):
|
|
|
589
600
|
n_consensus: Number of consensus extractions to perform
|
|
590
601
|
store: Whether to store the document in the Retab database
|
|
591
602
|
metadata: User-defined metadata to associate with this extraction
|
|
603
|
+
additional_messages: Additional chat messages to append after the document content messages
|
|
592
604
|
|
|
593
605
|
Returns:
|
|
594
606
|
RetabParsedChatCompletion: Parsed response from the API
|
|
@@ -607,6 +619,7 @@ class AsyncDocuments(AsyncAPIResource, BaseDocumentsMixin):
|
|
|
607
619
|
n_consensus=n_consensus,
|
|
608
620
|
store=store,
|
|
609
621
|
metadata=metadata,
|
|
622
|
+
additional_messages=additional_messages,
|
|
610
623
|
**extra_body,
|
|
611
624
|
)
|
|
612
625
|
response = await self._client._prepared_request(request)
|
|
@@ -625,6 +638,7 @@ class AsyncDocuments(AsyncAPIResource, BaseDocumentsMixin):
|
|
|
625
638
|
n_consensus: int = FieldUnset,
|
|
626
639
|
store: bool = FieldUnset,
|
|
627
640
|
metadata: dict[str, str] = FieldUnset,
|
|
641
|
+
additional_messages: list[ChatCompletionRetabMessage] = FieldUnset,
|
|
628
642
|
**extra_body: Any,
|
|
629
643
|
) -> AsyncGenerator[RetabParsedChatCompletion, None]:
|
|
630
644
|
"""
|
|
@@ -640,6 +654,7 @@ class AsyncDocuments(AsyncAPIResource, BaseDocumentsMixin):
|
|
|
640
654
|
n_consensus: Number of consensus extractions to perform (default: 1 which computes a single extraction and the likelihoods comes from the model logprobs)
|
|
641
655
|
store: Whether to store the document in the Retab database
|
|
642
656
|
metadata: User-defined metadata to associate with this extraction
|
|
657
|
+
additional_messages: Additional chat messages to append after the document content messages
|
|
643
658
|
Returns:
|
|
644
659
|
AsyncGenerator[RetabParsedChatCompletion, None]: Stream of parsed responses.
|
|
645
660
|
Raises:
|
|
@@ -663,6 +678,7 @@ class AsyncDocuments(AsyncAPIResource, BaseDocumentsMixin):
|
|
|
663
678
|
n_consensus=n_consensus,
|
|
664
679
|
store=store,
|
|
665
680
|
metadata=metadata,
|
|
681
|
+
additional_messages=additional_messages,
|
|
666
682
|
**extra_body,
|
|
667
683
|
)
|
|
668
684
|
schema = load_json_schema(json_schema)
|
retab/types/documents/extract.py
CHANGED
|
@@ -39,6 +39,7 @@ class DocumentExtractRequest(BaseModel):
|
|
|
39
39
|
parallel_ocr_keys: Optional[dict[str, str]] = Field(default=None, description="If set, keys to be used for the extraction of long lists of data using Parallel OCR", examples=[{"properties": "ID", "products": "identity.id"}])
|
|
40
40
|
metadata: dict[str, str] = Field(default_factory=dict, description="User-defined metadata to associate with this extraction")
|
|
41
41
|
extraction_id: Optional[str] = Field(default=None, description="Extraction ID to use for this extraction. If not provided, a new ID will be generated.")
|
|
42
|
+
additional_messages: Optional[list[ChatCompletionRetabMessage]] = Field(default=None, description="Additional chat messages to append after the document content messages. Useful for providing extra context or instructions.")
|
|
42
43
|
|
|
43
44
|
# Add a model validator that rejects n_consensus > 1 if temperature is 0
|
|
44
45
|
@field_validator("n_consensus")
|
|
@@ -7,7 +7,7 @@ retab/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
7
7
|
retab/resources/models.py,sha256=4WidFBnTGZEA65DSn2pLP2SRnCVXkMTw7o_m8xVCFC4,2469
|
|
8
8
|
retab/resources/schemas.py,sha256=rZ6OzfmoYv-mGaRVzvXjO09dD-KxP74mZhOO8sMgcDQ,4632
|
|
9
9
|
retab/resources/documents/__init__.py,sha256=OjXmngFN0RKqO4SI-mJBNzr6Ex6rMxfq0DxaqzP0RQs,89
|
|
10
|
-
retab/resources/documents/client.py,sha256=
|
|
10
|
+
retab/resources/documents/client.py,sha256=8WT0-PwfrCgUaA6Pj2_VTDQ66zRTDexDxj9koMG0Ygo,33161
|
|
11
11
|
retab/resources/extractions/__init__.py,sha256=2H1ezUG8hI5SmTRy6NFzXdYLOdGFFsFrI60uzkitV20,97
|
|
12
12
|
retab/resources/extractions/client.py,sha256=sEoNjOgX91FTOgoJUV-I1A9A9xl1ciCdPlhYwjhEjbA,11035
|
|
13
13
|
retab/resources/projects/__init__.py,sha256=tPR3_3tr7bsoYd618qmGjnYN2R23PmF5oCFd7Z5_HGY,85
|
|
@@ -22,7 +22,7 @@ retab/types/standards.py,sha256=7aGtuvzzkKidvqY8JB2Cjfn43V80FeKwrTtp162kjKc,1477
|
|
|
22
22
|
retab/types/documents/__init__.py,sha256=RaD6PnvRJw7QEVTh_PYNX6gckpLcxUJH7FKaopRKJzY,114
|
|
23
23
|
retab/types/documents/correct_orientation.py,sha256=e-ivsslI6L6Gl0YkcslXw_DH620xMGEYVp4tdeviXeM,261
|
|
24
24
|
retab/types/documents/create_messages.py,sha256=Cox0QgIyLhTXIvw1Nzd2BCnB9-5KAYgw_gads5eTaDw,7272
|
|
25
|
-
retab/types/documents/extract.py,sha256=
|
|
25
|
+
retab/types/documents/extract.py,sha256=tc6SJSbHcZlDdKv67AdV2w5v-veXqze9ztFOorPkLVU,16721
|
|
26
26
|
retab/types/documents/parse.py,sha256=Jd6i-1UXhAtgntRBZItEHGHeevyLdLmbTQa1-HNrico,1305
|
|
27
27
|
retab/types/extractions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
28
|
retab/types/extractions/types.py,sha256=mnCYSfJoEKsXN2eG-PrahnnQyR6RDjP5VO9sHC1Opmg,102
|
|
@@ -44,7 +44,7 @@ retab/utils/mime.py,sha256=mTP_lqSPttOP5DYJxopiWaeFXrUCPjhwd7y53nCVGO4,6189
|
|
|
44
44
|
retab/utils/stream_context_managers.py,sha256=gI1gVQSj3nWz6Mvjz7Ix5AiY0g6vSL-c2tPfuP04izo,2314
|
|
45
45
|
retab/utils/usage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
46
46
|
retab/utils/usage/json_schema.py,sha256=kRbL5E5OStlhlNlBXlxHNwaVHKd6MVhyqIb0y4aj8JA,84322
|
|
47
|
-
retab-0.0.
|
|
48
|
-
retab-0.0.
|
|
49
|
-
retab-0.0.
|
|
50
|
-
retab-0.0.
|
|
47
|
+
retab-0.0.71.dist-info/METADATA,sha256=85N0ECgTable-tLM2gHI6ZQV3Qp4XQSY14J1atXcOJY,4532
|
|
48
|
+
retab-0.0.71.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
49
|
+
retab-0.0.71.dist-info/top_level.txt,sha256=waQR0EGdhLIQtztoE3AXg7ik5ONQ9q_bsKVpyFuJdq0,6
|
|
50
|
+
retab-0.0.71.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|