retab 0.0.35__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-0.0.35.dist-info/METADATA +417 -0
- retab-0.0.35.dist-info/RECORD +111 -0
- retab-0.0.35.dist-info/WHEEL +5 -0
- retab-0.0.35.dist-info/top_level.txt +1 -0
- uiform/__init__.py +4 -0
- uiform/_resource.py +28 -0
- uiform/_utils/__init__.py +0 -0
- uiform/_utils/ai_models.py +100 -0
- uiform/_utils/benchmarking copy.py +588 -0
- uiform/_utils/benchmarking.py +485 -0
- uiform/_utils/chat.py +332 -0
- uiform/_utils/display.py +443 -0
- uiform/_utils/json_schema.py +2161 -0
- uiform/_utils/mime.py +168 -0
- uiform/_utils/responses.py +163 -0
- uiform/_utils/stream_context_managers.py +52 -0
- uiform/_utils/usage/__init__.py +0 -0
- uiform/_utils/usage/usage.py +300 -0
- uiform/client.py +701 -0
- uiform/py.typed +0 -0
- uiform/resources/__init__.py +0 -0
- uiform/resources/consensus/__init__.py +3 -0
- uiform/resources/consensus/client.py +114 -0
- uiform/resources/consensus/completions.py +252 -0
- uiform/resources/consensus/completions_stream.py +278 -0
- uiform/resources/consensus/responses.py +325 -0
- uiform/resources/consensus/responses_stream.py +373 -0
- uiform/resources/deployments/__init__.py +9 -0
- uiform/resources/deployments/client.py +78 -0
- uiform/resources/deployments/endpoints.py +322 -0
- uiform/resources/deployments/links.py +452 -0
- uiform/resources/deployments/logs.py +211 -0
- uiform/resources/deployments/mailboxes.py +496 -0
- uiform/resources/deployments/outlook.py +531 -0
- uiform/resources/deployments/tests.py +158 -0
- uiform/resources/documents/__init__.py +3 -0
- uiform/resources/documents/client.py +255 -0
- uiform/resources/documents/extractions.py +441 -0
- uiform/resources/evals.py +812 -0
- uiform/resources/files.py +24 -0
- uiform/resources/finetuning.py +62 -0
- uiform/resources/jsonlUtils.py +1046 -0
- uiform/resources/models.py +45 -0
- uiform/resources/openai_example.py +22 -0
- uiform/resources/processors/__init__.py +3 -0
- uiform/resources/processors/automations/__init__.py +9 -0
- uiform/resources/processors/automations/client.py +78 -0
- uiform/resources/processors/automations/endpoints.py +317 -0
- uiform/resources/processors/automations/links.py +356 -0
- uiform/resources/processors/automations/logs.py +211 -0
- uiform/resources/processors/automations/mailboxes.py +435 -0
- uiform/resources/processors/automations/outlook.py +444 -0
- uiform/resources/processors/automations/tests.py +158 -0
- uiform/resources/processors/client.py +474 -0
- uiform/resources/prompt_optimization.py +76 -0
- uiform/resources/schemas.py +369 -0
- uiform/resources/secrets/__init__.py +9 -0
- uiform/resources/secrets/client.py +20 -0
- uiform/resources/secrets/external_api_keys.py +109 -0
- uiform/resources/secrets/webhook.py +62 -0
- uiform/resources/usage.py +271 -0
- uiform/types/__init__.py +0 -0
- uiform/types/ai_models.py +645 -0
- uiform/types/automations/__init__.py +0 -0
- uiform/types/automations/cron.py +58 -0
- uiform/types/automations/endpoints.py +21 -0
- uiform/types/automations/links.py +28 -0
- uiform/types/automations/mailboxes.py +60 -0
- uiform/types/automations/outlook.py +68 -0
- uiform/types/automations/webhooks.py +21 -0
- uiform/types/chat.py +8 -0
- uiform/types/completions.py +93 -0
- uiform/types/consensus.py +10 -0
- uiform/types/db/__init__.py +0 -0
- uiform/types/db/annotations.py +24 -0
- uiform/types/db/files.py +36 -0
- uiform/types/deployments/__init__.py +0 -0
- uiform/types/deployments/cron.py +59 -0
- uiform/types/deployments/endpoints.py +28 -0
- uiform/types/deployments/links.py +36 -0
- uiform/types/deployments/mailboxes.py +67 -0
- uiform/types/deployments/outlook.py +76 -0
- uiform/types/deployments/webhooks.py +21 -0
- uiform/types/documents/__init__.py +0 -0
- uiform/types/documents/correct_orientation.py +13 -0
- uiform/types/documents/create_messages.py +226 -0
- uiform/types/documents/extractions.py +297 -0
- uiform/types/evals.py +207 -0
- uiform/types/events.py +76 -0
- uiform/types/extractions.py +85 -0
- uiform/types/jobs/__init__.py +0 -0
- uiform/types/jobs/base.py +150 -0
- uiform/types/jobs/batch_annotation.py +22 -0
- uiform/types/jobs/evaluation.py +133 -0
- uiform/types/jobs/finetune.py +6 -0
- uiform/types/jobs/prompt_optimization.py +41 -0
- uiform/types/jobs/webcrawl.py +6 -0
- uiform/types/logs.py +231 -0
- uiform/types/mime.py +257 -0
- uiform/types/modalities.py +68 -0
- uiform/types/pagination.py +6 -0
- uiform/types/schemas/__init__.py +0 -0
- uiform/types/schemas/enhance.py +53 -0
- uiform/types/schemas/evaluate.py +55 -0
- uiform/types/schemas/generate.py +32 -0
- uiform/types/schemas/layout.py +58 -0
- uiform/types/schemas/object.py +631 -0
- uiform/types/schemas/templates.py +107 -0
- uiform/types/secrets/__init__.py +0 -0
- uiform/types/secrets/external_api_keys.py +22 -0
- uiform/types/standards.py +39 -0
@@ -0,0 +1,531 @@
|
|
1
|
+
import json
|
2
|
+
from io import IOBase
|
3
|
+
from pathlib import Path
|
4
|
+
from typing import Any, Dict, List, Literal, Optional
|
5
|
+
|
6
|
+
from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
|
7
|
+
from PIL.Image import Image
|
8
|
+
from pydantic import HttpUrl
|
9
|
+
|
10
|
+
from ..._resource import AsyncAPIResource, SyncAPIResource
|
11
|
+
from ..._utils.ai_models import assert_valid_model_extraction
|
12
|
+
from ...types.automations.outlook import FetchParams, ListOutlooks, MatchParams, Outlook, UpdateOutlookRequest
|
13
|
+
from ...types.logs import AutomationLog
|
14
|
+
from ...types.modalities import Modality
|
15
|
+
from ...types.standards import PreparedRequest
|
16
|
+
|
17
|
+
|
18
|
+
class OutlooksMixin:
|
19
|
+
def prepare_create(
|
20
|
+
self,
|
21
|
+
name: str,
|
22
|
+
json_schema: Dict[str, Any],
|
23
|
+
webhook_url: HttpUrl,
|
24
|
+
# email specific opitonals Fields
|
25
|
+
authorized_domains: List[str] = [],
|
26
|
+
authorized_emails: List[str] = [],
|
27
|
+
# HTTP Config Optional Fields
|
28
|
+
webhook_headers: Dict[str, str] = {},
|
29
|
+
# DocumentExtraction Config
|
30
|
+
image_resolution_dpi: Optional[int] = None,
|
31
|
+
browser_canvas: Optional[Literal['A3', 'A4', 'A5']] = None,
|
32
|
+
modality: Modality = "native",
|
33
|
+
model: str = "gpt-4o-mini",
|
34
|
+
temperature: float = 0,
|
35
|
+
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
36
|
+
# Optional Fields for data integration
|
37
|
+
match_params: Optional[List[MatchParams]] = None,
|
38
|
+
fetch_params: Optional[List[FetchParams]] = None,
|
39
|
+
layout_schema: Optional[Dict[str, Any]] = None,
|
40
|
+
) -> PreparedRequest:
|
41
|
+
assert_valid_model_extraction(model)
|
42
|
+
|
43
|
+
data = {
|
44
|
+
"name": name,
|
45
|
+
"webhook_url": webhook_url,
|
46
|
+
"webhook_headers": webhook_headers,
|
47
|
+
"json_schema": json_schema,
|
48
|
+
"authorized_domains": authorized_domains,
|
49
|
+
"authorized_emails": authorized_emails,
|
50
|
+
"image_resolution_dpi": image_resolution_dpi,
|
51
|
+
"browser_canvas": browser_canvas,
|
52
|
+
"modality": modality,
|
53
|
+
"model": model,
|
54
|
+
"temperature": temperature,
|
55
|
+
"reasoning_effort": reasoning_effort,
|
56
|
+
"layout_schema": layout_schema,
|
57
|
+
}
|
58
|
+
|
59
|
+
if match_params is not None:
|
60
|
+
data["match_params"] = match_params
|
61
|
+
if fetch_params is not None:
|
62
|
+
data["fetch_params"] = fetch_params
|
63
|
+
|
64
|
+
# Validate the data
|
65
|
+
outlook_data = Outlook.model_validate(data)
|
66
|
+
return PreparedRequest(method="POST", url="/v1/deployments/outlook", data=outlook_data.model_dump(mode="json"))
|
67
|
+
|
68
|
+
def prepare_list(
|
69
|
+
self,
|
70
|
+
before: str | None = None,
|
71
|
+
after: str | None = None,
|
72
|
+
limit: int = 10,
|
73
|
+
order: Literal["asc", "desc"] | None = "desc",
|
74
|
+
id: Optional[str] = None,
|
75
|
+
name: Optional[str] = None,
|
76
|
+
webhook_url: Optional[str] = None,
|
77
|
+
schema_id: Optional[str] = None,
|
78
|
+
schema_data_id: Optional[str] = None,
|
79
|
+
) -> PreparedRequest:
|
80
|
+
params = {
|
81
|
+
"before": before,
|
82
|
+
"after": after,
|
83
|
+
"limit": limit,
|
84
|
+
"order": order,
|
85
|
+
"id": id,
|
86
|
+
"name": name,
|
87
|
+
"webhook_url": webhook_url,
|
88
|
+
"schema_id": schema_id,
|
89
|
+
"schema_data_id": schema_data_id,
|
90
|
+
}
|
91
|
+
# Remove None values
|
92
|
+
params = {k: v for k, v in params.items() if v is not None}
|
93
|
+
|
94
|
+
return PreparedRequest(method="GET", url="/v1/deployments/outlook", params=params)
|
95
|
+
|
96
|
+
def prepare_get(self, id: str) -> PreparedRequest:
|
97
|
+
return PreparedRequest(method="GET", url=f"/v1/deployments/outlook/{id}")
|
98
|
+
|
99
|
+
def prepare_update(
|
100
|
+
self,
|
101
|
+
id: str,
|
102
|
+
name: Optional[str] = None,
|
103
|
+
webhook_url: Optional[HttpUrl] = None,
|
104
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
105
|
+
authorized_domains: Optional[List[str]] = None,
|
106
|
+
authorized_emails: Optional[List[str]] = None,
|
107
|
+
image_resolution_dpi: Optional[int] = None,
|
108
|
+
browser_canvas: Optional[Literal['A3', 'A4', 'A5']] = None,
|
109
|
+
modality: Optional[Modality] = None,
|
110
|
+
model: Optional[str] = None,
|
111
|
+
temperature: Optional[float] = None,
|
112
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] = None,
|
113
|
+
json_schema: Optional[Dict[str, Any]] = None,
|
114
|
+
match_params: Optional[List[MatchParams]] = None,
|
115
|
+
fetch_params: Optional[List[FetchParams]] = None,
|
116
|
+
layout_schema: Optional[Dict[str, Any]] = None,
|
117
|
+
) -> PreparedRequest:
|
118
|
+
data: dict[str, Any] = {}
|
119
|
+
if name is not None:
|
120
|
+
data["name"] = name
|
121
|
+
if webhook_url is not None:
|
122
|
+
data["webhook_url"] = webhook_url
|
123
|
+
if webhook_headers is not None:
|
124
|
+
data["webhook_headers"] = webhook_headers
|
125
|
+
if authorized_domains is not None:
|
126
|
+
data["authorized_domains"] = authorized_domains
|
127
|
+
if authorized_emails is not None:
|
128
|
+
data["authorized_emails"] = authorized_emails
|
129
|
+
if image_resolution_dpi is not None:
|
130
|
+
data["image_resolution_dpi"] = image_resolution_dpi
|
131
|
+
if browser_canvas is not None:
|
132
|
+
data["browser_canvas"] = browser_canvas
|
133
|
+
if modality is not None:
|
134
|
+
data["modality"] = modality
|
135
|
+
if model is not None:
|
136
|
+
assert_valid_model_extraction(model)
|
137
|
+
data["model"] = model
|
138
|
+
if temperature is not None:
|
139
|
+
data["temperature"] = temperature
|
140
|
+
if json_schema is not None:
|
141
|
+
data["json_schema"] = json_schema
|
142
|
+
if match_params is not None:
|
143
|
+
data["match_params"] = match_params
|
144
|
+
if fetch_params is not None:
|
145
|
+
data["fetch_params"] = fetch_params
|
146
|
+
if reasoning_effort is not None:
|
147
|
+
data["reasoning_effort"] = reasoning_effort
|
148
|
+
if layout_schema is not None:
|
149
|
+
data["layout_schema"] = layout_schema
|
150
|
+
|
151
|
+
update_outlook_request = UpdateOutlookRequest.model_validate(data)
|
152
|
+
|
153
|
+
return PreparedRequest(method="PUT", url=f"/v1/deployments/outlook/{id}", data=update_outlook_request.model_dump(mode="json"))
|
154
|
+
|
155
|
+
def prepare_delete(self, id: str) -> PreparedRequest:
|
156
|
+
return PreparedRequest(method="DELETE", url=f"/v1/deployments/outlook/{id}")
|
157
|
+
|
158
|
+
def prepare_logs(
|
159
|
+
self,
|
160
|
+
before: str | None = None,
|
161
|
+
after: str | None = None,
|
162
|
+
limit: int = 10,
|
163
|
+
order: Literal["asc", "desc"] | None = "desc",
|
164
|
+
id: Optional[str] = None,
|
165
|
+
name: Optional[str] = None,
|
166
|
+
webhook_url: Optional[str] = None,
|
167
|
+
schema_id: Optional[str] = None,
|
168
|
+
schema_data_id: Optional[str] = None,
|
169
|
+
match_params: Optional[List[MatchParams]] = None,
|
170
|
+
fetch_params: Optional[List[FetchParams]] = None,
|
171
|
+
) -> PreparedRequest:
|
172
|
+
params = {
|
173
|
+
"id": id,
|
174
|
+
"name": name,
|
175
|
+
"webhook_url": webhook_url,
|
176
|
+
"schema_id": schema_id,
|
177
|
+
"schema_data_id": schema_data_id,
|
178
|
+
"before": before,
|
179
|
+
"after": after,
|
180
|
+
"limit": limit,
|
181
|
+
"order": order,
|
182
|
+
"match_params": match_params,
|
183
|
+
"fetch_params": fetch_params,
|
184
|
+
}
|
185
|
+
return PreparedRequest(method="GET", url=f"/v1/deployments/outlook/{id}/logs", params=params)
|
186
|
+
|
187
|
+
|
188
|
+
class Outlooks(SyncAPIResource, OutlooksMixin):
|
189
|
+
"""Outlook API wrapper for managing outlook automation configurations"""
|
190
|
+
|
191
|
+
def __init__(self, client: Any) -> None:
|
192
|
+
super().__init__(client=client)
|
193
|
+
|
194
|
+
def create(
|
195
|
+
self,
|
196
|
+
name: str,
|
197
|
+
json_schema: Dict[str, Any],
|
198
|
+
webhook_url: HttpUrl,
|
199
|
+
authorized_domains: List[str] = [],
|
200
|
+
authorized_emails: List[str] = [],
|
201
|
+
webhook_headers: Dict[str, str] = {},
|
202
|
+
image_resolution_dpi: Optional[int] = None,
|
203
|
+
browser_canvas: Optional[Literal['A3', 'A4', 'A5']] = None,
|
204
|
+
modality: Modality = "native",
|
205
|
+
model: str = "gpt-4o-mini",
|
206
|
+
temperature: float = 0,
|
207
|
+
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
208
|
+
match_params: Optional[List[MatchParams]] = None,
|
209
|
+
fetch_params: Optional[List[FetchParams]] = None,
|
210
|
+
) -> Outlook:
|
211
|
+
"""Create a new outlook automation configuration.
|
212
|
+
|
213
|
+
Args:
|
214
|
+
name: Name of the outlook plugin
|
215
|
+
json_schema: JSON schema to validate extracted data
|
216
|
+
webhook_url: Webhook URL to receive processed data
|
217
|
+
webhook_headers: Webhook headers to send with processed data
|
218
|
+
authorized_domains: List of authorized domains
|
219
|
+
authorized_emails: List of authorized emails
|
220
|
+
image_resolution_dpi: Optional image resolution DPI
|
221
|
+
browser_canvas: Optional browser canvas size
|
222
|
+
modality: Processing modality (currently only "native" supported)
|
223
|
+
model: AI model to use for processing
|
224
|
+
temperature: Model temperature setting
|
225
|
+
reasoning_effort: The effort level for the model to reason about the input data.
|
226
|
+
match_params: List of match parameters for the outlook automation
|
227
|
+
fetch_params: List of fetch parameters for the outlook automation
|
228
|
+
Returns:
|
229
|
+
Outlook: The created outlook plugin configuration
|
230
|
+
"""
|
231
|
+
|
232
|
+
request = self.prepare_create(
|
233
|
+
name,
|
234
|
+
json_schema,
|
235
|
+
webhook_url,
|
236
|
+
authorized_domains,
|
237
|
+
authorized_emails,
|
238
|
+
webhook_headers,
|
239
|
+
image_resolution_dpi,
|
240
|
+
browser_canvas,
|
241
|
+
modality,
|
242
|
+
model,
|
243
|
+
temperature,
|
244
|
+
reasoning_effort,
|
245
|
+
match_params,
|
246
|
+
fetch_params,
|
247
|
+
)
|
248
|
+
response = self._client._prepared_request(request)
|
249
|
+
|
250
|
+
print(f"Outlook automation created. Outlook available at https://www.uiform.com/dashboard/processors/{response['id']}")
|
251
|
+
|
252
|
+
return Outlook.model_validate(response)
|
253
|
+
|
254
|
+
def list(
|
255
|
+
self,
|
256
|
+
before: str | None = None,
|
257
|
+
after: str | None = None,
|
258
|
+
limit: int = 10,
|
259
|
+
order: Literal["asc", "desc"] | None = "desc",
|
260
|
+
id: Optional[str] = None,
|
261
|
+
name: Optional[str] = None,
|
262
|
+
webhook_url: Optional[str] = None,
|
263
|
+
schema_id: Optional[str] = None,
|
264
|
+
schema_data_id: Optional[str] = None,
|
265
|
+
) -> ListOutlooks:
|
266
|
+
"""List all outlook automation configurations.
|
267
|
+
|
268
|
+
Args:
|
269
|
+
before: Optional cursor for pagination - get results before this log ID
|
270
|
+
after: Optional cursor for pagination - get results after this log ID
|
271
|
+
limit: Maximum number of logs to return (1-100, default 10)
|
272
|
+
order: Sort order by creation time - "asc" or "desc" (default "desc")
|
273
|
+
id: Optional ID filter
|
274
|
+
name: Optional name filter
|
275
|
+
webhook_url: Optional webhook URL filter
|
276
|
+
schema_id: Optional schema ID filter
|
277
|
+
schema_data_id: Optional schema data ID filter
|
278
|
+
match_params: Optional list of match parameters for the outlook automation
|
279
|
+
fetch_params: Optional list of fetch parameters for the outlook automation
|
280
|
+
Returns:
|
281
|
+
List[Outlook]: List of outlook plugin configurations
|
282
|
+
"""
|
283
|
+
request = self.prepare_list(before, after, limit, order, id, name, webhook_url, schema_id, schema_data_id)
|
284
|
+
response = self._client._prepared_request(request)
|
285
|
+
return ListOutlooks.model_validate(response)
|
286
|
+
|
287
|
+
def get(self, id: str) -> Outlook:
|
288
|
+
"""Get a specific outlook automation configuration.
|
289
|
+
|
290
|
+
Args:
|
291
|
+
id: ID of the outlook plugin
|
292
|
+
|
293
|
+
Returns:
|
294
|
+
Outlook: The outlook plugin configuration
|
295
|
+
"""
|
296
|
+
request = self.prepare_get(id)
|
297
|
+
response = self._client._prepared_request(request)
|
298
|
+
return Outlook.model_validate(response)
|
299
|
+
|
300
|
+
def update(
|
301
|
+
self,
|
302
|
+
id: str,
|
303
|
+
name: Optional[str] = None,
|
304
|
+
webhook_url: Optional[HttpUrl] = None,
|
305
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
306
|
+
authorized_domains: Optional[List[str]] = None,
|
307
|
+
authorized_emails: Optional[List[str]] = None,
|
308
|
+
image_resolution_dpi: Optional[int] = None,
|
309
|
+
browser_canvas: Optional[Literal['A3', 'A4', 'A5']] = None,
|
310
|
+
modality: Optional[Modality] = None,
|
311
|
+
model: Optional[str] = None,
|
312
|
+
temperature: Optional[float] = None,
|
313
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] = None,
|
314
|
+
json_schema: Optional[Dict[str, Any]] = None,
|
315
|
+
match_params: Optional[List[MatchParams]] = None,
|
316
|
+
fetch_params: Optional[List[FetchParams]] = None,
|
317
|
+
layout_schema: Optional[Dict[str, Any]] = None,
|
318
|
+
) -> Outlook:
|
319
|
+
"""Update an outlook automation configuration.
|
320
|
+
|
321
|
+
Args:
|
322
|
+
id: ID of the outlook plugin to update
|
323
|
+
name: New name for the outlook plugin
|
324
|
+
webhook_url: New webhook URL
|
325
|
+
webhook_headers: New webhook headers
|
326
|
+
authorized_domains: New authorized domains
|
327
|
+
authorized_emails: New authorized emails
|
328
|
+
image_resolution_dpi: New image resolution DPI
|
329
|
+
browser_canvas: New browser canvas size
|
330
|
+
modality: New processing modality
|
331
|
+
model: New AI model
|
332
|
+
temperature: New temperature setting
|
333
|
+
reasoning_effort: New reasoning effort
|
334
|
+
json_schema: New JSON schema
|
335
|
+
match_params: New match parameters for the outlook automation
|
336
|
+
fetch_params: New fetch parameters for the outlook automation
|
337
|
+
layout_schema: New layout schema for the outlook automation
|
338
|
+
|
339
|
+
Returns:
|
340
|
+
Outlook: The updated outlook plugin configuration
|
341
|
+
"""
|
342
|
+
request = self.prepare_update(
|
343
|
+
id,
|
344
|
+
name,
|
345
|
+
webhook_url,
|
346
|
+
webhook_headers,
|
347
|
+
authorized_domains,
|
348
|
+
authorized_emails,
|
349
|
+
image_resolution_dpi,
|
350
|
+
browser_canvas,
|
351
|
+
modality,
|
352
|
+
model,
|
353
|
+
temperature,
|
354
|
+
reasoning_effort,
|
355
|
+
json_schema,
|
356
|
+
match_params,
|
357
|
+
fetch_params,
|
358
|
+
layout_schema,
|
359
|
+
)
|
360
|
+
response = self._client._prepared_request(request)
|
361
|
+
return Outlook.model_validate(response)
|
362
|
+
|
363
|
+
def delete(self, id: str) -> None:
|
364
|
+
"""Delete an outlook automation configuration.
|
365
|
+
|
366
|
+
Args:
|
367
|
+
id: ID of the outlook plugin to delete
|
368
|
+
"""
|
369
|
+
request = self.prepare_delete(id)
|
370
|
+
response = self._client._prepared_request(request)
|
371
|
+
return None
|
372
|
+
|
373
|
+
def logs(
|
374
|
+
self,
|
375
|
+
before: str | None = None,
|
376
|
+
after: str | None = None,
|
377
|
+
limit: int = 10,
|
378
|
+
order: Literal["asc", "desc"] | None = "desc",
|
379
|
+
id: Optional[str] = None,
|
380
|
+
name: Optional[str] = None,
|
381
|
+
webhook_url: Optional[str] = None,
|
382
|
+
schema_id: Optional[str] = None,
|
383
|
+
schema_data_id: Optional[str] = None,
|
384
|
+
match_params: Optional[List[MatchParams]] = None,
|
385
|
+
fetch_params: Optional[List[FetchParams]] = None,
|
386
|
+
) -> List[AutomationLog]:
|
387
|
+
"""Get logs for a specific outlook automation.
|
388
|
+
|
389
|
+
Args:
|
390
|
+
before: Optional cursor for pagination - get results before this log ID
|
391
|
+
after: Optional cursor for pagination - get results after this log ID
|
392
|
+
limit: Maximum number of logs to return (1-100, default 10)
|
393
|
+
order: Sort order by creation time - "asc" or "desc" (default "desc")
|
394
|
+
id: Optional ID filter
|
395
|
+
webhook_url: Optional webhook URL filter
|
396
|
+
schema_id: Optional schema ID filter
|
397
|
+
schema_data_id: Optional schema data ID filter
|
398
|
+
match_params: Optional list of match parameters for the outlook automation
|
399
|
+
fetch_params: Optional list of fetch parameters for the outlook automation
|
400
|
+
Returns:
|
401
|
+
List[Dict[str, Any]]: List of log entries
|
402
|
+
"""
|
403
|
+
request = self.prepare_logs(before, after, limit, order, id, name, webhook_url, schema_id, schema_data_id, match_params, fetch_params)
|
404
|
+
response = self._client._prepared_request(request)
|
405
|
+
return [AutomationLog.model_validate(log) for log in response]
|
406
|
+
|
407
|
+
|
408
|
+
class AsyncOutlooks(AsyncAPIResource, OutlooksMixin):
|
409
|
+
def __init__(self, client: Any) -> None:
|
410
|
+
super().__init__(client=client)
|
411
|
+
|
412
|
+
async def create(
|
413
|
+
self,
|
414
|
+
name: str,
|
415
|
+
json_schema: Dict[str, Any],
|
416
|
+
webhook_url: HttpUrl,
|
417
|
+
authorized_domains: List[str] = [],
|
418
|
+
authorized_emails: List[str] = [],
|
419
|
+
webhook_headers: Dict[str, str] = {},
|
420
|
+
image_resolution_dpi: Optional[int] = None,
|
421
|
+
browser_canvas: Optional[Literal['A3', 'A4', 'A5']] = None,
|
422
|
+
modality: Modality = "native",
|
423
|
+
model: str = "gpt-4o-mini",
|
424
|
+
temperature: float = 0,
|
425
|
+
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
426
|
+
match_params: List[MatchParams] = [],
|
427
|
+
fetch_params: List[FetchParams] = [],
|
428
|
+
) -> Outlook:
|
429
|
+
request = self.prepare_create(
|
430
|
+
name,
|
431
|
+
json_schema,
|
432
|
+
webhook_url,
|
433
|
+
authorized_domains,
|
434
|
+
authorized_emails,
|
435
|
+
webhook_headers,
|
436
|
+
image_resolution_dpi,
|
437
|
+
browser_canvas,
|
438
|
+
modality,
|
439
|
+
model,
|
440
|
+
temperature,
|
441
|
+
reasoning_effort,
|
442
|
+
match_params,
|
443
|
+
fetch_params,
|
444
|
+
)
|
445
|
+
response = await self._client._prepared_request(request)
|
446
|
+
print(f"Outlook automation created. Outlook available at https://www.uiform.com/dashboard/processors/{response['id']}")
|
447
|
+
return Outlook.model_validate(response)
|
448
|
+
|
449
|
+
async def list(
|
450
|
+
self,
|
451
|
+
before: str | None = None,
|
452
|
+
after: str | None = None,
|
453
|
+
limit: int = 10,
|
454
|
+
order: Literal["asc", "desc"] | None = "desc",
|
455
|
+
id: Optional[str] = None,
|
456
|
+
name: Optional[str] = None,
|
457
|
+
webhook_url: Optional[str] = None,
|
458
|
+
schema_id: Optional[str] = None,
|
459
|
+
schema_data_id: Optional[str] = None,
|
460
|
+
) -> ListOutlooks:
|
461
|
+
request = self.prepare_list(before, after, limit, order, id, name, webhook_url, schema_id, schema_data_id)
|
462
|
+
response = await self._client._prepared_request(request)
|
463
|
+
return ListOutlooks.model_validate(response)
|
464
|
+
|
465
|
+
async def get(self, id: str) -> Outlook:
|
466
|
+
request = self.prepare_get(id)
|
467
|
+
response = await self._client._prepared_request(request)
|
468
|
+
return Outlook.model_validate(response)
|
469
|
+
|
470
|
+
async def update(
|
471
|
+
self,
|
472
|
+
id: str,
|
473
|
+
name: Optional[str] = None,
|
474
|
+
webhook_url: Optional[HttpUrl] = None,
|
475
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
476
|
+
authorized_domains: Optional[List[str]] = None,
|
477
|
+
authorized_emails: Optional[List[str]] = None,
|
478
|
+
image_resolution_dpi: Optional[int] = None,
|
479
|
+
browser_canvas: Optional[Literal['A3', 'A4', 'A5']] = None,
|
480
|
+
modality: Optional[Modality] = None,
|
481
|
+
model: Optional[str] = None,
|
482
|
+
temperature: Optional[float] = None,
|
483
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] = None,
|
484
|
+
json_schema: Optional[Dict[str, Any]] = None,
|
485
|
+
match_params: Optional[List[MatchParams]] = None,
|
486
|
+
fetch_params: Optional[List[FetchParams]] = None,
|
487
|
+
layout_schema: Optional[Dict[str, Any]] = None,
|
488
|
+
) -> Outlook:
|
489
|
+
request = self.prepare_update(
|
490
|
+
id,
|
491
|
+
name,
|
492
|
+
webhook_url,
|
493
|
+
webhook_headers,
|
494
|
+
authorized_domains,
|
495
|
+
authorized_emails,
|
496
|
+
image_resolution_dpi,
|
497
|
+
browser_canvas,
|
498
|
+
modality,
|
499
|
+
model,
|
500
|
+
temperature,
|
501
|
+
reasoning_effort,
|
502
|
+
json_schema,
|
503
|
+
match_params,
|
504
|
+
fetch_params,
|
505
|
+
layout_schema,
|
506
|
+
)
|
507
|
+
response = await self._client._prepared_request(request)
|
508
|
+
return Outlook.model_validate(response)
|
509
|
+
|
510
|
+
async def delete(self, id: str) -> None:
|
511
|
+
request = self.prepare_delete(id)
|
512
|
+
await self._client._prepared_request(request)
|
513
|
+
return None
|
514
|
+
|
515
|
+
async def logs(
|
516
|
+
self,
|
517
|
+
before: str | None = None,
|
518
|
+
after: str | None = None,
|
519
|
+
limit: int = 10,
|
520
|
+
order: Literal["asc", "desc"] | None = "desc",
|
521
|
+
id: Optional[str] = None,
|
522
|
+
name: Optional[str] = None,
|
523
|
+
webhook_url: Optional[str] = None,
|
524
|
+
schema_id: Optional[str] = None,
|
525
|
+
schema_data_id: Optional[str] = None,
|
526
|
+
match_params: Optional[List[MatchParams]] = None,
|
527
|
+
fetch_params: Optional[List[FetchParams]] = None,
|
528
|
+
) -> List[AutomationLog]:
|
529
|
+
request = self.prepare_logs(before, after, limit, order, id, name, webhook_url, schema_id, schema_data_id, match_params, fetch_params)
|
530
|
+
response = await self._client._prepared_request(request)
|
531
|
+
return [AutomationLog.model_validate(log) for log in response]
|
@@ -0,0 +1,158 @@
|
|
1
|
+
import datetime
|
2
|
+
import json
|
3
|
+
from io import IOBase
|
4
|
+
from pathlib import Path
|
5
|
+
from typing import Any, Dict, Literal, Optional
|
6
|
+
|
7
|
+
import httpx
|
8
|
+
from pydantic import HttpUrl
|
9
|
+
from PIL.Image import Image
|
10
|
+
|
11
|
+
from ..._resource import AsyncAPIResource, SyncAPIResource
|
12
|
+
from ..._utils.mime import prepare_mime_document
|
13
|
+
from ...types.mime import BaseMIMEData, MIMEData
|
14
|
+
from ...types.logs import AutomationLog
|
15
|
+
from ...types.standards import PreparedRequest
|
16
|
+
|
17
|
+
|
18
|
+
class TestsMixin:
|
19
|
+
def prepare_upload(self, id: str, document: Path | str | IOBase | HttpUrl | Image | MIMEData) -> PreparedRequest:
|
20
|
+
mime_document = prepare_mime_document(document)
|
21
|
+
return PreparedRequest(method="POST", url=f"/v1/deployments/tests/upload/{id}", data={"document": mime_document.model_dump(mode='json')})
|
22
|
+
|
23
|
+
def prepare_webhook(self, id: str) -> PreparedRequest:
|
24
|
+
return PreparedRequest(method="POST", url=f"/v1/deployments/tests/webhook/{id}", data=None)
|
25
|
+
|
26
|
+
def print_upload_verbose(self, log: AutomationLog) -> None:
|
27
|
+
if log.external_request_log:
|
28
|
+
print(f"\nTEST FILE UPLOAD RESULTS:")
|
29
|
+
print(f"\n#########################")
|
30
|
+
print(f"Status Code: {log.external_request_log.status_code}")
|
31
|
+
print(f"Duration: {log.external_request_log.duration_ms:.2f}ms")
|
32
|
+
|
33
|
+
if log.external_request_log.error:
|
34
|
+
print(f"\nERROR: {log.external_request_log.error}")
|
35
|
+
|
36
|
+
if log.external_request_log.response_body:
|
37
|
+
print("\n--------------")
|
38
|
+
print("RESPONSE BODY:")
|
39
|
+
print("--------------")
|
40
|
+
print(json.dumps(log.external_request_log.response_body, indent=2))
|
41
|
+
|
42
|
+
if log.external_request_log.response_headers:
|
43
|
+
print("\n--------------")
|
44
|
+
print("RESPONSE HEADERS:")
|
45
|
+
print("--------------")
|
46
|
+
print(json.dumps(log.external_request_log.response_headers, indent=2))
|
47
|
+
|
48
|
+
def print_webhook_verbose(self, log: AutomationLog) -> None:
|
49
|
+
if log.external_request_log:
|
50
|
+
print(f"\nTEST WEBHOOK RESULTS:")
|
51
|
+
print(f"\n#########################")
|
52
|
+
print(f"Status Code: {log.external_request_log.status_code}")
|
53
|
+
print(f"Duration: {log.external_request_log.duration_ms:.2f}ms")
|
54
|
+
|
55
|
+
if log.external_request_log.error:
|
56
|
+
print(f"\nERROR: {log.external_request_log.error}")
|
57
|
+
|
58
|
+
if log.external_request_log.response_body:
|
59
|
+
print("\n--------------")
|
60
|
+
print("RESPONSE BODY:")
|
61
|
+
print("--------------")
|
62
|
+
print(json.dumps(log.external_request_log.response_body, indent=2))
|
63
|
+
|
64
|
+
if log.external_request_log.response_headers:
|
65
|
+
print("\n--------------")
|
66
|
+
print("RESPONSE HEADERS:")
|
67
|
+
print("--------------")
|
68
|
+
print(json.dumps(log.external_request_log.response_headers, indent=2))
|
69
|
+
|
70
|
+
|
71
|
+
class Tests(SyncAPIResource, TestsMixin):
|
72
|
+
"""Test API wrapper for testing automation configurations"""
|
73
|
+
|
74
|
+
def upload(self, id: str, document: Path | str | IOBase | HttpUrl | Image | MIMEData, verbose: bool = True) -> AutomationLog:
|
75
|
+
"""Test endpoint that simulates the complete extraction process with the provided document.
|
76
|
+
|
77
|
+
Args:
|
78
|
+
id: ID of the deployment to test
|
79
|
+
document: Document to process
|
80
|
+
verbose: Whether to print verbose output
|
81
|
+
|
82
|
+
Returns:
|
83
|
+
AutomationLog: The automation log with extraction results
|
84
|
+
"""
|
85
|
+
request = self.prepare_upload(id, document)
|
86
|
+
response = self._client._prepared_request(request)
|
87
|
+
|
88
|
+
log = AutomationLog.model_validate(response)
|
89
|
+
|
90
|
+
if verbose:
|
91
|
+
self.print_upload_verbose(log)
|
92
|
+
|
93
|
+
return log
|
94
|
+
|
95
|
+
def webhook(self, id: str, verbose: bool = True) -> AutomationLog:
|
96
|
+
"""Test endpoint that simulates the complete webhook process with sample data.
|
97
|
+
|
98
|
+
Args:
|
99
|
+
id: ID of the deployment to test
|
100
|
+
verbose: Whether to print verbose output
|
101
|
+
|
102
|
+
Returns:
|
103
|
+
AutomationLog: The automation log with webhook results
|
104
|
+
"""
|
105
|
+
request = self.prepare_webhook(id)
|
106
|
+
response = self._client._prepared_request(request)
|
107
|
+
|
108
|
+
log = AutomationLog.model_validate(response)
|
109
|
+
|
110
|
+
if verbose:
|
111
|
+
self.print_webhook_verbose(log)
|
112
|
+
|
113
|
+
return log
|
114
|
+
|
115
|
+
|
116
|
+
class AsyncTests(AsyncAPIResource, TestsMixin):
|
117
|
+
"""Async Test API wrapper for testing deployment configurations"""
|
118
|
+
|
119
|
+
async def upload(self, id: str, document: Path | str | IOBase | HttpUrl | Image | MIMEData, verbose: bool = True) -> AutomationLog:
|
120
|
+
"""Test endpoint that simulates the complete extraction process with the provided document.
|
121
|
+
|
122
|
+
Args:
|
123
|
+
id: ID of the deployment to test
|
124
|
+
document: Document to process
|
125
|
+
verbose: Whether to print verbose output
|
126
|
+
|
127
|
+
Returns:
|
128
|
+
AutomationLog: The automation log with extraction results
|
129
|
+
"""
|
130
|
+
request = self.prepare_upload(id, document)
|
131
|
+
response = await self._client._prepared_request(request)
|
132
|
+
|
133
|
+
log = AutomationLog.model_validate(response)
|
134
|
+
|
135
|
+
if verbose:
|
136
|
+
self.print_upload_verbose(log)
|
137
|
+
|
138
|
+
return log
|
139
|
+
|
140
|
+
async def webhook(self, id: str, verbose: bool = True) -> AutomationLog:
|
141
|
+
"""Test endpoint that simulates the complete webhook process with sample data.
|
142
|
+
|
143
|
+
Args:
|
144
|
+
id: ID of the deployment to test
|
145
|
+
verbose: Whether to print verbose output
|
146
|
+
|
147
|
+
Returns:
|
148
|
+
AutomationLog: The automation log with webhook results
|
149
|
+
"""
|
150
|
+
request = self.prepare_webhook(id)
|
151
|
+
response = await self._client._prepared_request(request)
|
152
|
+
|
153
|
+
log = AutomationLog.model_validate(response)
|
154
|
+
|
155
|
+
if verbose:
|
156
|
+
self.print_webhook_verbose(log)
|
157
|
+
|
158
|
+
return log
|