retab 0.0.36__py3-none-any.whl → 0.0.38__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/__init__.py +4 -0
- {uiform → retab}/_resource.py +5 -5
- {uiform → retab}/_utils/ai_models.py +2 -2
- {uiform → retab}/_utils/benchmarking.py +15 -16
- {uiform → retab}/_utils/chat.py +29 -34
- {uiform → retab}/_utils/display.py +0 -3
- {uiform → retab}/_utils/json_schema.py +9 -14
- {uiform → retab}/_utils/mime.py +11 -14
- {uiform → retab}/_utils/responses.py +16 -10
- {uiform → retab}/_utils/stream_context_managers.py +1 -1
- {uiform → retab}/_utils/usage/usage.py +31 -31
- {uiform → retab}/client.py +54 -53
- {uiform → retab}/resources/consensus/client.py +19 -38
- {uiform → retab}/resources/consensus/completions.py +36 -59
- {uiform → retab}/resources/consensus/completions_stream.py +35 -47
- {uiform → retab}/resources/consensus/responses.py +37 -86
- {uiform → retab}/resources/consensus/responses_stream.py +41 -89
- retab/resources/documents/client.py +455 -0
- {uiform → retab}/resources/documents/extractions.py +192 -101
- {uiform → retab}/resources/evals.py +56 -43
- retab/resources/evaluations/__init__.py +3 -0
- retab/resources/evaluations/client.py +301 -0
- retab/resources/evaluations/documents.py +233 -0
- retab/resources/evaluations/iterations.py +452 -0
- {uiform → retab}/resources/files.py +2 -2
- {uiform → retab}/resources/jsonlUtils.py +225 -221
- retab/resources/models.py +73 -0
- retab/resources/processors/automations/client.py +244 -0
- {uiform → retab}/resources/processors/automations/endpoints.py +79 -120
- retab/resources/processors/automations/links.py +294 -0
- {uiform → retab}/resources/processors/automations/logs.py +30 -19
- retab/resources/processors/automations/mailboxes.py +397 -0
- retab/resources/processors/automations/outlook.py +337 -0
- {uiform → retab}/resources/processors/automations/tests.py +22 -25
- {uiform → retab}/resources/processors/client.py +181 -166
- {uiform → retab}/resources/schemas.py +78 -66
- {uiform → retab}/resources/secrets/external_api_keys.py +1 -5
- retab/resources/secrets/webhook.py +64 -0
- {uiform → retab}/resources/usage.py +41 -4
- {uiform → retab}/types/ai_models.py +17 -17
- {uiform → retab}/types/automations/cron.py +19 -12
- {uiform → retab}/types/automations/endpoints.py +7 -4
- {uiform → retab}/types/automations/links.py +7 -3
- {uiform → retab}/types/automations/mailboxes.py +10 -10
- {uiform → retab}/types/automations/outlook.py +15 -11
- {uiform → retab}/types/automations/webhooks.py +1 -1
- retab/types/browser_canvas.py +3 -0
- retab/types/chat.py +8 -0
- {uiform → retab}/types/completions.py +12 -15
- retab/types/consensus.py +19 -0
- {uiform → retab}/types/db/annotations.py +3 -3
- {uiform → retab}/types/db/files.py +8 -6
- {uiform → retab}/types/documents/create_messages.py +20 -22
- {uiform → retab}/types/documents/extractions.py +71 -26
- {uiform → retab}/types/evals.py +5 -5
- retab/types/evaluations/__init__.py +31 -0
- retab/types/evaluations/documents.py +30 -0
- retab/types/evaluations/iterations.py +112 -0
- retab/types/evaluations/model.py +73 -0
- retab/types/events.py +79 -0
- {uiform → retab}/types/extractions.py +36 -13
- retab/types/inference_settings.py +15 -0
- retab/types/jobs/base.py +54 -0
- retab/types/jobs/batch_annotation.py +12 -0
- {uiform → retab}/types/jobs/evaluation.py +1 -2
- {uiform → retab}/types/logs.py +37 -34
- retab/types/metrics.py +32 -0
- {uiform → retab}/types/mime.py +22 -20
- {uiform → retab}/types/modalities.py +10 -10
- retab/types/predictions.py +19 -0
- {uiform → retab}/types/schemas/enhance.py +4 -2
- {uiform → retab}/types/schemas/evaluate.py +7 -4
- {uiform → retab}/types/schemas/generate.py +6 -3
- {uiform → retab}/types/schemas/layout.py +1 -1
- {uiform → retab}/types/schemas/object.py +16 -17
- {uiform → retab}/types/schemas/templates.py +1 -3
- {uiform → retab}/types/secrets/external_api_keys.py +0 -1
- {uiform → retab}/types/standards.py +18 -1
- {retab-0.0.36.dist-info → retab-0.0.38.dist-info}/METADATA +78 -77
- retab-0.0.38.dist-info/RECORD +107 -0
- retab-0.0.38.dist-info/top_level.txt +1 -0
- retab-0.0.36.dist-info/RECORD +0 -96
- retab-0.0.36.dist-info/top_level.txt +0 -1
- uiform/__init__.py +0 -4
- uiform/_utils/benchmarking copy.py +0 -588
- uiform/resources/documents/client.py +0 -255
- uiform/resources/models.py +0 -45
- uiform/resources/processors/automations/client.py +0 -78
- uiform/resources/processors/automations/links.py +0 -356
- uiform/resources/processors/automations/mailboxes.py +0 -435
- uiform/resources/processors/automations/outlook.py +0 -444
- uiform/resources/secrets/webhook.py +0 -62
- uiform/types/chat.py +0 -8
- uiform/types/consensus.py +0 -10
- uiform/types/events.py +0 -76
- uiform/types/jobs/base.py +0 -150
- uiform/types/jobs/batch_annotation.py +0 -22
- {uiform → retab}/_utils/__init__.py +0 -0
- {uiform → retab}/_utils/usage/__init__.py +0 -0
- {uiform → retab}/py.typed +0 -0
- {uiform → retab}/resources/__init__.py +0 -0
- {uiform → retab}/resources/consensus/__init__.py +0 -0
- {uiform → retab}/resources/documents/__init__.py +0 -0
- {uiform → retab}/resources/finetuning.py +0 -0
- {uiform → retab}/resources/openai_example.py +0 -0
- {uiform → retab}/resources/processors/__init__.py +0 -0
- {uiform → retab}/resources/processors/automations/__init__.py +0 -0
- {uiform → retab}/resources/prompt_optimization.py +0 -0
- {uiform → retab}/resources/secrets/__init__.py +0 -0
- {uiform → retab}/resources/secrets/client.py +0 -0
- {uiform → retab}/types/__init__.py +0 -0
- {uiform → retab}/types/automations/__init__.py +0 -0
- {uiform → retab}/types/db/__init__.py +0 -0
- {uiform → retab}/types/documents/__init__.py +0 -0
- {uiform → retab}/types/documents/correct_orientation.py +0 -0
- {uiform → retab}/types/jobs/__init__.py +0 -0
- {uiform → retab}/types/jobs/finetune.py +0 -0
- {uiform → retab}/types/jobs/prompt_optimization.py +0 -0
- {uiform → retab}/types/jobs/webcrawl.py +0 -0
- {uiform → retab}/types/pagination.py +0 -0
- {uiform → retab}/types/schemas/__init__.py +0 -0
- {uiform → retab}/types/secrets/__init__.py +0 -0
- {retab-0.0.36.dist-info → retab-0.0.38.dist-info}/WHEEL +0 -0
@@ -0,0 +1,73 @@
|
|
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(
|
9
|
+
self,
|
10
|
+
supports_finetuning: bool = False,
|
11
|
+
supports_image: bool = False,
|
12
|
+
include_finetuned_models: bool = True,
|
13
|
+
) -> PreparedRequest:
|
14
|
+
params = {
|
15
|
+
"supports_finetuning": supports_finetuning,
|
16
|
+
"supports_image": supports_image,
|
17
|
+
"include_finetuned_models": include_finetuned_models,
|
18
|
+
}
|
19
|
+
return PreparedRequest(method="GET", url="/v1/models", params=params)
|
20
|
+
|
21
|
+
|
22
|
+
class Models(SyncAPIResource, ModelsMixin):
|
23
|
+
"""Models API wrapper"""
|
24
|
+
|
25
|
+
def list(
|
26
|
+
self,
|
27
|
+
supports_finetuning: bool = False,
|
28
|
+
supports_image: bool = False,
|
29
|
+
include_finetuned_models: bool = True,
|
30
|
+
) -> list[Model]:
|
31
|
+
"""
|
32
|
+
List all available models.
|
33
|
+
|
34
|
+
Args:
|
35
|
+
supports_finetuning: Filter for models that support fine-tuning
|
36
|
+
supports_image: Filter for models that support image inputs
|
37
|
+
include_finetuned_models: Include fine-tuned models in results
|
38
|
+
|
39
|
+
Returns:
|
40
|
+
list[Model]: List of available models
|
41
|
+
Raises:
|
42
|
+
HTTPException if the request fails
|
43
|
+
"""
|
44
|
+
request = self.prepare_list(supports_finetuning, supports_image, include_finetuned_models)
|
45
|
+
output = self._client._prepared_request(request)
|
46
|
+
return [Model(**model) for model in output["data"]]
|
47
|
+
|
48
|
+
|
49
|
+
class AsyncModels(AsyncAPIResource, ModelsMixin):
|
50
|
+
"""Models Asyncronous API wrapper"""
|
51
|
+
|
52
|
+
async def list(
|
53
|
+
self,
|
54
|
+
supports_finetuning: bool = False,
|
55
|
+
supports_image: bool = False,
|
56
|
+
include_finetuned_models: bool = True,
|
57
|
+
) -> list[Model]:
|
58
|
+
"""
|
59
|
+
List all available models asynchronously.
|
60
|
+
|
61
|
+
Args:
|
62
|
+
supports_finetuning: Filter for models that support fine-tuning
|
63
|
+
supports_image: Filter for models that support image inputs
|
64
|
+
include_finetuned_models: Include fine-tuned models in results
|
65
|
+
|
66
|
+
Returns:
|
67
|
+
list[Model]: List of available models
|
68
|
+
Raises:
|
69
|
+
HTTPException if the request fails
|
70
|
+
"""
|
71
|
+
request = self.prepare_list(supports_finetuning, supports_image, include_finetuned_models)
|
72
|
+
output = await self._client._prepared_request(request)
|
73
|
+
return [Model(**model) for model in output["data"]]
|
@@ -0,0 +1,244 @@
|
|
1
|
+
import hashlib
|
2
|
+
import hmac
|
3
|
+
import json
|
4
|
+
from typing import Any, Literal, Optional, Union
|
5
|
+
|
6
|
+
from ...._resource import AsyncAPIResource, SyncAPIResource
|
7
|
+
from ....types.automations.endpoints import Endpoint, UpdateEndpointRequest
|
8
|
+
from ....types.automations.links import Link, UpdateLinkRequest
|
9
|
+
from ....types.automations.mailboxes import Mailbox, UpdateMailboxRequest
|
10
|
+
from ....types.automations.outlook import Outlook, UpdateOutlookRequest
|
11
|
+
from ....types.standards import PreparedRequest
|
12
|
+
from .endpoints import AsyncEndpoints, Endpoints
|
13
|
+
from .links import AsyncLinks, Links
|
14
|
+
from .logs import AsyncLogs, Logs
|
15
|
+
from .mailboxes import AsyncMailboxes, Mailboxes
|
16
|
+
from .outlook import AsyncOutlooks, Outlooks
|
17
|
+
from .tests import AsyncTests, Tests
|
18
|
+
|
19
|
+
|
20
|
+
class SignatureVerificationError(Exception):
|
21
|
+
"""Raised when webhook signature verification fails."""
|
22
|
+
|
23
|
+
pass
|
24
|
+
|
25
|
+
|
26
|
+
class AutomationsMixin:
|
27
|
+
def _verify_event(self, event_body: bytes, event_signature: str, secret: str) -> Any:
|
28
|
+
"""
|
29
|
+
Verify the signature of a webhook event.
|
30
|
+
|
31
|
+
Args:
|
32
|
+
body: The raw request body
|
33
|
+
signature: The signature header
|
34
|
+
secret: The secret key used for signing
|
35
|
+
|
36
|
+
Returns:
|
37
|
+
The parsed event payload
|
38
|
+
|
39
|
+
Raises:
|
40
|
+
SignatureVerificationError: If the signature verification fails
|
41
|
+
"""
|
42
|
+
expected_signature = hmac.new(secret.encode(), event_body, hashlib.sha256).hexdigest()
|
43
|
+
|
44
|
+
if not hmac.compare_digest(event_signature, expected_signature):
|
45
|
+
raise SignatureVerificationError("Invalid signature")
|
46
|
+
|
47
|
+
return json.loads(event_body.decode("utf-8"))
|
48
|
+
|
49
|
+
def prepare_list(
|
50
|
+
self,
|
51
|
+
processor_id: str,
|
52
|
+
before: Optional[str] = None,
|
53
|
+
after: Optional[str] = None,
|
54
|
+
limit: Optional[int] = 10,
|
55
|
+
order: Optional[Literal["asc", "desc"]] = "desc",
|
56
|
+
automation_id: Optional[str] = None,
|
57
|
+
webhook_url: Optional[str] = None,
|
58
|
+
name: Optional[str] = None,
|
59
|
+
) -> PreparedRequest:
|
60
|
+
params = {
|
61
|
+
"before": before,
|
62
|
+
"after": after,
|
63
|
+
"limit": limit,
|
64
|
+
"order": order,
|
65
|
+
"id": automation_id,
|
66
|
+
"webhook_url": webhook_url,
|
67
|
+
"name": name,
|
68
|
+
}
|
69
|
+
params = {k: v for k, v in params.items() if v is not None}
|
70
|
+
return PreparedRequest(method="GET", url=f"/v1/processors/{processor_id}/automations", params=params)
|
71
|
+
|
72
|
+
def prepare_get(self, processor_id: str, automation_id: str) -> PreparedRequest:
|
73
|
+
return PreparedRequest(method="GET", url=f"/v1/processors/{processor_id}/automations/{automation_id}")
|
74
|
+
|
75
|
+
def prepare_update(
|
76
|
+
self,
|
77
|
+
processor_id: str,
|
78
|
+
automation_id: str,
|
79
|
+
automation_data: Union[UpdateLinkRequest, UpdateMailboxRequest, UpdateEndpointRequest, UpdateOutlookRequest],
|
80
|
+
) -> PreparedRequest:
|
81
|
+
return PreparedRequest(method="PUT", url=f"/v1/processors/{processor_id}/automations/{automation_id}", data=automation_data.model_dump(mode="json"))
|
82
|
+
|
83
|
+
def prepare_delete(self, processor_id: str, automation_id: str) -> PreparedRequest:
|
84
|
+
return PreparedRequest(method="DELETE", url=f"/v1/processors/{processor_id}/automations/{automation_id}")
|
85
|
+
|
86
|
+
|
87
|
+
class Automations(SyncAPIResource, AutomationsMixin):
|
88
|
+
"""Automations API wrapper"""
|
89
|
+
|
90
|
+
def __init__(self, client: Any) -> None:
|
91
|
+
super().__init__(client=client)
|
92
|
+
self.mailboxes = Mailboxes(client=client)
|
93
|
+
self.links = Links(client=client)
|
94
|
+
self.outlook = Outlooks(client=client)
|
95
|
+
self.endpoints = Endpoints(client=client)
|
96
|
+
self.tests = Tests(client=client)
|
97
|
+
self.logs = Logs(client=client)
|
98
|
+
|
99
|
+
def verify_event(self, event_body: bytes, event_signature: str, secret: str) -> Any:
|
100
|
+
"""
|
101
|
+
Verify the signature of a webhook event.
|
102
|
+
"""
|
103
|
+
return self._verify_event(event_body, event_signature, secret)
|
104
|
+
|
105
|
+
def list_automations(
|
106
|
+
self,
|
107
|
+
processor_id: str,
|
108
|
+
before: Optional[str] = None,
|
109
|
+
after: Optional[str] = None,
|
110
|
+
limit: Optional[int] = 10,
|
111
|
+
order: Optional[Literal["asc", "desc"]] = "desc",
|
112
|
+
automation_id: Optional[str] = None,
|
113
|
+
webhook_url: Optional[str] = None,
|
114
|
+
name: Optional[str] = None,
|
115
|
+
):
|
116
|
+
"""List automations attached to this processor."""
|
117
|
+
request = self.prepare_list(processor_id, before, after, limit, order, automation_id, webhook_url, name)
|
118
|
+
response = self._client._prepared_request(request)
|
119
|
+
return response
|
120
|
+
|
121
|
+
def get_automation(self, processor_id: str, automation_id: str) -> Union[Link, Mailbox, Endpoint, Outlook]:
|
122
|
+
"""Get a specific automation attached to this processor."""
|
123
|
+
request = self.prepare_get(processor_id, automation_id)
|
124
|
+
response = self._client._prepared_request(request)
|
125
|
+
|
126
|
+
# Return the appropriate model based on the automation type
|
127
|
+
if response["object"] == "automation.link":
|
128
|
+
return Link.model_validate(response)
|
129
|
+
elif response["object"] == "automation.mailbox":
|
130
|
+
return Mailbox.model_validate(response)
|
131
|
+
elif response["object"] == "automation.endpoint":
|
132
|
+
return Endpoint.model_validate(response)
|
133
|
+
elif response["object"] == "automation.outlook":
|
134
|
+
return Outlook.model_validate(response)
|
135
|
+
else:
|
136
|
+
raise ValueError(f"Unknown automation type: {response.get('object')}")
|
137
|
+
|
138
|
+
def update_automation(
|
139
|
+
self,
|
140
|
+
processor_id: str,
|
141
|
+
automation_id: str,
|
142
|
+
automation_data: Union[UpdateLinkRequest, UpdateMailboxRequest, UpdateEndpointRequest, UpdateOutlookRequest],
|
143
|
+
) -> Union[Link, Mailbox, Endpoint, Outlook]:
|
144
|
+
"""Update an automation attached to this processor."""
|
145
|
+
request = self.prepare_update(processor_id, automation_id, automation_data)
|
146
|
+
response = self._client._prepared_request(request)
|
147
|
+
|
148
|
+
# Return the appropriate model based on the automation type
|
149
|
+
if response["object"] == "automation.link":
|
150
|
+
return Link.model_validate(response)
|
151
|
+
elif response["object"] == "automation.mailbox":
|
152
|
+
return Mailbox.model_validate(response)
|
153
|
+
elif response["object"] == "automation.endpoint":
|
154
|
+
return Endpoint.model_validate(response)
|
155
|
+
elif response["object"] == "automation.outlook":
|
156
|
+
return Outlook.model_validate(response)
|
157
|
+
else:
|
158
|
+
raise ValueError(f"Unknown automation type: {response.get('object')}")
|
159
|
+
|
160
|
+
def delete_automation(self, processor_id: str, automation_id: str) -> None:
|
161
|
+
"""Delete an automation attached to this processor."""
|
162
|
+
request = self.prepare_delete(processor_id, automation_id)
|
163
|
+
self._client._prepared_request(request)
|
164
|
+
print(f"Automation {automation_id} deleted from processor {processor_id}")
|
165
|
+
|
166
|
+
|
167
|
+
class AsyncAutomations(AsyncAPIResource, AutomationsMixin):
|
168
|
+
"""Async Automations API wrapper"""
|
169
|
+
|
170
|
+
def __init__(self, client: Any) -> None:
|
171
|
+
super().__init__(client=client)
|
172
|
+
self.mailboxes = AsyncMailboxes(client=client)
|
173
|
+
self.links = AsyncLinks(client=client)
|
174
|
+
self.outlook = AsyncOutlooks(client=client)
|
175
|
+
self.endpoints = AsyncEndpoints(client=client)
|
176
|
+
self.tests = AsyncTests(client=client)
|
177
|
+
self.logs = AsyncLogs(client=client)
|
178
|
+
|
179
|
+
async def verify_event(self, event_body: bytes, event_signature: str, secret: str) -> Any:
|
180
|
+
"""
|
181
|
+
Verify the signature of a webhook event.
|
182
|
+
"""
|
183
|
+
return self._verify_event(event_body, event_signature, secret)
|
184
|
+
|
185
|
+
async def list(
|
186
|
+
self,
|
187
|
+
processor_id: str,
|
188
|
+
before: Optional[str] = None,
|
189
|
+
after: Optional[str] = None,
|
190
|
+
limit: Optional[int] = 10,
|
191
|
+
order: Optional[Literal["asc", "desc"]] = "desc",
|
192
|
+
automation_id: Optional[str] = None,
|
193
|
+
webhook_url: Optional[str] = None,
|
194
|
+
name: Optional[str] = None,
|
195
|
+
):
|
196
|
+
"""List automations attached to this processor."""
|
197
|
+
request = self.prepare_list(processor_id, before, after, limit, order, automation_id, webhook_url, name)
|
198
|
+
response = await self._client._prepared_request(request)
|
199
|
+
return response
|
200
|
+
|
201
|
+
async def get(self, processor_id: str, automation_id: str) -> Union[Link, Mailbox, Endpoint, Outlook]:
|
202
|
+
"""Get a specific automation attached to this processor."""
|
203
|
+
request = self.prepare_get(processor_id, automation_id)
|
204
|
+
response = await self._client._prepared_request(request)
|
205
|
+
|
206
|
+
# Return the appropriate model based on the automation type
|
207
|
+
if response["object"] == "automation.link":
|
208
|
+
return Link.model_validate(response)
|
209
|
+
elif response["object"] == "automation.mailbox":
|
210
|
+
return Mailbox.model_validate(response)
|
211
|
+
elif response["object"] == "automation.endpoint":
|
212
|
+
return Endpoint.model_validate(response)
|
213
|
+
elif response["object"] == "automation.outlook":
|
214
|
+
return Outlook.model_validate(response)
|
215
|
+
else:
|
216
|
+
raise ValueError(f"Unknown automation type: {response.get('object')}")
|
217
|
+
|
218
|
+
async def update(
|
219
|
+
self,
|
220
|
+
processor_id: str,
|
221
|
+
automation_id: str,
|
222
|
+
automation_data: Union[UpdateLinkRequest, UpdateMailboxRequest, UpdateEndpointRequest, UpdateOutlookRequest],
|
223
|
+
) -> Union[Link, Mailbox, Endpoint, Outlook]:
|
224
|
+
"""Update an automation attached to this processor."""
|
225
|
+
request = self.prepare_update(processor_id, automation_id, automation_data)
|
226
|
+
response = await self._client._prepared_request(request)
|
227
|
+
|
228
|
+
# Return the appropriate model based on the automation type
|
229
|
+
if response["object"] == "automation.link":
|
230
|
+
return Link.model_validate(response)
|
231
|
+
elif response["object"] == "automation.mailbox":
|
232
|
+
return Mailbox.model_validate(response)
|
233
|
+
elif response["object"] == "automation.endpoint":
|
234
|
+
return Endpoint.model_validate(response)
|
235
|
+
elif response["object"] == "automation.outlook":
|
236
|
+
return Outlook.model_validate(response)
|
237
|
+
else:
|
238
|
+
raise ValueError(f"Unknown automation type: {response.get('object')}")
|
239
|
+
|
240
|
+
async def delete(self, processor_id: str, automation_id: str) -> None:
|
241
|
+
"""Delete an automation attached to this processor."""
|
242
|
+
request = self.prepare_delete(processor_id, automation_id)
|
243
|
+
await self._client._prepared_request(request)
|
244
|
+
print(f"Automation {automation_id} deleted from processor {processor_id}")
|
@@ -1,54 +1,33 @@
|
|
1
|
-
import
|
2
|
-
from pathlib import Path
|
3
|
-
from typing import Any, Dict, Literal, Optional
|
1
|
+
from typing import Literal, Optional
|
4
2
|
|
5
|
-
import
|
6
|
-
from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
|
7
|
-
from pydantic import HttpUrl
|
3
|
+
from pydantic_core import PydanticUndefined
|
8
4
|
|
9
5
|
from ...._resource import AsyncAPIResource, SyncAPIResource
|
10
6
|
from ...._utils.ai_models import assert_valid_model_extraction
|
11
7
|
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
8
|
from ....types.standards import PreparedRequest
|
18
9
|
|
19
10
|
|
20
11
|
class EndpointsMixin:
|
21
12
|
def prepare_create(
|
22
13
|
self,
|
14
|
+
processor_id: str,
|
23
15
|
name: str,
|
24
|
-
webhook_url:
|
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",
|
16
|
+
webhook_url: str,
|
31
17
|
model: str = "gpt-4o-mini",
|
32
|
-
|
33
|
-
|
18
|
+
webhook_headers: dict[str, str] = PydanticUndefined, # type: ignore[assignment]
|
19
|
+
need_validation: bool = PydanticUndefined, # type: ignore[assignment]
|
34
20
|
) -> PreparedRequest:
|
35
21
|
assert_valid_model_extraction(model)
|
36
22
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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'))
|
23
|
+
request = Endpoint(
|
24
|
+
processor_id=processor_id,
|
25
|
+
name=name,
|
26
|
+
webhook_url=webhook_url,
|
27
|
+
webhook_headers=webhook_headers,
|
28
|
+
need_validation=need_validation,
|
29
|
+
)
|
30
|
+
return PreparedRequest(method="POST", url="/v1/processors/automations/endpoints", data=request.model_dump(mode="json"))
|
52
31
|
|
53
32
|
def prepare_list(
|
54
33
|
self,
|
@@ -71,7 +50,7 @@ class EndpointsMixin:
|
|
71
50
|
# Remove None values
|
72
51
|
params = {k: v for k, v in params.items() if v is not None}
|
73
52
|
|
74
|
-
return PreparedRequest(method="GET", url="/v1/
|
53
|
+
return PreparedRequest(method="GET", url="/v1/processors/automations/endpoints", params=params)
|
75
54
|
|
76
55
|
def prepare_get(self, endpoint_id: str) -> PreparedRequest:
|
77
56
|
"""Get a specific endpoint configuration.
|
@@ -87,44 +66,20 @@ class EndpointsMixin:
|
|
87
66
|
def prepare_update(
|
88
67
|
self,
|
89
68
|
endpoint_id: str,
|
90
|
-
name:
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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,
|
69
|
+
name: str = PydanticUndefined, # type: ignore[assignment]
|
70
|
+
default_language: str = PydanticUndefined, # type: ignore[assignment]
|
71
|
+
webhook_url: str = PydanticUndefined, # type: ignore[assignment]
|
72
|
+
webhook_headers: dict[str, str] = PydanticUndefined, # type: ignore[assignment]
|
73
|
+
need_validation: bool = PydanticUndefined, # type: ignore[assignment]
|
100
74
|
) -> PreparedRequest:
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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'))
|
75
|
+
request = UpdateEndpointRequest(
|
76
|
+
name=name,
|
77
|
+
default_language=default_language,
|
78
|
+
webhook_url=webhook_url,
|
79
|
+
webhook_headers=webhook_headers,
|
80
|
+
need_validation=need_validation,
|
81
|
+
)
|
82
|
+
return PreparedRequest(method="PUT", url=f"/v1/processors/automations/endpoints/{endpoint_id}", data=request.model_dump(mode="json"))
|
128
83
|
|
129
84
|
def prepare_delete(self, endpoint_id: str) -> PreparedRequest:
|
130
85
|
return PreparedRequest(method="DELETE", url=f"/v1/processors/automations/endpoints/{endpoint_id}")
|
@@ -135,17 +90,11 @@ class Endpoints(SyncAPIResource, EndpointsMixin):
|
|
135
90
|
|
136
91
|
def create(
|
137
92
|
self,
|
93
|
+
processor_id: str,
|
138
94
|
name: str,
|
139
|
-
webhook_url:
|
140
|
-
|
141
|
-
|
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",
|
95
|
+
webhook_url: str,
|
96
|
+
webhook_headers: dict[str, str] = PydanticUndefined, # type: ignore[assignment]
|
97
|
+
need_validation: bool = PydanticUndefined, # type: ignore[assignment]
|
149
98
|
) -> Endpoint:
|
150
99
|
"""Create a new endpoint configuration.
|
151
100
|
|
@@ -163,9 +112,15 @@ class Endpoints(SyncAPIResource, EndpointsMixin):
|
|
163
112
|
Returns:
|
164
113
|
Endpoint: The created endpoint configuration
|
165
114
|
"""
|
166
|
-
request = self.prepare_create(
|
115
|
+
request = self.prepare_create(
|
116
|
+
processor_id=processor_id,
|
117
|
+
name=name,
|
118
|
+
webhook_url=webhook_url,
|
119
|
+
webhook_headers=webhook_headers,
|
120
|
+
need_validation=need_validation,
|
121
|
+
)
|
167
122
|
response = self._client._prepared_request(request)
|
168
|
-
print(f"Endpoint ID: {response['id']}. Endpoint available at https://www.
|
123
|
+
print(f"Endpoint ID: {response['id']}. Endpoint available at https://www.retab.dev/dashboard/processors/{response['id']}")
|
169
124
|
return Endpoint.model_validate(response)
|
170
125
|
|
171
126
|
def list(
|
@@ -210,16 +165,11 @@ class Endpoints(SyncAPIResource, EndpointsMixin):
|
|
210
165
|
def update(
|
211
166
|
self,
|
212
167
|
endpoint_id: str,
|
213
|
-
name:
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
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,
|
168
|
+
name: str = PydanticUndefined, # type: ignore[assignment]
|
169
|
+
default_language: str = PydanticUndefined, # type: ignore[assignment]
|
170
|
+
webhook_url: str = PydanticUndefined, # type: ignore[assignment]
|
171
|
+
webhook_headers: dict[str, str] = PydanticUndefined, # type: ignore[assignment]
|
172
|
+
need_validation: bool = PydanticUndefined, # type: ignore[assignment]
|
223
173
|
) -> Endpoint:
|
224
174
|
"""Update an endpoint configuration.
|
225
175
|
|
@@ -238,7 +188,14 @@ class Endpoints(SyncAPIResource, EndpointsMixin):
|
|
238
188
|
Returns:
|
239
189
|
Endpoint: The updated endpoint configuration
|
240
190
|
"""
|
241
|
-
request = self.prepare_update(
|
191
|
+
request = self.prepare_update(
|
192
|
+
endpoint_id=endpoint_id,
|
193
|
+
name=name,
|
194
|
+
default_language=default_language,
|
195
|
+
webhook_url=webhook_url,
|
196
|
+
webhook_headers=webhook_headers,
|
197
|
+
need_validation=need_validation,
|
198
|
+
)
|
242
199
|
response = self._client._prepared_request(request)
|
243
200
|
return Endpoint.model_validate(response)
|
244
201
|
|
@@ -258,22 +215,22 @@ class AsyncEndpoints(AsyncAPIResource, EndpointsMixin):
|
|
258
215
|
|
259
216
|
async def create(
|
260
217
|
self,
|
218
|
+
processor_id: str,
|
261
219
|
name: str,
|
262
|
-
webhook_url:
|
263
|
-
|
264
|
-
|
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",
|
220
|
+
webhook_url: str,
|
221
|
+
webhook_headers: dict[str, str] = PydanticUndefined, # type: ignore[assignment]
|
222
|
+
need_validation: bool = PydanticUndefined, # type: ignore[assignment]
|
272
223
|
) -> Endpoint:
|
273
|
-
request = self.prepare_create(
|
224
|
+
request = self.prepare_create(
|
225
|
+
processor_id=processor_id,
|
226
|
+
name=name,
|
227
|
+
webhook_url=webhook_url,
|
228
|
+
webhook_headers=webhook_headers,
|
229
|
+
need_validation=need_validation,
|
230
|
+
)
|
274
231
|
response = await self._client._prepared_request(request)
|
275
|
-
print(f"Endpoint ID: {response['id']}. Endpoint available at https://www.
|
276
|
-
|
232
|
+
print(f"Endpoint ID: {response['id']}. Endpoint available at https://www.retab.dev/dashboard/processors/{response['id']}")
|
233
|
+
|
277
234
|
return Endpoint.model_validate(response)
|
278
235
|
|
279
236
|
async def list(
|
@@ -297,18 +254,20 @@ class AsyncEndpoints(AsyncAPIResource, EndpointsMixin):
|
|
297
254
|
async def update(
|
298
255
|
self,
|
299
256
|
endpoint_id: str,
|
300
|
-
name:
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
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,
|
257
|
+
name: str = PydanticUndefined, # type: ignore[assignment]
|
258
|
+
default_language: str = PydanticUndefined, # type: ignore[assignment]
|
259
|
+
webhook_url: str = PydanticUndefined, # type: ignore[assignment]
|
260
|
+
webhook_headers: dict[str, str] = PydanticUndefined, # type: ignore[assignment]
|
261
|
+
need_validation: bool = PydanticUndefined, # type: ignore[assignment]
|
310
262
|
) -> Endpoint:
|
311
|
-
request = self.prepare_update(
|
263
|
+
request = self.prepare_update(
|
264
|
+
endpoint_id=endpoint_id,
|
265
|
+
name=name,
|
266
|
+
default_language=default_language,
|
267
|
+
webhook_url=webhook_url,
|
268
|
+
webhook_headers=webhook_headers,
|
269
|
+
need_validation=need_validation,
|
270
|
+
)
|
312
271
|
response = await self._client._prepared_request(request)
|
313
272
|
return Endpoint.model_validate(response)
|
314
273
|
|