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,45 @@
|
|
1
|
+
from openai.types.model import Model
|
2
|
+
|
3
|
+
from .._resource import AsyncAPIResource, SyncAPIResource
|
4
|
+
from ..types.standards import PreparedRequest
|
5
|
+
|
6
|
+
|
7
|
+
class ModelsMixin:
|
8
|
+
def prepare_list(self) -> PreparedRequest:
|
9
|
+
return PreparedRequest(method="GET", url="/v1/models")
|
10
|
+
|
11
|
+
|
12
|
+
class Models(SyncAPIResource, ModelsMixin):
|
13
|
+
"""Models API wrapper"""
|
14
|
+
|
15
|
+
def list(self) -> list[Model]:
|
16
|
+
"""
|
17
|
+
List all available models.
|
18
|
+
|
19
|
+
Returns:
|
20
|
+
list[str]: List of available models
|
21
|
+
Raises:
|
22
|
+
HTTPException if the request fails
|
23
|
+
"""
|
24
|
+
|
25
|
+
request = self.prepare_list()
|
26
|
+
output = self._client._prepared_request(request)
|
27
|
+
return [Model(**model) for model in output["data"]]
|
28
|
+
|
29
|
+
|
30
|
+
class AsyncModels(AsyncAPIResource, ModelsMixin):
|
31
|
+
"""Models Asyncronous API wrapper"""
|
32
|
+
|
33
|
+
async def list(self) -> list[Model]:
|
34
|
+
"""
|
35
|
+
List all available models.
|
36
|
+
|
37
|
+
Returns:
|
38
|
+
list[str]: List of available models
|
39
|
+
Raises:
|
40
|
+
HTTPException if the request fails
|
41
|
+
"""
|
42
|
+
|
43
|
+
request = self.prepare_list()
|
44
|
+
output = await self._client._prepared_request(request)
|
45
|
+
return [Model(**model) for model in output["data"]]
|
@@ -0,0 +1,22 @@
|
|
1
|
+
from openai import OpenAI
|
2
|
+
from pydantic import BaseModel
|
3
|
+
|
4
|
+
client = OpenAI()
|
5
|
+
|
6
|
+
|
7
|
+
class CalendarEvent(BaseModel):
|
8
|
+
name: str
|
9
|
+
date: str
|
10
|
+
participants: list[str]
|
11
|
+
|
12
|
+
|
13
|
+
completion = client.beta.chat.completions.parse(
|
14
|
+
model="gpt-4o-2024-08-06",
|
15
|
+
messages=[
|
16
|
+
{"role": "developer", "content": "Extract the event information."},
|
17
|
+
{"role": "user", "content": "Alice and Bob are going to a science fair on Friday."},
|
18
|
+
],
|
19
|
+
response_format=CalendarEvent,
|
20
|
+
)
|
21
|
+
|
22
|
+
event = completion.choices[0].message.parsed
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import hashlib
|
2
|
+
import hmac
|
3
|
+
import json
|
4
|
+
from typing import Any
|
5
|
+
|
6
|
+
from ...._resource import AsyncAPIResource, SyncAPIResource
|
7
|
+
from .endpoints import AsyncEndpoints, Endpoints
|
8
|
+
from .links import AsyncLinks, Links
|
9
|
+
from .mailboxes import AsyncMailboxes, Mailboxes
|
10
|
+
from .outlook import AsyncOutlooks, Outlooks
|
11
|
+
from .tests import AsyncTests, Tests
|
12
|
+
from .logs import AsyncLogs, Logs
|
13
|
+
|
14
|
+
class SignatureVerificationError(Exception):
|
15
|
+
"""Raised when webhook signature verification fails."""
|
16
|
+
|
17
|
+
pass
|
18
|
+
|
19
|
+
|
20
|
+
class AutomationsMixin:
|
21
|
+
def _verify_event(self, event_body: bytes, event_signature: str, secret: str) -> Any:
|
22
|
+
"""
|
23
|
+
Verify the signature of a webhook event.
|
24
|
+
|
25
|
+
Args:
|
26
|
+
body: The raw request body
|
27
|
+
signature: The signature header
|
28
|
+
secret: The secret key used for signing
|
29
|
+
|
30
|
+
Returns:
|
31
|
+
The parsed event payload
|
32
|
+
|
33
|
+
Raises:
|
34
|
+
SignatureVerificationError: If the signature verification fails
|
35
|
+
"""
|
36
|
+
expected_signature = hmac.new(secret.encode(), event_body, hashlib.sha256).hexdigest()
|
37
|
+
|
38
|
+
if not hmac.compare_digest(event_signature, expected_signature):
|
39
|
+
raise SignatureVerificationError("Invalid signature")
|
40
|
+
|
41
|
+
return json.loads(event_body.decode('utf-8'))
|
42
|
+
|
43
|
+
|
44
|
+
class Automations(SyncAPIResource, AutomationsMixin):
|
45
|
+
"""Automations API wrapper"""
|
46
|
+
|
47
|
+
def __init__(self, client: Any) -> None:
|
48
|
+
super().__init__(client=client)
|
49
|
+
self.mailboxes = Mailboxes(client=client)
|
50
|
+
self.links = Links(client=client)
|
51
|
+
self.outlook = Outlooks(client=client)
|
52
|
+
self.endpoints = Endpoints(client=client)
|
53
|
+
self.tests = Tests(client=client)
|
54
|
+
self.logs = Logs(client=client)
|
55
|
+
def verify_event(self, event_body: bytes, event_signature: str, secret: str) -> Any:
|
56
|
+
"""
|
57
|
+
Verify the signature of a webhook event.
|
58
|
+
"""
|
59
|
+
return self._verify_event(event_body, event_signature, secret)
|
60
|
+
|
61
|
+
|
62
|
+
class AsyncAutomations(AsyncAPIResource, AutomationsMixin):
|
63
|
+
"""Async Automations API wrapper"""
|
64
|
+
|
65
|
+
def __init__(self, client: Any) -> None:
|
66
|
+
super().__init__(client=client)
|
67
|
+
self.mailboxes = AsyncMailboxes(client=client)
|
68
|
+
self.links = AsyncLinks(client=client)
|
69
|
+
self.outlook = AsyncOutlooks(client=client)
|
70
|
+
self.endpoints = AsyncEndpoints(client=client)
|
71
|
+
self.tests = AsyncTests(client=client)
|
72
|
+
self.logs = AsyncLogs(client=client)
|
73
|
+
|
74
|
+
async def verify_event(self, event_body: bytes, event_signature: str, secret: str) -> Any:
|
75
|
+
"""
|
76
|
+
Verify the signature of a webhook event.
|
77
|
+
"""
|
78
|
+
return self._verify_event(event_body, event_signature, secret)
|
@@ -0,0 +1,317 @@
|
|
1
|
+
import datetime
|
2
|
+
from pathlib import Path
|
3
|
+
from typing import Any, Dict, Literal, Optional
|
4
|
+
|
5
|
+
import httpx
|
6
|
+
from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
|
7
|
+
from pydantic import HttpUrl
|
8
|
+
|
9
|
+
from ...._resource import AsyncAPIResource, SyncAPIResource
|
10
|
+
from ...._utils.ai_models import assert_valid_model_extraction
|
11
|
+
from ....types.automations.endpoints import Endpoint, ListEndpoints, UpdateEndpointRequest
|
12
|
+
from ....types.logs import ExternalRequestLog
|
13
|
+
|
14
|
+
# from ...types.documents.extractions import DocumentExtractResponse
|
15
|
+
from ....types.mime import BaseMIMEData, MIMEData
|
16
|
+
from ....types.modalities import Modality
|
17
|
+
from ....types.standards import PreparedRequest
|
18
|
+
|
19
|
+
|
20
|
+
class EndpointsMixin:
|
21
|
+
def prepare_create(
|
22
|
+
self,
|
23
|
+
name: str,
|
24
|
+
webhook_url: HttpUrl,
|
25
|
+
json_schema: Dict[str, Any],
|
26
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
27
|
+
# DocumentExtraction Config
|
28
|
+
image_resolution_dpi: Optional[int] = None,
|
29
|
+
browser_canvas: Optional[Literal['A3', 'A4', 'A5']] = None,
|
30
|
+
modality: Modality = "native",
|
31
|
+
model: str = "gpt-4o-mini",
|
32
|
+
temperature: float = 0,
|
33
|
+
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
34
|
+
) -> PreparedRequest:
|
35
|
+
assert_valid_model_extraction(model)
|
36
|
+
|
37
|
+
data = {
|
38
|
+
"name": name,
|
39
|
+
"webhook_url": webhook_url,
|
40
|
+
"webhook_headers": webhook_headers or {},
|
41
|
+
"json_schema": json_schema,
|
42
|
+
"image_resolution_dpi": image_resolution_dpi,
|
43
|
+
"browser_canvas": browser_canvas,
|
44
|
+
"modality": modality,
|
45
|
+
"model": model,
|
46
|
+
"temperature": temperature,
|
47
|
+
"reasoning_effort": reasoning_effort,
|
48
|
+
}
|
49
|
+
|
50
|
+
request = Endpoint.model_validate(data)
|
51
|
+
return PreparedRequest(method="POST", url="/v1/deployments/endpoints", data=request.model_dump(mode='json'))
|
52
|
+
|
53
|
+
def prepare_list(
|
54
|
+
self,
|
55
|
+
before: Optional[str] = None,
|
56
|
+
after: Optional[str] = None,
|
57
|
+
limit: Optional[int] = 10,
|
58
|
+
order: Optional[Literal["asc", "desc"]] = "desc",
|
59
|
+
# Filtering parameters
|
60
|
+
name: Optional[str] = None,
|
61
|
+
webhook_url: Optional[str] = None,
|
62
|
+
) -> PreparedRequest:
|
63
|
+
params = {
|
64
|
+
"before": before,
|
65
|
+
"after": after,
|
66
|
+
"limit": limit,
|
67
|
+
"order": order,
|
68
|
+
"name": name,
|
69
|
+
"webhook_url": webhook_url,
|
70
|
+
}
|
71
|
+
# Remove None values
|
72
|
+
params = {k: v for k, v in params.items() if v is not None}
|
73
|
+
|
74
|
+
return PreparedRequest(method="GET", url="/v1/deployments/endpoints", params=params)
|
75
|
+
|
76
|
+
def prepare_get(self, endpoint_id: str) -> PreparedRequest:
|
77
|
+
"""Get a specific endpoint configuration.
|
78
|
+
|
79
|
+
Args:
|
80
|
+
endpoint_id: ID of the endpoint
|
81
|
+
|
82
|
+
Returns:
|
83
|
+
Endpoint: The endpoint configuration
|
84
|
+
"""
|
85
|
+
return PreparedRequest(method="GET", url=f"/v1/processors/automations/endpoints/{endpoint_id}")
|
86
|
+
|
87
|
+
def prepare_update(
|
88
|
+
self,
|
89
|
+
endpoint_id: str,
|
90
|
+
name: Optional[str] = None,
|
91
|
+
webhook_url: Optional[HttpUrl] = None,
|
92
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
93
|
+
json_schema: Optional[Dict[str, Any]] = None,
|
94
|
+
image_resolution_dpi: Optional[int] = None,
|
95
|
+
browser_canvas: Optional[Literal['A3', 'A4', 'A5']] = None,
|
96
|
+
modality: Optional[Modality] = None,
|
97
|
+
model: Optional[str] = None,
|
98
|
+
temperature: Optional[float] = None,
|
99
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] = None,
|
100
|
+
) -> PreparedRequest:
|
101
|
+
data: dict[str, Any] = {}
|
102
|
+
|
103
|
+
if endpoint_id is not None:
|
104
|
+
data["id"] = endpoint_id
|
105
|
+
if name is not None:
|
106
|
+
data["name"] = name
|
107
|
+
if webhook_url is not None:
|
108
|
+
data["webhook_url"] = webhook_url
|
109
|
+
if webhook_headers is not None:
|
110
|
+
data["webhook_headers"] = webhook_headers
|
111
|
+
if json_schema is not None:
|
112
|
+
data["json_schema"] = json_schema
|
113
|
+
if image_resolution_dpi is not None:
|
114
|
+
data["image_resolution_dpi"] = image_resolution_dpi
|
115
|
+
if browser_canvas is not None:
|
116
|
+
data["browser_canvas"] = browser_canvas
|
117
|
+
if modality is not None:
|
118
|
+
data["modality"] = modality
|
119
|
+
if model is not None:
|
120
|
+
assert_valid_model_extraction(model)
|
121
|
+
data["model"] = model
|
122
|
+
if temperature is not None:
|
123
|
+
data["temperature"] = temperature
|
124
|
+
if reasoning_effort is not None:
|
125
|
+
data["reasoning_effort"] = reasoning_effort
|
126
|
+
request = UpdateEndpointRequest.model_validate(data)
|
127
|
+
return PreparedRequest(method="PUT", url=f"/v1/processors/automations/endpoints/{endpoint_id}", data=request.model_dump(mode='json'))
|
128
|
+
|
129
|
+
def prepare_delete(self, endpoint_id: str) -> PreparedRequest:
|
130
|
+
return PreparedRequest(method="DELETE", url=f"/v1/processors/automations/endpoints/{endpoint_id}")
|
131
|
+
|
132
|
+
|
133
|
+
class Endpoints(SyncAPIResource, EndpointsMixin):
|
134
|
+
"""Endpoints API wrapper for managing endpoint configurations"""
|
135
|
+
|
136
|
+
def create(
|
137
|
+
self,
|
138
|
+
name: str,
|
139
|
+
webhook_url: HttpUrl,
|
140
|
+
json_schema: Dict[str, Any],
|
141
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
142
|
+
# DocumentExtraction Config
|
143
|
+
image_resolution_dpi: Optional[int] = None,
|
144
|
+
browser_canvas: Optional[Literal['A3', 'A4', 'A5']] = None,
|
145
|
+
modality: Modality = "native",
|
146
|
+
model: str = "gpt-4o-mini",
|
147
|
+
temperature: float = 0,
|
148
|
+
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
149
|
+
) -> Endpoint:
|
150
|
+
"""Create a new endpoint configuration.
|
151
|
+
|
152
|
+
Args:
|
153
|
+
name: Name of the endpoint
|
154
|
+
webhook_url: Webhook endpoint URL
|
155
|
+
json_schema: JSON schema for the endpoint
|
156
|
+
webhook_headers: Optional HTTP headers for webhook requests
|
157
|
+
image_resolution_dpi: Optional image resolution DPI
|
158
|
+
browser_canvas: Optional browser canvas size
|
159
|
+
modality: Processing modality (currently only "native" supported)
|
160
|
+
model: AI model to use for processing
|
161
|
+
temperature: Model temperature setting
|
162
|
+
reasoning_effort: The effort level for the model to reason about the input data.
|
163
|
+
Returns:
|
164
|
+
Endpoint: The created endpoint configuration
|
165
|
+
"""
|
166
|
+
request = self.prepare_create(name, webhook_url, json_schema, webhook_headers, image_resolution_dpi, browser_canvas, modality, model, temperature, reasoning_effort)
|
167
|
+
response = self._client._prepared_request(request)
|
168
|
+
print(f"Endpoint ID: {response['id']}. Endpoint available at https://www.uiform.com/dashboard/processors/{response['id']}")
|
169
|
+
return Endpoint.model_validate(response)
|
170
|
+
|
171
|
+
def list(
|
172
|
+
self,
|
173
|
+
before: Optional[str] = None,
|
174
|
+
after: Optional[str] = None,
|
175
|
+
limit: Optional[int] = 10,
|
176
|
+
order: Optional[Literal["asc", "desc"]] = "desc",
|
177
|
+
name: Optional[str] = None,
|
178
|
+
webhook_url: Optional[str] = None,
|
179
|
+
) -> ListEndpoints:
|
180
|
+
"""List endpoint configurations with pagination support.
|
181
|
+
|
182
|
+
Args:
|
183
|
+
before: Optional cursor for pagination before a specific endpoint ID
|
184
|
+
after: Optional cursor for pagination after a specific endpoint ID
|
185
|
+
limit: Optional limit on number of results (max 100)
|
186
|
+
order: Optional sort order ("asc" or "desc")
|
187
|
+
name: Optional filter by endpoint name
|
188
|
+
webhook_url: Optional filter by webhook URL
|
189
|
+
|
190
|
+
Returns:
|
191
|
+
ListEndpoints: Paginated list of endpoint configurations with metadata
|
192
|
+
"""
|
193
|
+
request = self.prepare_list(before, after, limit, order, name, webhook_url)
|
194
|
+
response = self._client._prepared_request(request)
|
195
|
+
return ListEndpoints.model_validate(response)
|
196
|
+
|
197
|
+
def get(self, endpoint_id: str) -> Endpoint:
|
198
|
+
"""Get a specific endpoint configuration.
|
199
|
+
|
200
|
+
Args:
|
201
|
+
endpoint_id: ID of the endpoint
|
202
|
+
|
203
|
+
Returns:
|
204
|
+
Endpoint: The endpoint configuration
|
205
|
+
"""
|
206
|
+
request = self.prepare_get(endpoint_id)
|
207
|
+
response = self._client._prepared_request(request)
|
208
|
+
return Endpoint.model_validate(response)
|
209
|
+
|
210
|
+
def update(
|
211
|
+
self,
|
212
|
+
endpoint_id: str,
|
213
|
+
name: Optional[str] = None,
|
214
|
+
webhook_url: Optional[HttpUrl] = None,
|
215
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
216
|
+
json_schema: Optional[Dict[str, Any]] = None,
|
217
|
+
image_resolution_dpi: Optional[int] = None,
|
218
|
+
browser_canvas: Optional[Literal['A3', 'A4', 'A5']] = None,
|
219
|
+
modality: Optional[Modality] = None,
|
220
|
+
model: Optional[str] = None,
|
221
|
+
temperature: Optional[float] = None,
|
222
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] = None,
|
223
|
+
) -> Endpoint:
|
224
|
+
"""Update an endpoint configuration.
|
225
|
+
|
226
|
+
Args:
|
227
|
+
id: ID of the endpoint to update
|
228
|
+
name: New name for the endpoint
|
229
|
+
webhook_url: New webhook URL
|
230
|
+
webhook_headers: New webhook headers
|
231
|
+
json_schema: New JSON schema for the endpoint
|
232
|
+
image_resolution_dpi: New image resolution DPI
|
233
|
+
browser_canvas: New browser canvas size
|
234
|
+
modality: New processing modality
|
235
|
+
model: New AI model
|
236
|
+
temperature: New temperature setting
|
237
|
+
reasoning_effort: The effort level for the model to reason about the input data.
|
238
|
+
Returns:
|
239
|
+
Endpoint: The updated endpoint configuration
|
240
|
+
"""
|
241
|
+
request = self.prepare_update(endpoint_id, name, webhook_url, webhook_headers, json_schema, image_resolution_dpi, browser_canvas, modality, model, temperature, reasoning_effort)
|
242
|
+
response = self._client._prepared_request(request)
|
243
|
+
return Endpoint.model_validate(response)
|
244
|
+
|
245
|
+
def delete(self, endpoint_id: str) -> None:
|
246
|
+
"""Delete an endpoint configuration.
|
247
|
+
|
248
|
+
Args:
|
249
|
+
id: ID of the endpoint to delete
|
250
|
+
"""
|
251
|
+
request = self.prepare_delete(endpoint_id)
|
252
|
+
self._client._prepared_request(request)
|
253
|
+
print(f"Endpoint Deleted. ID: {endpoint_id}")
|
254
|
+
|
255
|
+
|
256
|
+
class AsyncEndpoints(AsyncAPIResource, EndpointsMixin):
|
257
|
+
"""Async Endpoints API wrapper for managing endpoint configurations"""
|
258
|
+
|
259
|
+
async def create(
|
260
|
+
self,
|
261
|
+
name: str,
|
262
|
+
webhook_url: HttpUrl,
|
263
|
+
json_schema: Dict[str, Any],
|
264
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
265
|
+
# DocumentExtraction Config
|
266
|
+
image_resolution_dpi: Optional[int] = None,
|
267
|
+
browser_canvas: Optional[Literal['A3', 'A4', 'A5']] = None,
|
268
|
+
modality: Modality = "native",
|
269
|
+
model: str = "gpt-4o-mini",
|
270
|
+
temperature: float = 0,
|
271
|
+
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
272
|
+
) -> Endpoint:
|
273
|
+
request = self.prepare_create(name, webhook_url, json_schema, webhook_headers, image_resolution_dpi, browser_canvas, modality, model, temperature, reasoning_effort)
|
274
|
+
response = await self._client._prepared_request(request)
|
275
|
+
print(f"Endpoint ID: {response['id']}. Endpoint available at https://www.uiform.com/dashboard/processors/{response['id']}")
|
276
|
+
|
277
|
+
return Endpoint.model_validate(response)
|
278
|
+
|
279
|
+
async def list(
|
280
|
+
self,
|
281
|
+
before: Optional[str] = None,
|
282
|
+
after: Optional[str] = None,
|
283
|
+
limit: Optional[int] = 10,
|
284
|
+
order: Optional[Literal["asc", "desc"]] = "desc",
|
285
|
+
name: Optional[str] = None,
|
286
|
+
webhook_url: Optional[str] = None,
|
287
|
+
) -> ListEndpoints:
|
288
|
+
request = self.prepare_list(before, after, limit, order, name, webhook_url)
|
289
|
+
response = await self._client._prepared_request(request)
|
290
|
+
return ListEndpoints.model_validate(response)
|
291
|
+
|
292
|
+
async def get(self, endpoint_id: str) -> Endpoint:
|
293
|
+
request = self.prepare_get(endpoint_id)
|
294
|
+
response = await self._client._prepared_request(request)
|
295
|
+
return Endpoint.model_validate(response)
|
296
|
+
|
297
|
+
async def update(
|
298
|
+
self,
|
299
|
+
endpoint_id: str,
|
300
|
+
name: Optional[str] = None,
|
301
|
+
webhook_url: Optional[HttpUrl] = None,
|
302
|
+
webhook_headers: Optional[Dict[str, str]] = None,
|
303
|
+
json_schema: Optional[Dict[str, Any]] = None,
|
304
|
+
image_resolution_dpi: Optional[int] = None,
|
305
|
+
browser_canvas: Optional[Literal['A3', 'A4', 'A5']] = None,
|
306
|
+
modality: Optional[Modality] = None,
|
307
|
+
model: Optional[str] = None,
|
308
|
+
temperature: Optional[float] = None,
|
309
|
+
reasoning_effort: Optional[ChatCompletionReasoningEffort] = None,
|
310
|
+
) -> Endpoint:
|
311
|
+
request = self.prepare_update(endpoint_id, name, webhook_url, webhook_headers, json_schema, image_resolution_dpi, browser_canvas, modality, model, temperature, reasoning_effort)
|
312
|
+
response = await self._client._prepared_request(request)
|
313
|
+
return Endpoint.model_validate(response)
|
314
|
+
|
315
|
+
async def delete(self, endpoint_id: str) -> None:
|
316
|
+
request = self.prepare_delete(endpoint_id)
|
317
|
+
await self._client._prepared_request(request)
|