retab 0.0.35__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.
Files changed (134) hide show
  1. {uiform → retab}/_utils/ai_models.py +2 -2
  2. {uiform → retab}/_utils/benchmarking.py +15 -16
  3. {uiform → retab}/_utils/chat.py +9 -14
  4. {uiform → retab}/_utils/display.py +0 -3
  5. {uiform → retab}/_utils/json_schema.py +9 -14
  6. {uiform → retab}/_utils/mime.py +11 -14
  7. {uiform → retab}/_utils/responses.py +9 -3
  8. {uiform → retab}/_utils/stream_context_managers.py +1 -1
  9. {uiform → retab}/_utils/usage/usage.py +28 -28
  10. {uiform → retab}/client.py +32 -31
  11. {uiform → retab}/resources/consensus/client.py +17 -36
  12. {uiform → retab}/resources/consensus/completions.py +24 -47
  13. {uiform → retab}/resources/consensus/completions_stream.py +26 -38
  14. {uiform → retab}/resources/consensus/responses.py +31 -80
  15. {uiform → retab}/resources/consensus/responses_stream.py +31 -79
  16. {uiform → retab}/resources/documents/client.py +59 -45
  17. {uiform → retab}/resources/documents/extractions.py +181 -90
  18. {uiform → retab}/resources/evals.py +56 -43
  19. retab/resources/evaluations/__init__.py +3 -0
  20. retab/resources/evaluations/client.py +301 -0
  21. retab/resources/evaluations/documents.py +233 -0
  22. retab/resources/evaluations/iterations.py +452 -0
  23. {uiform → retab}/resources/files.py +2 -2
  24. {uiform → retab}/resources/jsonlUtils.py +220 -216
  25. retab/resources/models.py +73 -0
  26. retab/resources/processors/automations/client.py +244 -0
  27. {uiform → retab}/resources/processors/automations/endpoints.py +77 -118
  28. retab/resources/processors/automations/links.py +294 -0
  29. {uiform → retab}/resources/processors/automations/logs.py +30 -19
  30. {uiform → retab}/resources/processors/automations/mailboxes.py +136 -174
  31. retab/resources/processors/automations/outlook.py +337 -0
  32. {uiform → retab}/resources/processors/automations/tests.py +22 -25
  33. {uiform → retab}/resources/processors/client.py +179 -164
  34. {uiform → retab}/resources/schemas.py +78 -66
  35. {uiform → retab}/resources/secrets/external_api_keys.py +1 -5
  36. retab/resources/secrets/webhook.py +64 -0
  37. {uiform → retab}/resources/usage.py +39 -2
  38. {uiform → retab}/types/ai_models.py +13 -13
  39. {uiform → retab}/types/automations/cron.py +19 -12
  40. {uiform → retab}/types/automations/endpoints.py +7 -4
  41. {uiform → retab}/types/automations/links.py +7 -3
  42. {uiform → retab}/types/automations/mailboxes.py +9 -9
  43. {uiform → retab}/types/automations/outlook.py +15 -11
  44. retab/types/browser_canvas.py +3 -0
  45. {uiform → retab}/types/chat.py +2 -2
  46. {uiform → retab}/types/completions.py +9 -12
  47. retab/types/consensus.py +19 -0
  48. {uiform → retab}/types/db/annotations.py +3 -3
  49. {uiform → retab}/types/db/files.py +8 -6
  50. {uiform → retab}/types/documents/create_messages.py +18 -20
  51. {uiform → retab}/types/documents/extractions.py +69 -24
  52. {uiform → retab}/types/evals.py +5 -5
  53. retab/types/evaluations/__init__.py +31 -0
  54. retab/types/evaluations/documents.py +30 -0
  55. retab/types/evaluations/iterations.py +112 -0
  56. retab/types/evaluations/model.py +73 -0
  57. retab/types/events.py +79 -0
  58. {uiform → retab}/types/extractions.py +33 -10
  59. retab/types/inference_settings.py +15 -0
  60. retab/types/jobs/base.py +54 -0
  61. retab/types/jobs/batch_annotation.py +12 -0
  62. {uiform → retab}/types/jobs/evaluation.py +1 -2
  63. {uiform → retab}/types/logs.py +37 -34
  64. retab/types/metrics.py +32 -0
  65. {uiform → retab}/types/mime.py +22 -20
  66. {uiform → retab}/types/modalities.py +10 -10
  67. retab/types/predictions.py +19 -0
  68. {uiform → retab}/types/schemas/enhance.py +4 -2
  69. {uiform → retab}/types/schemas/evaluate.py +7 -4
  70. {uiform → retab}/types/schemas/generate.py +6 -3
  71. {uiform → retab}/types/schemas/layout.py +1 -1
  72. {uiform → retab}/types/schemas/object.py +13 -14
  73. {uiform → retab}/types/schemas/templates.py +1 -3
  74. {uiform → retab}/types/secrets/external_api_keys.py +0 -1
  75. {uiform → retab}/types/standards.py +18 -1
  76. {retab-0.0.35.dist-info → retab-0.0.37.dist-info}/METADATA +7 -6
  77. retab-0.0.37.dist-info/RECORD +107 -0
  78. retab-0.0.37.dist-info/top_level.txt +1 -0
  79. retab-0.0.35.dist-info/RECORD +0 -111
  80. retab-0.0.35.dist-info/top_level.txt +0 -1
  81. uiform/_utils/benchmarking copy.py +0 -588
  82. uiform/resources/deployments/__init__.py +0 -9
  83. uiform/resources/deployments/client.py +0 -78
  84. uiform/resources/deployments/endpoints.py +0 -322
  85. uiform/resources/deployments/links.py +0 -452
  86. uiform/resources/deployments/logs.py +0 -211
  87. uiform/resources/deployments/mailboxes.py +0 -496
  88. uiform/resources/deployments/outlook.py +0 -531
  89. uiform/resources/deployments/tests.py +0 -158
  90. uiform/resources/models.py +0 -45
  91. uiform/resources/processors/automations/client.py +0 -78
  92. uiform/resources/processors/automations/links.py +0 -356
  93. uiform/resources/processors/automations/outlook.py +0 -444
  94. uiform/resources/secrets/webhook.py +0 -62
  95. uiform/types/consensus.py +0 -10
  96. uiform/types/deployments/cron.py +0 -59
  97. uiform/types/deployments/endpoints.py +0 -28
  98. uiform/types/deployments/links.py +0 -36
  99. uiform/types/deployments/mailboxes.py +0 -67
  100. uiform/types/deployments/outlook.py +0 -76
  101. uiform/types/deployments/webhooks.py +0 -21
  102. uiform/types/events.py +0 -76
  103. uiform/types/jobs/base.py +0 -150
  104. uiform/types/jobs/batch_annotation.py +0 -22
  105. uiform/types/secrets/__init__.py +0 -0
  106. {uiform → retab}/__init__.py +0 -0
  107. {uiform → retab}/_resource.py +0 -0
  108. {uiform → retab}/_utils/__init__.py +0 -0
  109. {uiform → retab}/_utils/usage/__init__.py +0 -0
  110. {uiform → retab}/py.typed +0 -0
  111. {uiform → retab}/resources/__init__.py +0 -0
  112. {uiform → retab}/resources/consensus/__init__.py +0 -0
  113. {uiform → retab}/resources/documents/__init__.py +0 -0
  114. {uiform → retab}/resources/finetuning.py +0 -0
  115. {uiform → retab}/resources/openai_example.py +0 -0
  116. {uiform → retab}/resources/processors/__init__.py +0 -0
  117. {uiform → retab}/resources/processors/automations/__init__.py +0 -0
  118. {uiform → retab}/resources/prompt_optimization.py +0 -0
  119. {uiform → retab}/resources/secrets/__init__.py +0 -0
  120. {uiform → retab}/resources/secrets/client.py +0 -0
  121. {uiform → retab}/types/__init__.py +0 -0
  122. {uiform → retab}/types/automations/__init__.py +0 -0
  123. {uiform → retab}/types/automations/webhooks.py +0 -0
  124. {uiform → retab}/types/db/__init__.py +0 -0
  125. {uiform/types/deployments → retab/types/documents}/__init__.py +0 -0
  126. {uiform → retab}/types/documents/correct_orientation.py +0 -0
  127. {uiform/types/documents → retab/types/jobs}/__init__.py +0 -0
  128. {uiform → retab}/types/jobs/finetune.py +0 -0
  129. {uiform → retab}/types/jobs/prompt_optimization.py +0 -0
  130. {uiform → retab}/types/jobs/webcrawl.py +0 -0
  131. {uiform → retab}/types/pagination.py +0 -0
  132. {uiform/types/jobs → retab/types/schemas}/__init__.py +0 -0
  133. {uiform/types/schemas → retab/types/secrets}/__init__.py +0 -0
  134. {retab-0.0.35.dist-info → retab-0.0.37.dist-info}/WHEEL +0 -0
@@ -1,452 +0,0 @@
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)
@@ -1,211 +0,0 @@
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)