retab 0.0.36__py3-none-any.whl → 0.0.37__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.
- {uiform → retab}/_utils/ai_models.py +2 -2
- {uiform → retab}/_utils/benchmarking.py +15 -16
- {uiform → retab}/_utils/chat.py +9 -14
- {uiform → retab}/_utils/display.py +0 -3
- {uiform → retab}/_utils/json_schema.py +9 -14
- {uiform → retab}/_utils/mime.py +11 -14
- {uiform → retab}/_utils/responses.py +9 -3
- {uiform → retab}/_utils/stream_context_managers.py +1 -1
- {uiform → retab}/_utils/usage/usage.py +28 -28
- {uiform → retab}/client.py +32 -31
- {uiform → retab}/resources/consensus/client.py +17 -36
- {uiform → retab}/resources/consensus/completions.py +24 -47
- {uiform → retab}/resources/consensus/completions_stream.py +26 -38
- {uiform → retab}/resources/consensus/responses.py +31 -80
- {uiform → retab}/resources/consensus/responses_stream.py +31 -79
- {uiform → retab}/resources/documents/client.py +59 -45
- {uiform → retab}/resources/documents/extractions.py +181 -90
- {uiform → retab}/resources/evals.py +56 -43
- retab/resources/evaluations/__init__.py +3 -0
- retab/resources/evaluations/client.py +301 -0
- retab/resources/evaluations/documents.py +233 -0
- retab/resources/evaluations/iterations.py +452 -0
- {uiform → retab}/resources/files.py +2 -2
- {uiform → retab}/resources/jsonlUtils.py +220 -216
- retab/resources/models.py +73 -0
- retab/resources/processors/automations/client.py +244 -0
- {uiform → retab}/resources/processors/automations/endpoints.py +77 -118
- retab/resources/processors/automations/links.py +294 -0
- {uiform → retab}/resources/processors/automations/logs.py +30 -19
- {uiform → retab}/resources/processors/automations/mailboxes.py +136 -174
- retab/resources/processors/automations/outlook.py +337 -0
- {uiform → retab}/resources/processors/automations/tests.py +22 -25
- {uiform → retab}/resources/processors/client.py +179 -164
- {uiform → retab}/resources/schemas.py +78 -66
- {uiform → retab}/resources/secrets/external_api_keys.py +1 -5
- retab/resources/secrets/webhook.py +64 -0
- {uiform → retab}/resources/usage.py +39 -2
- {uiform → retab}/types/ai_models.py +13 -13
- {uiform → retab}/types/automations/cron.py +19 -12
- {uiform → retab}/types/automations/endpoints.py +7 -4
- {uiform → retab}/types/automations/links.py +7 -3
- {uiform → retab}/types/automations/mailboxes.py +9 -9
- {uiform → retab}/types/automations/outlook.py +15 -11
- retab/types/browser_canvas.py +3 -0
- {uiform → retab}/types/chat.py +2 -2
- {uiform → retab}/types/completions.py +9 -12
- retab/types/consensus.py +19 -0
- {uiform → retab}/types/db/annotations.py +3 -3
- {uiform → retab}/types/db/files.py +8 -6
- {uiform → retab}/types/documents/create_messages.py +18 -20
- {uiform → retab}/types/documents/extractions.py +69 -24
- {uiform → retab}/types/evals.py +5 -5
- retab/types/evaluations/__init__.py +31 -0
- retab/types/evaluations/documents.py +30 -0
- retab/types/evaluations/iterations.py +112 -0
- retab/types/evaluations/model.py +73 -0
- retab/types/events.py +79 -0
- {uiform → retab}/types/extractions.py +33 -10
- retab/types/inference_settings.py +15 -0
- retab/types/jobs/base.py +54 -0
- retab/types/jobs/batch_annotation.py +12 -0
- {uiform → retab}/types/jobs/evaluation.py +1 -2
- {uiform → retab}/types/logs.py +37 -34
- retab/types/metrics.py +32 -0
- {uiform → retab}/types/mime.py +22 -20
- {uiform → retab}/types/modalities.py +10 -10
- retab/types/predictions.py +19 -0
- {uiform → retab}/types/schemas/enhance.py +4 -2
- {uiform → retab}/types/schemas/evaluate.py +7 -4
- {uiform → retab}/types/schemas/generate.py +6 -3
- {uiform → retab}/types/schemas/layout.py +1 -1
- {uiform → retab}/types/schemas/object.py +13 -14
- {uiform → retab}/types/schemas/templates.py +1 -3
- {uiform → retab}/types/secrets/external_api_keys.py +0 -1
- {uiform → retab}/types/standards.py +18 -1
- {retab-0.0.36.dist-info → retab-0.0.37.dist-info}/METADATA +7 -6
- retab-0.0.37.dist-info/RECORD +107 -0
- retab-0.0.37.dist-info/top_level.txt +1 -0
- retab-0.0.36.dist-info/RECORD +0 -96
- retab-0.0.36.dist-info/top_level.txt +0 -1
- uiform/_utils/benchmarking copy.py +0 -588
- uiform/resources/models.py +0 -45
- uiform/resources/processors/automations/client.py +0 -78
- uiform/resources/processors/automations/links.py +0 -356
- uiform/resources/processors/automations/outlook.py +0 -444
- uiform/resources/secrets/webhook.py +0 -62
- uiform/types/consensus.py +0 -10
- uiform/types/events.py +0 -76
- uiform/types/jobs/base.py +0 -150
- uiform/types/jobs/batch_annotation.py +0 -22
- {uiform → retab}/__init__.py +0 -0
- {uiform → retab}/_resource.py +0 -0
- {uiform → retab}/_utils/__init__.py +0 -0
- {uiform → retab}/_utils/usage/__init__.py +0 -0
- {uiform → retab}/py.typed +0 -0
- {uiform → retab}/resources/__init__.py +0 -0
- {uiform → retab}/resources/consensus/__init__.py +0 -0
- {uiform → retab}/resources/documents/__init__.py +0 -0
- {uiform → retab}/resources/finetuning.py +0 -0
- {uiform → retab}/resources/openai_example.py +0 -0
- {uiform → retab}/resources/processors/__init__.py +0 -0
- {uiform → retab}/resources/processors/automations/__init__.py +0 -0
- {uiform → retab}/resources/prompt_optimization.py +0 -0
- {uiform → retab}/resources/secrets/__init__.py +0 -0
- {uiform → retab}/resources/secrets/client.py +0 -0
- {uiform → retab}/types/__init__.py +0 -0
- {uiform → retab}/types/automations/__init__.py +0 -0
- {uiform → retab}/types/automations/webhooks.py +0 -0
- {uiform → retab}/types/db/__init__.py +0 -0
- {uiform → retab}/types/documents/__init__.py +0 -0
- {uiform → retab}/types/documents/correct_orientation.py +0 -0
- {uiform → retab}/types/jobs/__init__.py +0 -0
- {uiform → retab}/types/jobs/finetune.py +0 -0
- {uiform → retab}/types/jobs/prompt_optimization.py +0 -0
- {uiform → retab}/types/jobs/webcrawl.py +0 -0
- {uiform → retab}/types/pagination.py +0 -0
- {uiform → retab}/types/schemas/__init__.py +0 -0
- {uiform → retab}/types/secrets/__init__.py +0 -0
- {retab-0.0.36.dist-info → retab-0.0.37.dist-info}/WHEEL +0 -0
@@ -1,31 +1,29 @@
|
|
1
1
|
import base64
|
2
|
-
import datetime
|
3
2
|
from io import IOBase
|
4
3
|
from pathlib import Path
|
5
|
-
from typing import Any, Dict, List, Literal
|
4
|
+
from typing import Any, Dict, List, Literal
|
6
5
|
|
7
|
-
import httpx
|
8
6
|
import PIL.Image
|
9
7
|
from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
|
10
|
-
from pydantic import HttpUrl
|
8
|
+
from pydantic import BaseModel, HttpUrl
|
9
|
+
from pydantic_core import PydanticUndefined
|
11
10
|
|
12
11
|
from ..._resource import AsyncAPIResource, SyncAPIResource
|
13
12
|
from ..._utils.ai_models import assert_valid_model_extraction
|
14
13
|
from ..._utils.mime import MIMEData, prepare_mime_document
|
14
|
+
from ...types.browser_canvas import BrowserCanvas
|
15
|
+
from ...types.documents.extractions import UiParsedChatCompletion
|
15
16
|
from ...types.logs import ProcessorConfig, UpdateProcessorRequest
|
16
|
-
from ...types.pagination import ListMetadata
|
17
|
-
from ...types.documents.extractions import UiParsedChatCompletion, DocumentExtractRequest
|
18
|
-
from pydantic import BaseModel
|
19
|
-
|
20
|
-
# from ...types.documents.extractions import DocumentExtractResponse
|
21
|
-
from ...types.mime import BaseMIMEData
|
22
17
|
from ...types.modalities import Modality
|
18
|
+
from ...types.pagination import ListMetadata
|
23
19
|
from ...types.standards import PreparedRequest
|
24
|
-
from .automations import
|
20
|
+
from .automations.client import AsyncAutomations, Automations
|
25
21
|
|
26
22
|
|
27
23
|
class ListProcessors(BaseModel):
|
28
|
-
|
24
|
+
"""Response model for listing processor configurations."""
|
25
|
+
|
26
|
+
data: list[ProcessorConfig]
|
29
27
|
list_metadata: ListMetadata
|
30
28
|
|
31
29
|
|
@@ -33,44 +31,43 @@ class ProcessorsMixin:
|
|
33
31
|
def prepare_create(
|
34
32
|
self,
|
35
33
|
name: str,
|
36
|
-
json_schema:
|
34
|
+
json_schema: dict[str, Any],
|
37
35
|
modality: Modality = "native",
|
38
36
|
model: str = "gpt-4o-mini",
|
39
|
-
temperature: float =
|
40
|
-
reasoning_effort: ChatCompletionReasoningEffort =
|
41
|
-
image_resolution_dpi:
|
42
|
-
browser_canvas:
|
43
|
-
n_consensus: int =
|
37
|
+
temperature: float = PydanticUndefined, # type: ignore[assignment]
|
38
|
+
reasoning_effort: ChatCompletionReasoningEffort = PydanticUndefined, # type: ignore[assignment]
|
39
|
+
image_resolution_dpi: int = PydanticUndefined, # type: ignore[assignment]
|
40
|
+
browser_canvas: BrowserCanvas = PydanticUndefined, # type: ignore[assignment]
|
41
|
+
n_consensus: int = PydanticUndefined, # type: ignore[assignment]
|
44
42
|
) -> PreparedRequest:
|
45
43
|
assert_valid_model_extraction(model)
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
45
|
+
processor_config = ProcessorConfig(
|
46
|
+
name=name,
|
47
|
+
json_schema=json_schema,
|
48
|
+
modality=modality,
|
49
|
+
model=model,
|
50
|
+
temperature=temperature,
|
51
|
+
reasoning_effort=reasoning_effort,
|
52
|
+
image_resolution_dpi=image_resolution_dpi,
|
53
|
+
browser_canvas=browser_canvas,
|
54
|
+
n_consensus=n_consensus,
|
55
|
+
)
|
58
56
|
|
59
|
-
|
60
|
-
return PreparedRequest(method="POST", url="/v1/processors", data=request.model_dump(mode='json'))
|
57
|
+
return PreparedRequest(method="POST", url="/v1/processors", data=processor_config.model_dump(mode="json"))
|
61
58
|
|
62
59
|
def prepare_list(
|
63
60
|
self,
|
64
|
-
before:
|
65
|
-
after:
|
66
|
-
limit:
|
67
|
-
order:
|
61
|
+
before: str | None = None,
|
62
|
+
after: str | None = None,
|
63
|
+
limit: int | None = 10,
|
64
|
+
order: Literal["asc", "desc"] | None = "desc",
|
68
65
|
# Filtering parameters
|
69
|
-
name:
|
70
|
-
modality:
|
71
|
-
model:
|
72
|
-
schema_id:
|
73
|
-
schema_data_id:
|
66
|
+
name: str | None = None,
|
67
|
+
modality: str | None = None,
|
68
|
+
model: str | None = None,
|
69
|
+
schema_id: str | None = None,
|
70
|
+
schema_data_id: str | None = None,
|
74
71
|
) -> PreparedRequest:
|
75
72
|
params = {
|
76
73
|
"before": before,
|
@@ -102,39 +99,32 @@ class ProcessorsMixin:
|
|
102
99
|
def prepare_update(
|
103
100
|
self,
|
104
101
|
processor_id: str,
|
105
|
-
name:
|
106
|
-
modality:
|
107
|
-
image_resolution_dpi:
|
108
|
-
browser_canvas:
|
109
|
-
model:
|
110
|
-
json_schema:
|
111
|
-
temperature:
|
112
|
-
reasoning_effort:
|
113
|
-
n_consensus:
|
102
|
+
name: str | None = None,
|
103
|
+
modality: Modality | None = None,
|
104
|
+
image_resolution_dpi: int | None = None,
|
105
|
+
browser_canvas: BrowserCanvas | None = None,
|
106
|
+
model: str | None = None,
|
107
|
+
json_schema: dict[str, Any] | None = None,
|
108
|
+
temperature: float | None = None,
|
109
|
+
reasoning_effort: ChatCompletionReasoningEffort | None = None,
|
110
|
+
n_consensus: int | None = None,
|
114
111
|
) -> PreparedRequest:
|
115
|
-
data: dict[str, Any] = {}
|
116
|
-
|
117
|
-
if name is not None:
|
118
|
-
data["name"] = name
|
119
|
-
if modality is not None:
|
120
|
-
data["modality"] = modality
|
121
|
-
if image_resolution_dpi is not None:
|
122
|
-
data["image_resolution_dpi"] = image_resolution_dpi
|
123
|
-
if browser_canvas is not None:
|
124
|
-
data["browser_canvas"] = browser_canvas
|
125
112
|
if model is not None:
|
126
113
|
assert_valid_model_extraction(model)
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
114
|
+
|
115
|
+
update_request = UpdateProcessorRequest(
|
116
|
+
name=name,
|
117
|
+
modality=modality,
|
118
|
+
image_resolution_dpi=image_resolution_dpi,
|
119
|
+
browser_canvas=browser_canvas,
|
120
|
+
model=model,
|
121
|
+
json_schema=json_schema,
|
122
|
+
temperature=temperature,
|
123
|
+
reasoning_effort=reasoning_effort,
|
124
|
+
n_consensus=n_consensus,
|
125
|
+
)
|
126
|
+
|
127
|
+
return PreparedRequest(method="PUT", url=f"/v1/processors/{processor_id}", data=update_request.model_dump(mode="json", exclude_none=True))
|
138
128
|
|
139
129
|
def prepare_delete(self, processor_id: str) -> PreparedRequest:
|
140
130
|
return PreparedRequest(method="DELETE", url=f"/v1/processors/{processor_id}")
|
@@ -142,10 +132,10 @@ class ProcessorsMixin:
|
|
142
132
|
def prepare_submit(
|
143
133
|
self,
|
144
134
|
processor_id: str,
|
145
|
-
document:
|
146
|
-
documents:
|
147
|
-
temperature:
|
148
|
-
seed:
|
135
|
+
document: Path | str | bytes | IOBase | MIMEData | PIL.Image.Image | HttpUrl | None = None,
|
136
|
+
documents: list[Path | str | bytes | IOBase | MIMEData | PIL.Image.Image | HttpUrl] | None = None,
|
137
|
+
temperature: float | None = None,
|
138
|
+
seed: int | None = None,
|
149
139
|
store: bool = True,
|
150
140
|
) -> PreparedRequest:
|
151
141
|
"""Prepare a request to submit documents to a processor.
|
@@ -164,10 +154,10 @@ class ProcessorsMixin:
|
|
164
154
|
# Validate that either document or documents is provided, but not both
|
165
155
|
if not document and not documents:
|
166
156
|
raise ValueError("Either 'document' or 'documents' must be provided")
|
167
|
-
|
157
|
+
|
168
158
|
if document and documents:
|
169
159
|
raise ValueError("Provide either 'document' (single) or 'documents' (multiple), not both")
|
170
|
-
|
160
|
+
|
171
161
|
# Prepare form data parameters
|
172
162
|
form_data = {
|
173
163
|
"temperature": temperature,
|
@@ -183,31 +173,23 @@ class ProcessorsMixin:
|
|
183
173
|
# Convert document to MIMEData if needed
|
184
174
|
mime_document = prepare_mime_document(document)
|
185
175
|
# Single document upload
|
186
|
-
files["document"] = (
|
187
|
-
mime_document.filename,
|
188
|
-
base64.b64decode(mime_document.content),
|
189
|
-
mime_document.mime_type
|
190
|
-
)
|
176
|
+
files["document"] = (mime_document.filename, base64.b64decode(mime_document.content), mime_document.mime_type)
|
191
177
|
elif documents:
|
192
178
|
# Multiple documents upload - httpx supports multiple files with same field name using a list
|
193
179
|
files_list = []
|
194
180
|
for doc in documents:
|
195
181
|
# Convert each document to MIMEData if needed
|
196
182
|
mime_doc = prepare_mime_document(doc)
|
197
|
-
files_list.append(
|
198
|
-
"documents", # field name
|
183
|
+
files_list.append(
|
199
184
|
(
|
200
|
-
|
201
|
-
base64.b64decode(mime_doc.content),
|
202
|
-
mime_doc.mime_type
|
185
|
+
"documents", # field name
|
186
|
+
(mime_doc.filename, base64.b64decode(mime_doc.content), mime_doc.mime_type),
|
203
187
|
)
|
204
|
-
)
|
188
|
+
)
|
205
189
|
files = files_list
|
206
190
|
|
207
191
|
url = f"/v1/processors/{processor_id}/submit"
|
208
|
-
|
209
|
-
# url = f"/v1/processors/{processor_id}/submit/stream"
|
210
|
-
|
192
|
+
|
211
193
|
return PreparedRequest(method="POST", url=url, form_data=form_data, files=files)
|
212
194
|
|
213
195
|
|
@@ -224,11 +206,11 @@ class Processors(SyncAPIResource, ProcessorsMixin):
|
|
224
206
|
json_schema: Dict[str, Any],
|
225
207
|
modality: Modality = "native",
|
226
208
|
model: str = "gpt-4o-mini",
|
227
|
-
temperature: float =
|
228
|
-
reasoning_effort: ChatCompletionReasoningEffort =
|
229
|
-
image_resolution_dpi:
|
230
|
-
browser_canvas:
|
231
|
-
n_consensus: int =
|
209
|
+
temperature: float = PydanticUndefined, # type: ignore[assignment]
|
210
|
+
reasoning_effort: ChatCompletionReasoningEffort = PydanticUndefined, # type: ignore[assignment]
|
211
|
+
image_resolution_dpi: int = PydanticUndefined, # type: ignore[assignment]
|
212
|
+
browser_canvas: BrowserCanvas = PydanticUndefined, # type: ignore[assignment]
|
213
|
+
n_consensus: int = PydanticUndefined, # type: ignore[assignment]
|
232
214
|
) -> ProcessorConfig:
|
233
215
|
"""Create a new processor configuration.
|
234
216
|
|
@@ -245,22 +227,32 @@ class Processors(SyncAPIResource, ProcessorsMixin):
|
|
245
227
|
Returns:
|
246
228
|
ProcessorConfig: The created processor configuration
|
247
229
|
"""
|
248
|
-
request = self.prepare_create(
|
230
|
+
request = self.prepare_create(
|
231
|
+
name=name,
|
232
|
+
json_schema=json_schema,
|
233
|
+
modality=modality,
|
234
|
+
model=model,
|
235
|
+
temperature=temperature,
|
236
|
+
reasoning_effort=reasoning_effort,
|
237
|
+
image_resolution_dpi=image_resolution_dpi,
|
238
|
+
browser_canvas=browser_canvas,
|
239
|
+
n_consensus=n_consensus,
|
240
|
+
)
|
249
241
|
response = self._client._prepared_request(request)
|
250
242
|
print(f"Processor ID: {response['id']}. Processor available at https://www.uiform.com/dashboard/processors/{response['id']}")
|
251
243
|
return ProcessorConfig.model_validate(response)
|
252
244
|
|
253
245
|
def list(
|
254
246
|
self,
|
255
|
-
before:
|
256
|
-
after:
|
257
|
-
limit:
|
258
|
-
order:
|
259
|
-
name:
|
260
|
-
modality:
|
261
|
-
model:
|
262
|
-
schema_id:
|
263
|
-
schema_data_id:
|
247
|
+
before: str | None = None,
|
248
|
+
after: str | None = None,
|
249
|
+
limit: int | None = 10,
|
250
|
+
order: Literal["asc", "desc"] | None = "desc",
|
251
|
+
name: str | None = None,
|
252
|
+
modality: str | None = None,
|
253
|
+
model: str | None = None,
|
254
|
+
schema_id: str | None = None,
|
255
|
+
schema_data_id: str | None = None,
|
264
256
|
) -> ListProcessors:
|
265
257
|
"""List processor configurations with pagination support.
|
266
258
|
|
@@ -298,15 +290,15 @@ class Processors(SyncAPIResource, ProcessorsMixin):
|
|
298
290
|
def update(
|
299
291
|
self,
|
300
292
|
processor_id: str,
|
301
|
-
name:
|
302
|
-
modality:
|
303
|
-
image_resolution_dpi:
|
304
|
-
browser_canvas:
|
305
|
-
model:
|
306
|
-
json_schema:
|
307
|
-
temperature:
|
308
|
-
reasoning_effort:
|
309
|
-
n_consensus:
|
293
|
+
name: str | None = None,
|
294
|
+
modality: Modality | None = None,
|
295
|
+
image_resolution_dpi: int | None = None,
|
296
|
+
browser_canvas: BrowserCanvas | None = None,
|
297
|
+
model: str | None = None,
|
298
|
+
json_schema: dict[str, Any] | None = None,
|
299
|
+
temperature: float | None = None,
|
300
|
+
reasoning_effort: ChatCompletionReasoningEffort | None = None,
|
301
|
+
n_consensus: int | None = None,
|
310
302
|
) -> ProcessorConfig:
|
311
303
|
"""Update a processor configuration.
|
312
304
|
|
@@ -324,7 +316,18 @@ class Processors(SyncAPIResource, ProcessorsMixin):
|
|
324
316
|
Returns:
|
325
317
|
ProcessorConfig: The updated processor configuration
|
326
318
|
"""
|
327
|
-
request = self.prepare_update(
|
319
|
+
request = self.prepare_update(
|
320
|
+
processor_id=processor_id,
|
321
|
+
name=name,
|
322
|
+
modality=modality,
|
323
|
+
image_resolution_dpi=image_resolution_dpi,
|
324
|
+
browser_canvas=browser_canvas,
|
325
|
+
model=model,
|
326
|
+
json_schema=json_schema,
|
327
|
+
temperature=temperature,
|
328
|
+
reasoning_effort=reasoning_effort,
|
329
|
+
n_consensus=n_consensus,
|
330
|
+
)
|
328
331
|
response = self._client._prepared_request(request)
|
329
332
|
return ProcessorConfig.model_validate(response)
|
330
333
|
|
@@ -341,10 +344,10 @@ class Processors(SyncAPIResource, ProcessorsMixin):
|
|
341
344
|
def submit(
|
342
345
|
self,
|
343
346
|
processor_id: str,
|
344
|
-
document:
|
345
|
-
documents:
|
346
|
-
temperature:
|
347
|
-
seed:
|
347
|
+
document: Path | str | bytes | IOBase | MIMEData | PIL.Image.Image | HttpUrl | None = None,
|
348
|
+
documents: List[Path | str | bytes | IOBase | MIMEData | PIL.Image.Image | HttpUrl] | None = None,
|
349
|
+
temperature: float | None = None,
|
350
|
+
seed: int | None = None,
|
348
351
|
store: bool = True,
|
349
352
|
) -> UiParsedChatCompletion:
|
350
353
|
"""Submit documents to a processor for processing.
|
@@ -360,14 +363,7 @@ class Processors(SyncAPIResource, ProcessorsMixin):
|
|
360
363
|
Returns:
|
361
364
|
UiParsedChatCompletion: The processing result
|
362
365
|
"""
|
363
|
-
request = self.prepare_submit(
|
364
|
-
processor_id=processor_id,
|
365
|
-
document=document,
|
366
|
-
documents=documents,
|
367
|
-
temperature=temperature,
|
368
|
-
seed=seed,
|
369
|
-
store=store
|
370
|
-
)
|
366
|
+
request = self.prepare_submit(processor_id=processor_id, document=document, documents=documents, temperature=temperature, seed=seed, store=store)
|
371
367
|
response = self._client._prepared_request(request)
|
372
368
|
return UiParsedChatCompletion.model_validate(response)
|
373
369
|
|
@@ -385,29 +381,39 @@ class AsyncProcessors(AsyncAPIResource, ProcessorsMixin):
|
|
385
381
|
json_schema: Dict[str, Any],
|
386
382
|
modality: Modality = "native",
|
387
383
|
model: str = "gpt-4o-mini",
|
388
|
-
temperature: float =
|
389
|
-
reasoning_effort: ChatCompletionReasoningEffort =
|
390
|
-
image_resolution_dpi:
|
391
|
-
browser_canvas:
|
392
|
-
n_consensus: int =
|
384
|
+
temperature: float = PydanticUndefined, # type: ignore[assignment]
|
385
|
+
reasoning_effort: ChatCompletionReasoningEffort = PydanticUndefined, # type: ignore[assignment]
|
386
|
+
image_resolution_dpi: int = PydanticUndefined, # type: ignore[assignment]
|
387
|
+
browser_canvas: BrowserCanvas = PydanticUndefined, # type: ignore[assignment]
|
388
|
+
n_consensus: int = PydanticUndefined, # type: ignore[assignment]
|
393
389
|
) -> ProcessorConfig:
|
394
|
-
request = self.prepare_create(
|
390
|
+
request = self.prepare_create(
|
391
|
+
name=name,
|
392
|
+
json_schema=json_schema,
|
393
|
+
modality=modality,
|
394
|
+
model=model,
|
395
|
+
temperature=temperature,
|
396
|
+
reasoning_effort=reasoning_effort,
|
397
|
+
image_resolution_dpi=image_resolution_dpi,
|
398
|
+
browser_canvas=browser_canvas,
|
399
|
+
n_consensus=n_consensus,
|
400
|
+
)
|
395
401
|
response = await self._client._prepared_request(request)
|
396
402
|
print(f"Processor ID: {response['id']}. Processor available at https://www.uiform.com/dashboard/processors/{response['id']}")
|
397
|
-
|
403
|
+
|
398
404
|
return ProcessorConfig.model_validate(response)
|
399
405
|
|
400
406
|
async def list(
|
401
407
|
self,
|
402
|
-
before:
|
403
|
-
after:
|
404
|
-
limit:
|
405
|
-
order:
|
406
|
-
name:
|
407
|
-
modality:
|
408
|
-
model:
|
409
|
-
schema_id:
|
410
|
-
schema_data_id:
|
408
|
+
before: str | None = None,
|
409
|
+
after: str | None = None,
|
410
|
+
limit: int | None = 10,
|
411
|
+
order: Literal["asc", "desc"] | None = "desc",
|
412
|
+
name: str | None = None,
|
413
|
+
modality: str | None = None,
|
414
|
+
model: str | None = None,
|
415
|
+
schema_id: str | None = None,
|
416
|
+
schema_data_id: str | None = None,
|
411
417
|
) -> ListProcessors:
|
412
418
|
request = self.prepare_list(before, after, limit, order, name, modality, model, schema_id, schema_data_id)
|
413
419
|
response = await self._client._prepared_request(request)
|
@@ -421,16 +427,32 @@ class AsyncProcessors(AsyncAPIResource, ProcessorsMixin):
|
|
421
427
|
async def update(
|
422
428
|
self,
|
423
429
|
processor_id: str,
|
424
|
-
name:
|
425
|
-
modality:
|
426
|
-
image_resolution_dpi:
|
427
|
-
browser_canvas:
|
428
|
-
model:
|
429
|
-
json_schema:
|
430
|
-
temperature:
|
431
|
-
reasoning_effort:
|
432
|
-
n_consensus:
|
430
|
+
name: str | None = None,
|
431
|
+
modality: Modality | None = None,
|
432
|
+
image_resolution_dpi: int | None = None,
|
433
|
+
browser_canvas: BrowserCanvas | None = None,
|
434
|
+
model: str | None = None,
|
435
|
+
json_schema: dict[str, Any] | None = None,
|
436
|
+
temperature: float | None = None,
|
437
|
+
reasoning_effort: ChatCompletionReasoningEffort | None = None,
|
438
|
+
n_consensus: int | None = None,
|
433
439
|
) -> ProcessorConfig:
|
440
|
+
"""Update a processor configuration.
|
441
|
+
|
442
|
+
Args:
|
443
|
+
processor_id: ID of the processor to update
|
444
|
+
name: New name for the processor
|
445
|
+
modality: New processing modality
|
446
|
+
image_resolution_dpi: New image resolution DPI
|
447
|
+
browser_canvas: New browser canvas size
|
448
|
+
model: New AI model
|
449
|
+
json_schema: New JSON schema for the processor
|
450
|
+
temperature: New temperature setting
|
451
|
+
reasoning_effort: The effort level for the model to reason about the input data.
|
452
|
+
n_consensus: New number of consensus required
|
453
|
+
Returns:
|
454
|
+
ProcessorConfig: The updated processor configuration
|
455
|
+
"""
|
434
456
|
request = self.prepare_update(processor_id, name, modality, image_resolution_dpi, browser_canvas, model, json_schema, temperature, reasoning_effort, n_consensus)
|
435
457
|
response = await self._client._prepared_request(request)
|
436
458
|
return ProcessorConfig.model_validate(response)
|
@@ -443,10 +465,10 @@ class AsyncProcessors(AsyncAPIResource, ProcessorsMixin):
|
|
443
465
|
async def submit(
|
444
466
|
self,
|
445
467
|
processor_id: str,
|
446
|
-
document:
|
447
|
-
documents:
|
448
|
-
temperature:
|
449
|
-
seed:
|
468
|
+
document: Path | str | bytes | IOBase | MIMEData | PIL.Image.Image | HttpUrl | None = None,
|
469
|
+
documents: List[Path | str | bytes | IOBase | MIMEData | PIL.Image.Image | HttpUrl] | None = None,
|
470
|
+
temperature: float | None = None,
|
471
|
+
seed: int | None = None,
|
450
472
|
store: bool = True,
|
451
473
|
) -> UiParsedChatCompletion:
|
452
474
|
"""Submit documents to a processor for processing.
|
@@ -462,13 +484,6 @@ class AsyncProcessors(AsyncAPIResource, ProcessorsMixin):
|
|
462
484
|
Returns:
|
463
485
|
UiParsedChatCompletion: The processing result
|
464
486
|
"""
|
465
|
-
request = self.prepare_submit(
|
466
|
-
processor_id=processor_id,
|
467
|
-
document=document,
|
468
|
-
documents=documents,
|
469
|
-
temperature=temperature,
|
470
|
-
seed=seed,
|
471
|
-
store=store
|
472
|
-
)
|
487
|
+
request = self.prepare_submit(processor_id=processor_id, document=document, documents=documents, temperature=temperature, seed=seed, store=store)
|
473
488
|
response = await self._client._prepared_request(request)
|
474
489
|
return UiParsedChatCompletion.model_validate(response)
|