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,452 @@
|
|
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 openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
|
9
|
+
from PIL.Image import Image
|
10
|
+
from pydantic import HttpUrl
|
11
|
+
|
12
|
+
from ..._resource import AsyncAPIResource, SyncAPIResource
|
13
|
+
from ..._utils.ai_models import assert_valid_model_extraction
|
14
|
+
from ..._utils.mime import prepare_mime_document
|
15
|
+
from ...types.automations.links import Link, ListLinks, UpdateLinkRequest
|
16
|
+
from ...types.documents.extractions import UiParsedChatCompletion
|
17
|
+
from ...types.logs import AutomationLog, ExternalRequestLog, ListLogs
|
18
|
+
from ...types.mime import BaseMIMEData, MIMEData
|
19
|
+
from ...types.modalities import Modality
|
20
|
+
from ...types.standards import PreparedRequest
|
21
|
+
|
22
|
+
|
23
|
+
class LinksMixin:
|
24
|
+
def prepare_create(
|
25
|
+
self,
|
26
|
+
name: str,
|
27
|
+
json_schema: Dict[str, Any],
|
28
|
+
webhook_url: HttpUrl,
|
29
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
30
|
+
password: str | None = None,
|
31
|
+
# DocumentExtraction Config
|
32
|
+
image_resolution_dpi: Optional[int] = None,
|
33
|
+
browser_canvas: Optional[str] = None,
|
34
|
+
modality: Modality = "native",
|
35
|
+
model: str = "gpt-4o-mini",
|
36
|
+
temperature: float = 0,
|
37
|
+
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
38
|
+
) -> PreparedRequest:
|
39
|
+
assert_valid_model_extraction(model)
|
40
|
+
|
41
|
+
data = {
|
42
|
+
"name": name,
|
43
|
+
"webhook_url": webhook_url,
|
44
|
+
"webhook_headers": webhook_headers or {},
|
45
|
+
"json_schema": json_schema,
|
46
|
+
"password": password,
|
47
|
+
"image_resolution_dpi": image_resolution_dpi,
|
48
|
+
"browser_canvas": browser_canvas,
|
49
|
+
"modality": modality,
|
50
|
+
"model": model,
|
51
|
+
"temperature": temperature,
|
52
|
+
"reasoning_effort": reasoning_effort,
|
53
|
+
}
|
54
|
+
|
55
|
+
request = Link.model_validate(data)
|
56
|
+
return PreparedRequest(method="POST", url="/v1/deployments/links", data=request.model_dump(mode='json'))
|
57
|
+
|
58
|
+
def prepare_list(
|
59
|
+
self,
|
60
|
+
before: Optional[str] = None,
|
61
|
+
after: Optional[str] = None,
|
62
|
+
limit: Optional[int] = 10,
|
63
|
+
order: Optional[Literal["asc", "desc"]] = "desc",
|
64
|
+
# Filtering parameters
|
65
|
+
link_id: Optional[str] = None,
|
66
|
+
name: Optional[str] = None,
|
67
|
+
webhook_url: Optional[str] = None,
|
68
|
+
schema_id: Optional[str] = None,
|
69
|
+
schema_data_id: Optional[str] = None,
|
70
|
+
) -> PreparedRequest:
|
71
|
+
params = {
|
72
|
+
"before": before,
|
73
|
+
"after": after,
|
74
|
+
"limit": limit,
|
75
|
+
"order": order,
|
76
|
+
"automation_id": link_id,
|
77
|
+
"name": name,
|
78
|
+
"webhook_url": webhook_url,
|
79
|
+
"schema_id": schema_id,
|
80
|
+
"schema_data_id": schema_data_id,
|
81
|
+
}
|
82
|
+
# Remove None values
|
83
|
+
params = {k: v for k, v in params.items() if v is not None}
|
84
|
+
|
85
|
+
return PreparedRequest(method="GET", url="/v1/deployments", params=params)
|
86
|
+
|
87
|
+
def prepare_get(self, link_id: str) -> PreparedRequest:
|
88
|
+
"""Get a specific extraction link configuration.
|
89
|
+
|
90
|
+
Args:
|
91
|
+
link_id: ID of the extraction link
|
92
|
+
|
93
|
+
Returns:
|
94
|
+
Link: The extraction link configuration
|
95
|
+
"""
|
96
|
+
return PreparedRequest(method="GET", url=f"/v1/deployments/{link_id}")
|
97
|
+
|
98
|
+
def prepare_update(
|
99
|
+
self,
|
100
|
+
link_id: str,
|
101
|
+
name: Optional[str] = None,
|
102
|
+
webhook_url: Optional[HttpUrl] = None,
|
103
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
104
|
+
password: Optional[str] = None,
|
105
|
+
image_resolution_dpi: Optional[int] = None,
|
106
|
+
browser_canvas: Optional[str] = None,
|
107
|
+
modality: Optional[Modality] = None,
|
108
|
+
model: Optional[str] = None,
|
109
|
+
temperature: Optional[float] = None,
|
110
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] = None,
|
111
|
+
json_schema: Optional[Dict[str, Any]] = None,
|
112
|
+
) -> PreparedRequest:
|
113
|
+
data: dict[str, Any] = {}
|
114
|
+
|
115
|
+
if link_id is not None:
|
116
|
+
data["id"] = link_id
|
117
|
+
if name is not None:
|
118
|
+
data["name"] = name
|
119
|
+
if webhook_url is not None:
|
120
|
+
data["webhook_url"] = webhook_url
|
121
|
+
if webhook_headers is not None:
|
122
|
+
data["webhook_headers"] = webhook_headers
|
123
|
+
if password is not None:
|
124
|
+
data["password"] = password
|
125
|
+
if image_resolution_dpi is not None:
|
126
|
+
data["image_resolution_dpi"] = image_resolution_dpi
|
127
|
+
if browser_canvas is not None:
|
128
|
+
data["browser_canvas"] = browser_canvas
|
129
|
+
if modality is not None:
|
130
|
+
data["modality"] = modality
|
131
|
+
if model is not None:
|
132
|
+
assert_valid_model_extraction(model)
|
133
|
+
data["model"] = model
|
134
|
+
if temperature is not None:
|
135
|
+
data["temperature"] = temperature
|
136
|
+
if json_schema is not None:
|
137
|
+
data["json_schema"] = json_schema
|
138
|
+
if reasoning_effort is not None:
|
139
|
+
data["reasoning_effort"] = reasoning_effort
|
140
|
+
|
141
|
+
request = UpdateLinkRequest.model_validate(data)
|
142
|
+
return PreparedRequest(method="PUT", url=f"/v1/deployments/{link_id}", data=request.model_dump(mode='json'))
|
143
|
+
|
144
|
+
def prepare_delete(self, link_id: str) -> PreparedRequest:
|
145
|
+
return PreparedRequest(method="DELETE", url=f"/v1/deployments/links/{link_id}", raise_for_status=True)
|
146
|
+
|
147
|
+
def prepare_logs(
|
148
|
+
self,
|
149
|
+
before: str | None = None,
|
150
|
+
after: str | None = None,
|
151
|
+
limit: int = 10,
|
152
|
+
order: Literal["asc", "desc"] | None = "desc",
|
153
|
+
# Filtering parameters
|
154
|
+
link_id: Optional[str] = None,
|
155
|
+
name: Optional[str] = None,
|
156
|
+
webhook_url: Optional[str] = None,
|
157
|
+
schema_id: Optional[str] = None,
|
158
|
+
schema_data_id: Optional[str] = None,
|
159
|
+
) -> PreparedRequest:
|
160
|
+
"""Get logs for extraction links with pagination support.
|
161
|
+
|
162
|
+
Args:
|
163
|
+
before: Optional cursor for pagination - get results before this log ID
|
164
|
+
after: Optional cursor for pagination - get results after this log ID
|
165
|
+
limit: Maximum number of logs to return (1-100, default 10)
|
166
|
+
order: Sort order by creation time - "asc" or "desc" (default "desc")
|
167
|
+
link_id: Optional ID of a specific extraction link to filter logs for
|
168
|
+
name: Optional filter by link name
|
169
|
+
webhook_url: Optional filter by webhook URL
|
170
|
+
schema_id: Optional filter by schema ID
|
171
|
+
schema_data_id: Optional filter by schema data ID
|
172
|
+
|
173
|
+
Returns:
|
174
|
+
ListLinkLogsResponse: Paginated list of logs and metadata
|
175
|
+
"""
|
176
|
+
params = {
|
177
|
+
"automation_id": link_id,
|
178
|
+
"name": name,
|
179
|
+
"webhook_url": webhook_url,
|
180
|
+
"schema_id": schema_id,
|
181
|
+
"schema_data_id": schema_data_id,
|
182
|
+
"before": before,
|
183
|
+
"after": after,
|
184
|
+
"limit": limit,
|
185
|
+
"order": order,
|
186
|
+
}
|
187
|
+
# Remove None values
|
188
|
+
params = {k: v for k, v in params.items() if v is not None}
|
189
|
+
|
190
|
+
return PreparedRequest(method="GET", url="/v1/deployments/logs", params=params)
|
191
|
+
|
192
|
+
|
193
|
+
class Links(SyncAPIResource, LinksMixin):
|
194
|
+
"""Extraction Link API wrapper for managing extraction link configurations"""
|
195
|
+
|
196
|
+
def __init__(self, client: Any) -> None:
|
197
|
+
super().__init__(client=client)
|
198
|
+
|
199
|
+
def create(
|
200
|
+
self,
|
201
|
+
name: str,
|
202
|
+
json_schema: Dict[str, Any],
|
203
|
+
webhook_url: HttpUrl,
|
204
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
205
|
+
password: str | None = None,
|
206
|
+
# DocumentExtraction Config
|
207
|
+
image_resolution_dpi: Optional[int] = None,
|
208
|
+
browser_canvas: Optional[str] = None,
|
209
|
+
modality: Modality = "native",
|
210
|
+
model: str = "gpt-4o-mini",
|
211
|
+
temperature: float = 0,
|
212
|
+
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
213
|
+
) -> Link:
|
214
|
+
"""Create a new extraction link configuration.
|
215
|
+
|
216
|
+
Args:
|
217
|
+
name: Name of the extraction link
|
218
|
+
json_schema: JSON schema to validate extracted data
|
219
|
+
webhook_url: Webhook endpoint for forwarding processed files
|
220
|
+
webhook_headers: Optional HTTP headers for webhook requests
|
221
|
+
password: Optional password for protected links
|
222
|
+
image_resolution_dpi: Optional image resolution DPI
|
223
|
+
browser_canvas: Optional browser canvas
|
224
|
+
modality: Processing modality (currently only "native" supported)
|
225
|
+
model: AI model to use for processing
|
226
|
+
temperature: Model temperature setting
|
227
|
+
reasoning_effort: The effort level for the model to reason about the input data.
|
228
|
+
Returns:
|
229
|
+
Link: The created extraction link configuration
|
230
|
+
"""
|
231
|
+
|
232
|
+
request = self.prepare_create(name, json_schema, webhook_url, webhook_headers, password, image_resolution_dpi, browser_canvas, modality, model, temperature, reasoning_effort)
|
233
|
+
response = self._client._prepared_request(request)
|
234
|
+
|
235
|
+
print(f"Extraction Link Created. Link available at https://www.uiform.com/dashboard/processors/{response['id']}")
|
236
|
+
return Link.model_validate(response)
|
237
|
+
|
238
|
+
def list(
|
239
|
+
self,
|
240
|
+
before: Optional[str] = None,
|
241
|
+
after: Optional[str] = None,
|
242
|
+
limit: Optional[int] = 10,
|
243
|
+
order: Optional[Literal["asc", "desc"]] = "desc",
|
244
|
+
# Filtering parameters
|
245
|
+
link_id: Optional[str] = None,
|
246
|
+
name: Optional[str] = None,
|
247
|
+
webhook_url: Optional[str] = None,
|
248
|
+
schema_id: Optional[str] = None,
|
249
|
+
schema_data_id: Optional[str] = None,
|
250
|
+
) -> ListLinks:
|
251
|
+
"""List extraction link configurations with pagination support.
|
252
|
+
|
253
|
+
Args:
|
254
|
+
before: Optional cursor for pagination before a specific link ID
|
255
|
+
after: Optional cursor for pagination after a specific link ID
|
256
|
+
limit: Optional limit on number of results (max 100)
|
257
|
+
order: Optional sort order ("asc" or "desc")
|
258
|
+
link_id: Optional filter by extraction link ID
|
259
|
+
name: Optional filter by link name
|
260
|
+
webhook_url: Optional filter by webhook URL
|
261
|
+
schema_id: Optional filter by schema ID
|
262
|
+
schema_data_id: Optional filter by schema data ID
|
263
|
+
|
264
|
+
Returns:
|
265
|
+
ListLinks: Paginated list of extraction link configurations with metadata
|
266
|
+
"""
|
267
|
+
request = self.prepare_list(before, after, limit, order, link_id, name, webhook_url, schema_id, schema_data_id)
|
268
|
+
response = self._client._prepared_request(request)
|
269
|
+
return ListLinks.model_validate(response)
|
270
|
+
|
271
|
+
def get(self, link_id: str) -> Link:
|
272
|
+
"""Get a specific extraction link configuration.
|
273
|
+
|
274
|
+
Args:
|
275
|
+
link_id: ID of the extraction link
|
276
|
+
|
277
|
+
Returns:
|
278
|
+
Link: The extraction link configuration
|
279
|
+
"""
|
280
|
+
request = self.prepare_get(link_id)
|
281
|
+
response = self._client._prepared_request(request)
|
282
|
+
return Link.model_validate(response)
|
283
|
+
|
284
|
+
def update(
|
285
|
+
self,
|
286
|
+
link_id: str,
|
287
|
+
name: Optional[str] = None,
|
288
|
+
webhook_url: Optional[HttpUrl] = None,
|
289
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
290
|
+
password: Optional[str] = None,
|
291
|
+
image_resolution_dpi: Optional[int] = None,
|
292
|
+
browser_canvas: Optional[str] = None,
|
293
|
+
modality: Optional[Modality] = None,
|
294
|
+
model: Optional[str] = None,
|
295
|
+
temperature: Optional[float] = None,
|
296
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] = None,
|
297
|
+
json_schema: Optional[Dict[str, Any]] = None,
|
298
|
+
) -> Link:
|
299
|
+
"""Update an extraction link configuration.
|
300
|
+
|
301
|
+
Args:
|
302
|
+
link_id: ID of the extraction link to update
|
303
|
+
name: New name for the link
|
304
|
+
webhook_url: New webhook endpoint URL
|
305
|
+
webhook_headers: New webhook headers
|
306
|
+
password: New password for protected links
|
307
|
+
image_resolution_dpi: New image resolution DPI
|
308
|
+
browser_canvas: New browser canvas
|
309
|
+
modality: New processing modality
|
310
|
+
model: New AI model
|
311
|
+
temperature: New temperature setting
|
312
|
+
reasoning_effort: The effort level for the model to reason about the input data.
|
313
|
+
json_schema: New JSON schema
|
314
|
+
|
315
|
+
Returns:
|
316
|
+
Link: The updated extraction link configuration
|
317
|
+
"""
|
318
|
+
|
319
|
+
request = self.prepare_update(link_id, name, webhook_url, webhook_headers, password, image_resolution_dpi, browser_canvas, modality, model, temperature, reasoning_effort, json_schema)
|
320
|
+
response = self._client._prepared_request(request)
|
321
|
+
return Link.model_validate(response)
|
322
|
+
|
323
|
+
def delete(self, link_id: str) -> None:
|
324
|
+
"""Delete an extraction link configuration.
|
325
|
+
|
326
|
+
Args:
|
327
|
+
link_id: ID of the extraction link to delete
|
328
|
+
|
329
|
+
Returns:
|
330
|
+
Dict[str, str]: Response message confirming deletion
|
331
|
+
"""
|
332
|
+
request = self.prepare_delete(link_id)
|
333
|
+
self._client._prepared_request(request)
|
334
|
+
|
335
|
+
def logs(
|
336
|
+
self,
|
337
|
+
before: str | None = None,
|
338
|
+
after: str | None = None,
|
339
|
+
limit: int = 10,
|
340
|
+
order: Literal["asc", "desc"] | None = "desc",
|
341
|
+
# Filtering parameters
|
342
|
+
link_id: Optional[str] = None,
|
343
|
+
name: Optional[str] = None,
|
344
|
+
webhook_url: Optional[str] = None,
|
345
|
+
schema_id: Optional[str] = None,
|
346
|
+
schema_data_id: Optional[str] = None,
|
347
|
+
) -> ListLogs:
|
348
|
+
"""Get logs for extraction links with pagination support.
|
349
|
+
|
350
|
+
Args:
|
351
|
+
before: Optional cursor for pagination - get results before this log ID
|
352
|
+
after: Optional cursor for pagination - get results after this log ID
|
353
|
+
limit: Maximum number of logs to return (1-100, default 10)
|
354
|
+
order: Sort order by creation time - "asc" or "desc" (default "desc")
|
355
|
+
link_id: Optional ID of a specific extraction link to filter logs for
|
356
|
+
name: Optional filter by link name
|
357
|
+
webhook_url: Optional filter by webhook URL
|
358
|
+
schema_id: Optional filter by schema ID
|
359
|
+
schema_data_id: Optional filter by schema data ID
|
360
|
+
|
361
|
+
Returns:
|
362
|
+
ListLinkLogsResponse: Paginated list of logs and metadata
|
363
|
+
"""
|
364
|
+
request = self.prepare_logs(before, after, limit, order, link_id, name, webhook_url, schema_id, schema_data_id)
|
365
|
+
response = self._client._prepared_request(request)
|
366
|
+
return ListLogs.model_validate(response)
|
367
|
+
|
368
|
+
|
369
|
+
class AsyncLinks(AsyncAPIResource, LinksMixin):
|
370
|
+
"""Async Extraction Link API wrapper for managing extraction link configurations"""
|
371
|
+
|
372
|
+
def __init__(self, client: Any) -> None:
|
373
|
+
super().__init__(client=client)
|
374
|
+
|
375
|
+
async def create(
|
376
|
+
self,
|
377
|
+
name: str,
|
378
|
+
json_schema: Dict[str, Any],
|
379
|
+
webhook_url: HttpUrl,
|
380
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
381
|
+
password: str | None = None,
|
382
|
+
image_resolution_dpi: Optional[int] = None,
|
383
|
+
browser_canvas: Optional[str] = None,
|
384
|
+
modality: Modality = "native",
|
385
|
+
model: str = "gpt-4o-mini",
|
386
|
+
temperature: float = 0,
|
387
|
+
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
388
|
+
) -> Link:
|
389
|
+
request = self.prepare_create(name, json_schema, webhook_url, webhook_headers, password, image_resolution_dpi, browser_canvas, modality, model, temperature, reasoning_effort)
|
390
|
+
response = await self._client._prepared_request(request)
|
391
|
+
print(f"Extraction Link Created. Link available at https://www.uiform.com/dashboard/processors/{response['id']}")
|
392
|
+
return Link.model_validate(response)
|
393
|
+
|
394
|
+
async def list(
|
395
|
+
self,
|
396
|
+
before: Optional[str] = None,
|
397
|
+
after: Optional[str] = None,
|
398
|
+
limit: Optional[int] = 10,
|
399
|
+
order: Optional[Literal["asc", "desc"]] = "desc",
|
400
|
+
link_id: Optional[str] = None,
|
401
|
+
name: Optional[str] = None,
|
402
|
+
webhook_url: Optional[str] = None,
|
403
|
+
schema_id: Optional[str] = None,
|
404
|
+
schema_data_id: Optional[str] = None,
|
405
|
+
) -> ListLinks:
|
406
|
+
request = self.prepare_list(before, after, limit, order, link_id, name, webhook_url, schema_id, schema_data_id)
|
407
|
+
response = await self._client._prepared_request(request)
|
408
|
+
return ListLinks.model_validate(response)
|
409
|
+
|
410
|
+
async def get(self, link_id: str) -> Link:
|
411
|
+
request = self.prepare_get(link_id)
|
412
|
+
response = await self._client._prepared_request(request)
|
413
|
+
return Link.model_validate(response)
|
414
|
+
|
415
|
+
async def update(
|
416
|
+
self,
|
417
|
+
link_id: str,
|
418
|
+
name: Optional[str] = None,
|
419
|
+
webhook_url: Optional[HttpUrl] = None,
|
420
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
421
|
+
password: Optional[str] = None,
|
422
|
+
image_resolution_dpi: Optional[int] = None,
|
423
|
+
browser_canvas: Optional[str] = None,
|
424
|
+
modality: Optional[Modality] = None,
|
425
|
+
model: Optional[str] = None,
|
426
|
+
temperature: Optional[float] = None,
|
427
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] = None,
|
428
|
+
json_schema: Optional[Dict[str, Any]] = None,
|
429
|
+
) -> Link:
|
430
|
+
request = self.prepare_update(link_id, name, webhook_url, webhook_headers, password, image_resolution_dpi, browser_canvas, modality, model, temperature, reasoning_effort, json_schema)
|
431
|
+
response = await self._client._prepared_request(request)
|
432
|
+
return Link.model_validate(response)
|
433
|
+
|
434
|
+
async def delete(self, link_id: str) -> None:
|
435
|
+
request = self.prepare_delete(link_id)
|
436
|
+
await self._client._prepared_request(request)
|
437
|
+
|
438
|
+
async def logs(
|
439
|
+
self,
|
440
|
+
before: str | None = None,
|
441
|
+
after: str | None = None,
|
442
|
+
limit: int = 10,
|
443
|
+
order: Literal["asc", "desc"] | None = "desc",
|
444
|
+
link_id: Optional[str] = None,
|
445
|
+
name: Optional[str] = None,
|
446
|
+
webhook_url: Optional[str] = None,
|
447
|
+
schema_id: Optional[str] = None,
|
448
|
+
schema_data_id: Optional[str] = None,
|
449
|
+
) -> ListLogs:
|
450
|
+
request = self.prepare_logs(before, after, limit, order, link_id, name, webhook_url, schema_id, schema_data_id)
|
451
|
+
response = await self._client._prepared_request(request)
|
452
|
+
return ListLogs.model_validate(response)
|
@@ -0,0 +1,211 @@
|
|
1
|
+
from typing import Any, Dict, Literal, Optional
|
2
|
+
|
3
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
4
|
+
from ...types.logs import AutomationLog, ExternalRequestLog, ListLogs
|
5
|
+
from ...types.standards import PreparedRequest
|
6
|
+
|
7
|
+
|
8
|
+
class LogsMixin:
|
9
|
+
def prepare_get(self, id: str) -> PreparedRequest:
|
10
|
+
"""Get a specific automation log by ID.
|
11
|
+
|
12
|
+
Args:
|
13
|
+
id: ID of the log to retrieve
|
14
|
+
|
15
|
+
Returns:
|
16
|
+
PreparedRequest: The prepared request
|
17
|
+
"""
|
18
|
+
return PreparedRequest(method="GET", url=f"/v1/deployments/logs/{id}")
|
19
|
+
|
20
|
+
def prepare_list(
|
21
|
+
self,
|
22
|
+
before: Optional[str] = None,
|
23
|
+
after: Optional[str] = None,
|
24
|
+
limit: Optional[int] = 10,
|
25
|
+
order: Optional[Literal["asc", "desc"]] = "desc",
|
26
|
+
# Filtering parameters
|
27
|
+
status_code: Optional[int] = None,
|
28
|
+
status_class: Optional[Literal["2xx", "3xx", "4xx", "5xx"]] = None,
|
29
|
+
deployment_id: Optional[str] = None,
|
30
|
+
webhook_url: Optional[str] = None,
|
31
|
+
schema_id: Optional[str] = None,
|
32
|
+
schema_data_id: Optional[str] = None,
|
33
|
+
) -> PreparedRequest:
|
34
|
+
"""List automation logs with pagination support.
|
35
|
+
|
36
|
+
Args:
|
37
|
+
before: Optional cursor for pagination before a specific log ID
|
38
|
+
after: Optional cursor for pagination after a specific log ID
|
39
|
+
limit: Optional limit on number of results (max 100)
|
40
|
+
order: Optional sort order ("asc" or "desc")
|
41
|
+
status_code: Optional filter by status code
|
42
|
+
status_class: Optional filter by status_class
|
43
|
+
deployment_id: Optional filter by deployment ID
|
44
|
+
webhook_url: Optional filter by webhook URL
|
45
|
+
schema_id: Optional filter by schema ID
|
46
|
+
schema_data_id: Optional filter by schema data ID
|
47
|
+
|
48
|
+
Returns:
|
49
|
+
PreparedRequest: The prepared request
|
50
|
+
"""
|
51
|
+
params = {
|
52
|
+
"before": before,
|
53
|
+
"after": after,
|
54
|
+
"limit": limit,
|
55
|
+
"order": order,
|
56
|
+
"status_code": status_code,
|
57
|
+
"status_class": status_class,
|
58
|
+
"deployment_id": deployment_id,
|
59
|
+
"webhook_url": webhook_url,
|
60
|
+
"schema_id": schema_id,
|
61
|
+
"schema_data_id": schema_data_id,
|
62
|
+
}
|
63
|
+
# Remove None values
|
64
|
+
params = {k: v for k, v in params.items() if v is not None}
|
65
|
+
|
66
|
+
return PreparedRequest(method="GET", url="/v1/deployments/logs", params=params)
|
67
|
+
|
68
|
+
def prepare_rerun(self, id: str) -> PreparedRequest:
|
69
|
+
"""Rerun a webhook from an existing AutomationLog.
|
70
|
+
|
71
|
+
Args:
|
72
|
+
id: ID of the log to rerun
|
73
|
+
|
74
|
+
Returns:
|
75
|
+
PreparedRequest: The prepared request
|
76
|
+
"""
|
77
|
+
return PreparedRequest(method="POST", url=f"/v1/deployments/logs/{id}/rerun")
|
78
|
+
|
79
|
+
|
80
|
+
class Logs(SyncAPIResource, LogsMixin):
|
81
|
+
"""Logs API wrapper for managing automation logs"""
|
82
|
+
|
83
|
+
def get(self, id: str) -> AutomationLog:
|
84
|
+
"""Get a specific automation log by ID.
|
85
|
+
|
86
|
+
Args:
|
87
|
+
id: ID of the log to retrieve
|
88
|
+
|
89
|
+
Returns:
|
90
|
+
AutomationLog: The automation log
|
91
|
+
"""
|
92
|
+
request = self.prepare_get(id)
|
93
|
+
response = self._client._prepared_request(request)
|
94
|
+
return AutomationLog.model_validate(response)
|
95
|
+
|
96
|
+
def list(
|
97
|
+
self,
|
98
|
+
before: Optional[str] = None,
|
99
|
+
after: Optional[str] = None,
|
100
|
+
limit: Optional[int] = 10,
|
101
|
+
order: Optional[Literal["asc", "desc"]] = "desc",
|
102
|
+
status_code: Optional[int] = None,
|
103
|
+
status_class: Optional[Literal["2xx", "3xx", "4xx", "5xx"]] = None,
|
104
|
+
deployment_id: Optional[str] = None,
|
105
|
+
webhook_url: Optional[str] = None,
|
106
|
+
schema_id: Optional[str] = None,
|
107
|
+
schema_data_id: Optional[str] = None,
|
108
|
+
) -> ListLogs:
|
109
|
+
"""List automation logs with pagination support.
|
110
|
+
|
111
|
+
Args:
|
112
|
+
before: Optional cursor for pagination before a specific log ID
|
113
|
+
after: Optional cursor for pagination after a specific log ID
|
114
|
+
limit: Optional limit on number of results (max 100)
|
115
|
+
order: Optional sort order ("asc" or "desc")
|
116
|
+
status_code: Optional filter by status code
|
117
|
+
status_class: Optional filter by status_class
|
118
|
+
deployment_id: Optional filter by deployment ID
|
119
|
+
webhook_url: Optional filter by webhook URL
|
120
|
+
schema_id: Optional filter by schema ID
|
121
|
+
schema_data_id: Optional filter by schema data ID
|
122
|
+
|
123
|
+
Returns:
|
124
|
+
ListLogs: Paginated list of automation logs with metadata
|
125
|
+
"""
|
126
|
+
request = self.prepare_list(before, after, limit, order, status_code, status_class, deployment_id, webhook_url, schema_id, schema_data_id)
|
127
|
+
response = self._client._prepared_request(request)
|
128
|
+
return ListLogs.model_validate(response)
|
129
|
+
|
130
|
+
def rerun(self, id: str) -> ExternalRequestLog:
|
131
|
+
"""Rerun a webhook from an existing AutomationLog.
|
132
|
+
|
133
|
+
Args:
|
134
|
+
id: ID of the log to rerun
|
135
|
+
|
136
|
+
Returns:
|
137
|
+
ExternalRequestLog: The result of the rerun webhook call
|
138
|
+
"""
|
139
|
+
request = self.prepare_rerun(id)
|
140
|
+
response = self._client._prepared_request(request)
|
141
|
+
|
142
|
+
print(f"Webhook call run successfully. Log available at https://docs.uiform.com/dashboard/processors/logs/{id}")
|
143
|
+
|
144
|
+
return ExternalRequestLog.model_validate(response)
|
145
|
+
|
146
|
+
|
147
|
+
class AsyncLogs(AsyncAPIResource, LogsMixin):
|
148
|
+
"""Async Logs API wrapper for managing automation logs"""
|
149
|
+
|
150
|
+
async def get(self, id: str) -> AutomationLog:
|
151
|
+
"""Get a specific automation log by ID.
|
152
|
+
|
153
|
+
Args:
|
154
|
+
id: ID of the log to retrieve
|
155
|
+
|
156
|
+
Returns:
|
157
|
+
AutomationLog: The automation log
|
158
|
+
"""
|
159
|
+
request = self.prepare_get(id)
|
160
|
+
response = await self._client._prepared_request(request)
|
161
|
+
return AutomationLog.model_validate(response)
|
162
|
+
|
163
|
+
async def list(
|
164
|
+
self,
|
165
|
+
before: Optional[str] = None,
|
166
|
+
after: Optional[str] = None,
|
167
|
+
limit: Optional[int] = 10,
|
168
|
+
order: Optional[Literal["asc", "desc"]] = "desc",
|
169
|
+
status_code: Optional[int] = None,
|
170
|
+
status_class: Optional[Literal["2xx", "3xx", "4xx", "5xx"]] = None,
|
171
|
+
deployment_id: Optional[str] = None,
|
172
|
+
webhook_url: Optional[str] = None,
|
173
|
+
schema_id: Optional[str] = None,
|
174
|
+
schema_data_id: Optional[str] = None,
|
175
|
+
) -> ListLogs:
|
176
|
+
"""List automation logs with pagination support.
|
177
|
+
|
178
|
+
Args:
|
179
|
+
before: Optional cursor for pagination before a specific log ID
|
180
|
+
after: Optional cursor for pagination after a specific log ID
|
181
|
+
limit: Optional limit on number of results (max 100)
|
182
|
+
order: Optional sort order ("asc" or "desc")
|
183
|
+
status_code: Optional filter by status code
|
184
|
+
status_class: Optional filter by status_class
|
185
|
+
deployment_id: Optional filter by deployment ID
|
186
|
+
webhook_url: Optional filter by webhook URL
|
187
|
+
schema_id: Optional filter by schema ID
|
188
|
+
schema_data_id: Optional filter by schema data ID
|
189
|
+
|
190
|
+
Returns:
|
191
|
+
ListLogs: Paginated list of automation logs with metadata
|
192
|
+
"""
|
193
|
+
request = self.prepare_list(before, after, limit, order, status_code, status_class, deployment_id, webhook_url, schema_id, schema_data_id)
|
194
|
+
response = await self._client._prepared_request(request)
|
195
|
+
return ListLogs.model_validate(response)
|
196
|
+
|
197
|
+
async def rerun(self, id: str) -> ExternalRequestLog:
|
198
|
+
"""Rerun a webhook from an existing AutomationLog.
|
199
|
+
|
200
|
+
Args:
|
201
|
+
id: ID of the log to rerun
|
202
|
+
|
203
|
+
Returns:
|
204
|
+
ExternalRequestLog: The result of the rerun webhook call
|
205
|
+
"""
|
206
|
+
request = self.prepare_rerun(id)
|
207
|
+
response = await self._client._prepared_request(request)
|
208
|
+
|
209
|
+
print(f"Webhook call run successfully. Log available at https://docs.uiform.com/dashboard/processors/logs/{id}")
|
210
|
+
|
211
|
+
return ExternalRequestLog.model_validate(response)
|