retab 0.0.36__py3-none-any.whl → 0.0.38__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.
Files changed (123) hide show
  1. retab/__init__.py +4 -0
  2. {uiform → retab}/_resource.py +5 -5
  3. {uiform → retab}/_utils/ai_models.py +2 -2
  4. {uiform → retab}/_utils/benchmarking.py +15 -16
  5. {uiform → retab}/_utils/chat.py +29 -34
  6. {uiform → retab}/_utils/display.py +0 -3
  7. {uiform → retab}/_utils/json_schema.py +9 -14
  8. {uiform → retab}/_utils/mime.py +11 -14
  9. {uiform → retab}/_utils/responses.py +16 -10
  10. {uiform → retab}/_utils/stream_context_managers.py +1 -1
  11. {uiform → retab}/_utils/usage/usage.py +31 -31
  12. {uiform → retab}/client.py +54 -53
  13. {uiform → retab}/resources/consensus/client.py +19 -38
  14. {uiform → retab}/resources/consensus/completions.py +36 -59
  15. {uiform → retab}/resources/consensus/completions_stream.py +35 -47
  16. {uiform → retab}/resources/consensus/responses.py +37 -86
  17. {uiform → retab}/resources/consensus/responses_stream.py +41 -89
  18. retab/resources/documents/client.py +455 -0
  19. {uiform → retab}/resources/documents/extractions.py +192 -101
  20. {uiform → retab}/resources/evals.py +56 -43
  21. retab/resources/evaluations/__init__.py +3 -0
  22. retab/resources/evaluations/client.py +301 -0
  23. retab/resources/evaluations/documents.py +233 -0
  24. retab/resources/evaluations/iterations.py +452 -0
  25. {uiform → retab}/resources/files.py +2 -2
  26. {uiform → retab}/resources/jsonlUtils.py +225 -221
  27. retab/resources/models.py +73 -0
  28. retab/resources/processors/automations/client.py +244 -0
  29. {uiform → retab}/resources/processors/automations/endpoints.py +79 -120
  30. retab/resources/processors/automations/links.py +294 -0
  31. {uiform → retab}/resources/processors/automations/logs.py +30 -19
  32. retab/resources/processors/automations/mailboxes.py +397 -0
  33. retab/resources/processors/automations/outlook.py +337 -0
  34. {uiform → retab}/resources/processors/automations/tests.py +22 -25
  35. {uiform → retab}/resources/processors/client.py +181 -166
  36. {uiform → retab}/resources/schemas.py +78 -66
  37. {uiform → retab}/resources/secrets/external_api_keys.py +1 -5
  38. retab/resources/secrets/webhook.py +64 -0
  39. {uiform → retab}/resources/usage.py +41 -4
  40. {uiform → retab}/types/ai_models.py +17 -17
  41. {uiform → retab}/types/automations/cron.py +19 -12
  42. {uiform → retab}/types/automations/endpoints.py +7 -4
  43. {uiform → retab}/types/automations/links.py +7 -3
  44. {uiform → retab}/types/automations/mailboxes.py +10 -10
  45. {uiform → retab}/types/automations/outlook.py +15 -11
  46. {uiform → retab}/types/automations/webhooks.py +1 -1
  47. retab/types/browser_canvas.py +3 -0
  48. retab/types/chat.py +8 -0
  49. {uiform → retab}/types/completions.py +12 -15
  50. retab/types/consensus.py +19 -0
  51. {uiform → retab}/types/db/annotations.py +3 -3
  52. {uiform → retab}/types/db/files.py +8 -6
  53. {uiform → retab}/types/documents/create_messages.py +20 -22
  54. {uiform → retab}/types/documents/extractions.py +71 -26
  55. {uiform → retab}/types/evals.py +5 -5
  56. retab/types/evaluations/__init__.py +31 -0
  57. retab/types/evaluations/documents.py +30 -0
  58. retab/types/evaluations/iterations.py +112 -0
  59. retab/types/evaluations/model.py +73 -0
  60. retab/types/events.py +79 -0
  61. {uiform → retab}/types/extractions.py +36 -13
  62. retab/types/inference_settings.py +15 -0
  63. retab/types/jobs/base.py +54 -0
  64. retab/types/jobs/batch_annotation.py +12 -0
  65. {uiform → retab}/types/jobs/evaluation.py +1 -2
  66. {uiform → retab}/types/logs.py +37 -34
  67. retab/types/metrics.py +32 -0
  68. {uiform → retab}/types/mime.py +22 -20
  69. {uiform → retab}/types/modalities.py +10 -10
  70. retab/types/predictions.py +19 -0
  71. {uiform → retab}/types/schemas/enhance.py +4 -2
  72. {uiform → retab}/types/schemas/evaluate.py +7 -4
  73. {uiform → retab}/types/schemas/generate.py +6 -3
  74. {uiform → retab}/types/schemas/layout.py +1 -1
  75. {uiform → retab}/types/schemas/object.py +16 -17
  76. {uiform → retab}/types/schemas/templates.py +1 -3
  77. {uiform → retab}/types/secrets/external_api_keys.py +0 -1
  78. {uiform → retab}/types/standards.py +18 -1
  79. {retab-0.0.36.dist-info → retab-0.0.38.dist-info}/METADATA +78 -77
  80. retab-0.0.38.dist-info/RECORD +107 -0
  81. retab-0.0.38.dist-info/top_level.txt +1 -0
  82. retab-0.0.36.dist-info/RECORD +0 -96
  83. retab-0.0.36.dist-info/top_level.txt +0 -1
  84. uiform/__init__.py +0 -4
  85. uiform/_utils/benchmarking copy.py +0 -588
  86. uiform/resources/documents/client.py +0 -255
  87. uiform/resources/models.py +0 -45
  88. uiform/resources/processors/automations/client.py +0 -78
  89. uiform/resources/processors/automations/links.py +0 -356
  90. uiform/resources/processors/automations/mailboxes.py +0 -435
  91. uiform/resources/processors/automations/outlook.py +0 -444
  92. uiform/resources/secrets/webhook.py +0 -62
  93. uiform/types/chat.py +0 -8
  94. uiform/types/consensus.py +0 -10
  95. uiform/types/events.py +0 -76
  96. uiform/types/jobs/base.py +0 -150
  97. uiform/types/jobs/batch_annotation.py +0 -22
  98. {uiform → retab}/_utils/__init__.py +0 -0
  99. {uiform → retab}/_utils/usage/__init__.py +0 -0
  100. {uiform → retab}/py.typed +0 -0
  101. {uiform → retab}/resources/__init__.py +0 -0
  102. {uiform → retab}/resources/consensus/__init__.py +0 -0
  103. {uiform → retab}/resources/documents/__init__.py +0 -0
  104. {uiform → retab}/resources/finetuning.py +0 -0
  105. {uiform → retab}/resources/openai_example.py +0 -0
  106. {uiform → retab}/resources/processors/__init__.py +0 -0
  107. {uiform → retab}/resources/processors/automations/__init__.py +0 -0
  108. {uiform → retab}/resources/prompt_optimization.py +0 -0
  109. {uiform → retab}/resources/secrets/__init__.py +0 -0
  110. {uiform → retab}/resources/secrets/client.py +0 -0
  111. {uiform → retab}/types/__init__.py +0 -0
  112. {uiform → retab}/types/automations/__init__.py +0 -0
  113. {uiform → retab}/types/db/__init__.py +0 -0
  114. {uiform → retab}/types/documents/__init__.py +0 -0
  115. {uiform → retab}/types/documents/correct_orientation.py +0 -0
  116. {uiform → retab}/types/jobs/__init__.py +0 -0
  117. {uiform → retab}/types/jobs/finetune.py +0 -0
  118. {uiform → retab}/types/jobs/prompt_optimization.py +0 -0
  119. {uiform → retab}/types/jobs/webcrawl.py +0 -0
  120. {uiform → retab}/types/pagination.py +0 -0
  121. {uiform → retab}/types/schemas/__init__.py +0 -0
  122. {uiform → retab}/types/secrets/__init__.py +0 -0
  123. {retab-0.0.36.dist-info → retab-0.0.38.dist-info}/WHEEL +0 -0
@@ -1,33 +1,20 @@
1
- import json
2
- from pathlib import Path
3
- from typing import Any, AsyncGenerator, Generator, TypeVar, Generic, Optional, Union, List, Sequence, cast
4
-
5
- from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
6
- from openai.types.chat.parsed_chat_completion import ParsedChatCompletionMessage
7
- from openai.types.responses.response import Response
8
- from openai.types.responses.response_input_param import ResponseInputParam, ResponseInputItemParam
9
- from openai.types.responses.response_output_item import ResponseOutputItem
10
- from openai.types.shared_params.response_format_json_schema import ResponseFormatJSONSchema
1
+ from typing import AsyncGenerator, Generator, Optional, TypeVar, Union
2
+
3
+ from openai.types.responses.response_input_param import ResponseInputParam
4
+ from openai.types.responses.response_text_config_param import ResponseTextConfigParam
5
+ from openai.types.shared_params.reasoning import Reasoning
11
6
  from pydantic import BaseModel
12
7
 
13
8
  from ..._resource import AsyncAPIResource, SyncAPIResource
14
9
  from ..._utils.ai_models import assert_valid_model_extraction
15
- from ..._utils.json_schema import load_json_schema, unflatten_dict
16
- from ..._utils.responses import convert_to_openai_format, convert_from_openai_format, parse_openai_responses_response
17
10
  from ..._utils.stream_context_managers import as_async_context_manager, as_context_manager
18
- from ...types.chat import ChatCompletionUiformMessage
19
- from ...types.completions import UiChatResponseCreateRequest, UiChatCompletionsRequest
20
- from ...types.documents.extractions import UiParsedChatCompletion, UiParsedChatCompletionChunk, UiParsedChoice, UiResponse
21
- from ...types.standards import PreparedRequest
11
+ from ...types.completions import UiChatResponseCreateRequest
12
+ from ...types.documents.extractions import UiResponse
22
13
  from ...types.schemas.object import Schema
14
+ from ...types.standards import PreparedRequest
23
15
 
24
- from typing import Optional, Union
25
- from openai.types.shared_params.reasoning import Reasoning
26
- from openai.types.responses.response_input_param import ResponseInputParam
27
- from openai.types.responses.response_text_config_param import ResponseTextConfigParam
28
- from openai.types.shared_params.response_format_json_schema import ResponseFormatJSONSchema
16
+ T = TypeVar("T", bound=BaseModel)
29
17
 
30
- T = TypeVar('T', bound=BaseModel)
31
18
 
32
19
  class BaseResponsesMixin:
33
20
  def prepare_create(
@@ -56,35 +43,20 @@ class BaseResponsesMixin:
56
43
 
57
44
  if instructions is None:
58
45
  instructions = schema_obj.developer_system_prompt
59
-
46
+
60
47
  # Create the request object based on the UiChatResponseCreateRequest model
61
- data = UiChatResponseCreateRequest(
48
+ request = UiChatResponseCreateRequest(
62
49
  model=model,
63
50
  input=input,
64
51
  temperature=temperature,
65
52
  stream=stream,
66
- reasoning=reasoning,
53
+ reasoning=reasoning,
67
54
  n_consensus=n_consensus,
68
- text={
69
- "format": {
70
- "type": "json_schema",
71
- "name": schema_obj.id,
72
- "schema": schema_obj.inference_json_schema,
73
- "strict": True
74
- }
75
- },
55
+ text={"format": {"type": "json_schema", "name": schema_obj.id, "schema": schema_obj.inference_json_schema, "strict": True}},
76
56
  instructions=instructions,
77
57
  )
78
58
 
79
- # Validate the request data
80
- ui_chat_response_create_request = UiChatResponseCreateRequest.model_validate(data)
81
-
82
- return PreparedRequest(
83
- method="POST",
84
- url="/v1/responses",
85
- data=ui_chat_response_create_request.model_dump(),
86
- idempotency_key=idempotency_key
87
- )
59
+ return PreparedRequest(method="POST", url="/v1/responses", data=request.model_dump(), idempotency_key=idempotency_key)
88
60
 
89
61
  def prepare_parse(
90
62
  self,
@@ -108,47 +80,29 @@ class BaseResponsesMixin:
108
80
 
109
81
  if instructions is None:
110
82
  instructions = schema_obj.developer_system_prompt
111
-
83
+
112
84
  # Create the request object based on the UiChatResponseCreateRequest model
113
- data = UiChatResponseCreateRequest(
85
+ request = UiChatResponseCreateRequest(
114
86
  model=model,
115
87
  input=input,
116
88
  temperature=temperature,
117
89
  stream=stream,
118
- reasoning=reasoning,
90
+ reasoning=reasoning,
119
91
  n_consensus=n_consensus,
120
- text={
121
- "format": {
122
- "type": "json_schema",
123
- "name": schema_obj.id,
124
- "schema": schema_obj.inference_json_schema,
125
- "strict": True
126
- }
127
- },
92
+ text={"format": {"type": "json_schema", "name": schema_obj.id, "schema": schema_obj.inference_json_schema, "strict": True}},
128
93
  instructions=instructions,
129
94
  )
130
95
 
131
- # Validate the request data
132
- ui_chat_response_create_request = UiChatResponseCreateRequest.model_validate(data)
133
-
134
- return PreparedRequest(
135
- method="POST",
136
- url="/v1/responses",
137
- data=ui_chat_response_create_request.model_dump(),
138
- idempotency_key=idempotency_key
139
- )
140
-
141
-
142
96
  return PreparedRequest(
143
- method="POST",
144
- url="/v1/completions",
145
- data=ui_chat_completions_request.model_dump(),
146
- idempotency_key=idempotency_key
97
+ method="POST",
98
+ url="/v1/responses",
99
+ data=request.model_dump(),
100
+ idempotency_key=idempotency_key,
147
101
  )
148
102
 
149
103
 
150
104
  class Responses(SyncAPIResource, BaseResponsesMixin):
151
- """UiForm Responses API compatible with OpenAI Responses API"""
105
+ """Retab Responses API compatible with OpenAI Responses API"""
152
106
 
153
107
  @as_context_manager
154
108
  def stream(
@@ -163,8 +117,8 @@ class Responses(SyncAPIResource, BaseResponsesMixin):
163
117
  idempotency_key: Optional[str] = None,
164
118
  ) -> Generator[UiResponse, None, None]:
165
119
  """
166
- Create a completion using the UiForm API with streaming enabled.
167
-
120
+ Create a completion using the Retab API with streaming enabled.
121
+
168
122
  Args:
169
123
  model: The model to use
170
124
  input: The input text or message array
@@ -174,13 +128,13 @@ class Responses(SyncAPIResource, BaseResponsesMixin):
174
128
  n_consensus: Number of consensus models to use
175
129
  instructions: Optional system instructions
176
130
  idempotency_key: Idempotency key for request
177
-
131
+
178
132
  Returns:
179
133
  Generator[UiResponse]: Stream of responses
180
134
 
181
135
  Usage:
182
136
  ```python
183
- with uiform.responses.stream(model, input, text, temperature, reasoning) as stream:
137
+ with retab.responses.stream(model, input, text, temperature, reasoning) as stream:
184
138
  for response in stream:
185
139
  print(response)
186
140
  ```
@@ -217,8 +171,8 @@ class Responses(SyncAPIResource, BaseResponsesMixin):
217
171
  idempotency_key: Optional[str] = None,
218
172
  ) -> Generator[UiResponse, None, None]:
219
173
  """
220
- Parse content using the UiForm API with streaming enabled.
221
-
174
+ Parse content using the Retab API with streaming enabled.
175
+
222
176
  Args:
223
177
  model: The model to use
224
178
  input: The input text or message array
@@ -228,13 +182,13 @@ class Responses(SyncAPIResource, BaseResponsesMixin):
228
182
  n_consensus: Number of consensus models to use
229
183
  instructions: Optional system instructions
230
184
  idempotency_key: Idempotency key for request
231
-
185
+
232
186
  Returns:
233
187
  Generator[UiResponse]: Stream of parsed responses
234
188
 
235
189
  Usage:
236
190
  ```python
237
- with uiform.responses.stream_parse(model, input, MyModel, temperature, reasoning) as stream:
191
+ with retab.responses.stream_parse(model, input, MyModel, temperature, reasoning) as stream:
238
192
  for response in stream:
239
193
  print(response)
240
194
  ```
@@ -259,9 +213,8 @@ class Responses(SyncAPIResource, BaseResponsesMixin):
259
213
  yield response
260
214
 
261
215
 
262
-
263
216
  class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
264
- """UiForm Responses API compatible with OpenAI Responses API for async usage"""
217
+ """Retab Responses API compatible with OpenAI Responses API for async usage"""
265
218
 
266
219
  @as_async_context_manager
267
220
  async def stream(
@@ -276,8 +229,8 @@ class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
276
229
  idempotency_key: Optional[str] = None,
277
230
  ) -> AsyncGenerator[UiResponse, None]:
278
231
  """
279
- Create a completion using the UiForm API asynchronously with streaming enabled.
280
-
232
+ Create a completion using the Retab API asynchronously with streaming enabled.
233
+
281
234
  Args:
282
235
  model: The model to use
283
236
  input: The input text or message array
@@ -287,13 +240,13 @@ class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
287
240
  n_consensus: Number of consensus models to use
288
241
  instructions: Optional system instructions
289
242
  idempotency_key: Idempotency key for request
290
-
243
+
291
244
  Returns:
292
245
  AsyncGenerator[UiResponse]: Async stream of responses
293
246
 
294
247
  Usage:
295
248
  ```python
296
- async with uiform.responses.async_stream(model, input, text, temperature, reasoning) as stream:
249
+ async with retab.responses.async_stream(model, input, text, temperature, reasoning) as stream:
297
250
  async for response in stream:
298
251
  print(response)
299
252
  ```
@@ -316,7 +269,7 @@ class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
316
269
  continue
317
270
  response = UiResponse.model_validate(chunk_json)
318
271
  yield response
319
-
272
+
320
273
  @as_async_context_manager
321
274
  async def stream_parse(
322
275
  self,
@@ -330,8 +283,8 @@ class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
330
283
  idempotency_key: Optional[str] = None,
331
284
  ) -> AsyncGenerator[UiResponse, None]:
332
285
  """
333
- Parse content using the UiForm API asynchronously with streaming enabled.
334
-
286
+ Parse content using the Retab API asynchronously with streaming enabled.
287
+
335
288
  Args:
336
289
  model: The model to use
337
290
  input: The input text or message array
@@ -341,13 +294,13 @@ class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
341
294
  n_consensus: Number of consensus models to use
342
295
  instructions: Optional system instructions
343
296
  idempotency_key: Idempotency key for request
344
-
297
+
345
298
  Returns:
346
299
  AsyncGenerator[UiResponse]: Async stream of parsed responses
347
300
 
348
301
  Usage:
349
302
  ```python
350
- async with uiform.responses.async_stream_parse(model, input, MyModel, temperature, reasoning) as stream:
303
+ async with retab.responses.async_stream_parse(model, input, MyModel, temperature, reasoning) as stream:
351
304
  async for response in stream:
352
305
  print(response)
353
306
  ```
@@ -370,4 +323,3 @@ class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
370
323
  continue
371
324
  response = UiResponse.model_validate(chunk_json)
372
325
  yield response
373
-