retab 0.0.70__py3-none-any.whl → 0.0.72__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.
@@ -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)
@@ -74,9 +74,9 @@ class ProjectsMixin:
74
74
  def prepare_delete(self, id: str) -> PreparedRequest:
75
75
  return PreparedRequest(method="DELETE", url=f"/v1/projects/{id}")
76
76
 
77
- def prepare_publish(self, project_id: str, **extra_body: Any) -> PreparedRequest:
78
- data = extra_body or None
79
- return PreparedRequest(method="POST", url=f"/v1/projects/{project_id}/publish", data=data)
77
+ def prepare_publish(self, project_id: str, origin: Optional[str] = None) -> PreparedRequest:
78
+ params = {"origin": origin} if origin else None
79
+ return PreparedRequest(method="POST", url=f"/v1/projects/{project_id}/publish", params=params)
80
80
 
81
81
  def prepare_extract(
82
82
  self,
@@ -234,9 +234,15 @@ class Projects(SyncAPIResource, ProjectsMixin):
234
234
  request = self.prepare_delete(project_id)
235
235
  return self._client._prepared_request(request)
236
236
 
237
- def publish(self, project_id: str, **extra_body: Any) -> Project:
238
- """Publish a project's draft configuration."""
239
- request = self.prepare_publish(project_id, **extra_body)
237
+ def publish(self, project_id: str, origin: Optional[str] = None) -> Project:
238
+ """Publish a project's draft configuration.
239
+
240
+ Args:
241
+ project_id: The ID of the project to publish
242
+ origin: Optional origin identifier (e.g., iteration ID). If an iteration ID
243
+ is provided, the project will be published using that iteration's config.
244
+ """
245
+ request = self.prepare_publish(project_id, origin=origin)
240
246
  response = self._client._prepared_request(request)
241
247
  return Project(**response)
242
248
 
@@ -353,9 +359,15 @@ class AsyncProjects(AsyncAPIResource, ProjectsMixin):
353
359
  request = self.prepare_delete(project_id)
354
360
  return await self._client._prepared_request(request)
355
361
 
356
- async def publish(self, project_id: str, **extra_body: Any) -> Project:
357
- """Publish a project's draft configuration."""
358
- request = self.prepare_publish(project_id, **extra_body)
362
+ async def publish(self, project_id: str, origin: Optional[str] = None) -> Project:
363
+ """Publish a project's draft configuration.
364
+
365
+ Args:
366
+ project_id: The ID of the project to publish
367
+ origin: Optional origin identifier (e.g., iteration ID). If an iteration ID
368
+ is provided, the project will be published using that iteration's config.
369
+ """
370
+ request = self.prepare_publish(project_id, origin=origin)
359
371
  response = await self._client._prepared_request(request)
360
372
  return Project(**response)
361
373
 
@@ -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")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: retab
3
- Version: 0.0.70
3
+ Version: 0.0.72
4
4
  Summary: Retab official python library
5
5
  Home-page: https://github.com/retab-dev/retab
6
6
  Author: Retab
@@ -7,11 +7,11 @@ 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=H-ylTrFcaC36iVj5XSWbwJB489n3GEWwbqsPgQQ50G4,31980
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
14
- retab/resources/projects/client.py,sha256=nvqsDiVyeRrXsoYddwyXNmpZxaBLYWAGO2e0n6qkCzY,14988
14
+ retab/resources/projects/client.py,sha256=5LPAhJt5-nqBP4VWYvo0k7cW6HLGF6K9xMiHKQzIXho,15593
15
15
  retab/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  retab/types/chat.py,sha256=x9VbtPMa4w6Gc0HrFC3ILl6cCnfEn5ytDnwJtZmlcys,1436
17
17
  retab/types/inference_settings.py,sha256=e4NDZHFdtrqi30Za1z0JhRU5PBO94yKxUGoK7S2kA3M,1053
@@ -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=Z-Qsj5-lmWb9dkgyTTt3Z7Lpd4_7SZdRGErtV_aw8oE,16492
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.70.dist-info/METADATA,sha256=fmovHmnRSdICMGaxGo7aOrYiOXbqyMmXBxUiG7gtdEQ,4532
48
- retab-0.0.70.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
- retab-0.0.70.dist-info/top_level.txt,sha256=waQR0EGdhLIQtztoE3AXg7ik5ONQ9q_bsKVpyFuJdq0,6
50
- retab-0.0.70.dist-info/RECORD,,
47
+ retab-0.0.72.dist-info/METADATA,sha256=qHuMpSS3GS_6RZDt0jjrP9WX7OLr1BXA8EbkvorXaWM,4532
48
+ retab-0.0.72.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
+ retab-0.0.72.dist-info/top_level.txt,sha256=waQR0EGdhLIQtztoE3AXg7ik5ONQ9q_bsKVpyFuJdq0,6
50
+ retab-0.0.72.dist-info/RECORD,,
File without changes