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
@@ -1,32 +1,28 @@
|
|
1
|
-
from typing import Any, Dict, List, Optional, TypedDict, Union, Literal
|
2
1
|
from io import IOBase
|
3
2
|
from pathlib import Path
|
3
|
+
from typing import Any, Dict, List, Optional, TypedDict, Union
|
4
4
|
|
5
5
|
import PIL.Image
|
6
|
+
from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
|
6
7
|
from pydantic import HttpUrl
|
7
8
|
|
8
9
|
from .._resource import AsyncAPIResource, SyncAPIResource
|
9
|
-
from ..
|
10
|
+
from .._utils.mime import prepare_mime_document
|
10
11
|
from ..types.evals import (
|
12
|
+
CreateIterationRequest,
|
13
|
+
DistancesResult,
|
14
|
+
DocumentItem,
|
11
15
|
Evaluation,
|
12
16
|
EvaluationDocument,
|
13
17
|
Iteration,
|
14
|
-
DistancesResult,
|
15
|
-
PredictionData,
|
16
|
-
AddIterationFromJsonlRequest,
|
17
|
-
DocumentItem,
|
18
18
|
UpdateEvaluationDocumentRequest,
|
19
|
-
|
20
|
-
CreateIterationRequest,
|
19
|
+
UpdateEvaluationRequest,
|
21
20
|
)
|
22
|
-
from ..types.
|
23
|
-
|
21
|
+
from ..types.inference_settings import InferenceSettings
|
24
22
|
from ..types.mime import MIMEData
|
25
|
-
from .._utils.mime import prepare_mime_document
|
26
23
|
from ..types.modalities import Modality
|
27
|
-
from
|
28
|
-
|
29
|
-
from tqdm import tqdm
|
24
|
+
from ..types.browser_canvas import BrowserCanvas
|
25
|
+
from ..types.standards import PreparedRequest
|
30
26
|
|
31
27
|
|
32
28
|
class DeleteResponse(TypedDict):
|
@@ -82,21 +78,17 @@ class EvalsMixin:
|
|
82
78
|
Only the provided fields will be updated. Fields set to None will be excluded from the update.
|
83
79
|
"""
|
84
80
|
# Build a dictionary with only the provided fields
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
if default_inference_settings is not None:
|
97
|
-
update_data["default_inference_settings"] = default_inference_settings.model_dump(exclude_none=True, mode="json")
|
98
|
-
|
99
|
-
return PreparedRequest(method="PATCH", url=f"/v1/evals/{evaluation_id}", data=update_data)
|
81
|
+
|
82
|
+
update_request = UpdateEvaluationRequest(
|
83
|
+
name=name,
|
84
|
+
project_id=project_id,
|
85
|
+
json_schema=json_schema,
|
86
|
+
documents=documents,
|
87
|
+
iterations=iterations,
|
88
|
+
default_inference_settings=default_inference_settings,
|
89
|
+
)
|
90
|
+
|
91
|
+
return PreparedRequest(method="PATCH", url=f"/v1/evals/{evaluation_id}", data=update_request.model_dump(exclude_none=True, mode="json"))
|
100
92
|
|
101
93
|
def prepare_list(self, project_id: Optional[str] = None) -> PreparedRequest:
|
102
94
|
params = {}
|
@@ -114,9 +106,7 @@ class DocumentsMixin:
|
|
114
106
|
|
115
107
|
def prepare_create(self, evaluation_id: str, document: MIMEData, annotation: Dict[str, Any]) -> PreparedRequest:
|
116
108
|
# Serialize the MIMEData
|
117
|
-
|
118
109
|
document_item = DocumentItem(mime_data=document, annotation=annotation, annotation_metadata=None)
|
119
|
-
|
120
110
|
return PreparedRequest(method="POST", url=f"/v1/evals/{evaluation_id}/documents", data=document_item.model_dump(mode="json"))
|
121
111
|
|
122
112
|
def prepare_list(self, evaluation_id: str, filename: Optional[str] = None) -> PreparedRequest:
|
@@ -127,7 +117,6 @@ class DocumentsMixin:
|
|
127
117
|
|
128
118
|
def prepare_update(self, evaluation_id: str, document_id: str, annotation: Dict[str, Any]) -> PreparedRequest:
|
129
119
|
update_request = UpdateEvaluationDocumentRequest(annotation=annotation, annotation_metadata=None)
|
130
|
-
|
131
120
|
return PreparedRequest(method="PUT", url=f"/v1/evals/{evaluation_id}/documents/{document_id}", data=update_request.model_dump(mode="json", exclude_none=True))
|
132
121
|
|
133
122
|
def prepare_delete(self, evaluation_id: str, document_id: str) -> PreparedRequest:
|
@@ -153,10 +142,10 @@ class IterationsMixin:
|
|
153
142
|
modality: Modality = "native",
|
154
143
|
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
155
144
|
image_resolution_dpi: int = 96,
|
156
|
-
browser_canvas:
|
145
|
+
browser_canvas: BrowserCanvas = "A4",
|
157
146
|
n_consensus: int = 1,
|
158
147
|
) -> PreparedRequest:
|
159
|
-
|
148
|
+
inference_settings = InferenceSettings(
|
160
149
|
model=model,
|
161
150
|
temperature=temperature,
|
162
151
|
modality=modality,
|
@@ -166,18 +155,30 @@ class IterationsMixin:
|
|
166
155
|
n_consensus=n_consensus,
|
167
156
|
)
|
168
157
|
|
169
|
-
|
158
|
+
request = CreateIterationRequest(inference_settings=inference_settings, json_schema=json_schema)
|
170
159
|
|
171
|
-
return PreparedRequest(method="POST", url=f"/v1/evals/{evaluation_id}/iterations/create", data=
|
160
|
+
return PreparedRequest(method="POST", url=f"/v1/evals/{evaluation_id}/iterations/create", data=request.model_dump(exclude_none=True, mode="json"))
|
172
161
|
|
173
162
|
def prepare_update(
|
174
|
-
self,
|
163
|
+
self,
|
164
|
+
iteration_id: str,
|
165
|
+
json_schema: Dict[str, Any],
|
166
|
+
model: str,
|
167
|
+
temperature: float = 0.0,
|
168
|
+
modality: Modality = "native",
|
169
|
+
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
170
|
+
image_resolution_dpi: int = 96,
|
171
|
+
browser_canvas: BrowserCanvas = "A4",
|
172
|
+
n_consensus: int = 1,
|
175
173
|
) -> PreparedRequest:
|
176
174
|
inference_settings = InferenceSettings(
|
177
175
|
model=model,
|
178
176
|
temperature=temperature,
|
177
|
+
modality=modality,
|
178
|
+
reasoning_effort=reasoning_effort,
|
179
179
|
image_resolution_dpi=image_resolution_dpi,
|
180
180
|
browser_canvas=browser_canvas,
|
181
|
+
n_consensus=n_consensus,
|
181
182
|
)
|
182
183
|
|
183
184
|
iteration_data = Iteration(id=iteration_id, json_schema=json_schema, inference_settings=inference_settings, predictions=[])
|
@@ -261,7 +262,13 @@ class Evals(SyncAPIResource, EvalsMixin):
|
|
261
262
|
HTTPException if the request fails
|
262
263
|
"""
|
263
264
|
request = self.prepare_update(
|
264
|
-
evaluation_id=evaluation_id,
|
265
|
+
evaluation_id=evaluation_id,
|
266
|
+
name=name,
|
267
|
+
project_id=project_id,
|
268
|
+
json_schema=json_schema,
|
269
|
+
documents=documents,
|
270
|
+
iterations=iterations,
|
271
|
+
default_inference_settings=default_inference_settings,
|
265
272
|
)
|
266
273
|
response = self._client._prepared_request(request)
|
267
274
|
return Evaluation(**response)
|
@@ -429,7 +436,7 @@ class Iterations(SyncAPIResource, IterationsMixin):
|
|
429
436
|
json_schema: Optional[Dict[str, Any]] = None,
|
430
437
|
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
431
438
|
image_resolution_dpi: int = 96,
|
432
|
-
browser_canvas:
|
439
|
+
browser_canvas: BrowserCanvas = "A4",
|
433
440
|
n_consensus: int = 1,
|
434
441
|
) -> Iteration:
|
435
442
|
"""
|
@@ -445,7 +452,7 @@ class Iterations(SyncAPIResource, IterationsMixin):
|
|
445
452
|
image_resolution_dpi: The DPI of the image. Defaults to 96.
|
446
453
|
browser_canvas: The canvas size of the browser. Must be one of:
|
447
454
|
- "A3" (11.7in x 16.54in)
|
448
|
-
- "A4" (8.27in x 11.7in)
|
455
|
+
- "A4" (8.27in x 11.7in)
|
449
456
|
- "A5" (5.83in x 8.27in)
|
450
457
|
Defaults to "A4".
|
451
458
|
n_consensus: Number of consensus iterations to perform
|
@@ -572,7 +579,13 @@ class AsyncEvals(AsyncAPIResource, EvalsMixin):
|
|
572
579
|
HTTPException if the request fails
|
573
580
|
"""
|
574
581
|
request = self.prepare_update(
|
575
|
-
evaluation_id=evaluation_id,
|
582
|
+
evaluation_id=evaluation_id,
|
583
|
+
name=name,
|
584
|
+
project_id=project_id,
|
585
|
+
json_schema=json_schema,
|
586
|
+
documents=documents,
|
587
|
+
iterations=iterations,
|
588
|
+
default_inference_settings=default_inference_settings,
|
576
589
|
)
|
577
590
|
response = await self._client._prepared_request(request)
|
578
591
|
return Evaluation(**response)
|
@@ -739,7 +752,7 @@ class AsyncIterations(AsyncAPIResource, IterationsMixin):
|
|
739
752
|
json_schema: Optional[Dict[str, Any]] = None,
|
740
753
|
reasoning_effort: ChatCompletionReasoningEffort = "medium",
|
741
754
|
image_resolution_dpi: int = 96,
|
742
|
-
browser_canvas:
|
755
|
+
browser_canvas: BrowserCanvas = "A4",
|
743
756
|
n_consensus: int = 1,
|
744
757
|
) -> Iteration:
|
745
758
|
"""
|
@@ -755,7 +768,7 @@ class AsyncIterations(AsyncAPIResource, IterationsMixin):
|
|
755
768
|
image_resolution_dpi: The DPI of the image. Defaults to 96.
|
756
769
|
browser_canvas: The canvas size of the browser. Must be one of:
|
757
770
|
- "A3" (11.7in x 16.54in)
|
758
|
-
- "A4" (8.27in x 11.7in)
|
771
|
+
- "A4" (8.27in x 11.7in)
|
759
772
|
- "A5" (5.83in x 8.27in)
|
760
773
|
Defaults to "A4".
|
761
774
|
n_consensus: Number of consensus iterations to perform
|
@@ -0,0 +1,301 @@
|
|
1
|
+
from typing import Any, Dict, List
|
2
|
+
|
3
|
+
from ..._resource import AsyncAPIResource, SyncAPIResource
|
4
|
+
from ...types.evaluations import Evaluation, PatchEvaluationRequest, ListEvaluationParams, CreateEvaluation
|
5
|
+
from ...types.inference_settings import InferenceSettings
|
6
|
+
from ...types.standards import PreparedRequest, DeleteResponse, FieldUnset
|
7
|
+
from .documents import Documents, AsyncDocuments
|
8
|
+
from .iterations import Iterations, AsyncIterations
|
9
|
+
|
10
|
+
|
11
|
+
class EvaluationsMixin:
|
12
|
+
def prepare_create(
|
13
|
+
self,
|
14
|
+
name: str,
|
15
|
+
json_schema: dict[str, Any],
|
16
|
+
project_id: str = FieldUnset,
|
17
|
+
default_inference_settings: InferenceSettings = FieldUnset,
|
18
|
+
) -> PreparedRequest:
|
19
|
+
# Use CreateEvaluation model
|
20
|
+
eval_data = CreateEvaluation(
|
21
|
+
name=name,
|
22
|
+
json_schema=json_schema,
|
23
|
+
project_id=project_id,
|
24
|
+
default_inference_settings=default_inference_settings,
|
25
|
+
)
|
26
|
+
return PreparedRequest(method="POST", url="/v1/evaluations", data=eval_data.model_dump(exclude_none=True, mode="json"))
|
27
|
+
|
28
|
+
def prepare_get(self, evaluation_id: str) -> PreparedRequest:
|
29
|
+
return PreparedRequest(method="GET", url=f"/v1/evaluations/{evaluation_id}")
|
30
|
+
|
31
|
+
def prepare_update(
|
32
|
+
self,
|
33
|
+
evaluation_id: str,
|
34
|
+
name: str = FieldUnset,
|
35
|
+
project_id: str = FieldUnset,
|
36
|
+
json_schema: dict[str, Any] = FieldUnset,
|
37
|
+
default_inference_settings: InferenceSettings = FieldUnset,
|
38
|
+
) -> PreparedRequest:
|
39
|
+
"""
|
40
|
+
Prepare a request to update an evaluation with partial updates.
|
41
|
+
|
42
|
+
Only the provided fields will be updated. Fields set to None will be excluded from the update.
|
43
|
+
"""
|
44
|
+
# Build a dictionary with only the provided fields
|
45
|
+
data = PatchEvaluationRequest(
|
46
|
+
name=name,
|
47
|
+
project_id=project_id,
|
48
|
+
json_schema=json_schema,
|
49
|
+
default_inference_settings=default_inference_settings,
|
50
|
+
).model_dump(exclude_unset=True, mode="json")
|
51
|
+
|
52
|
+
return PreparedRequest(method="PATCH", url=f"/v1/evaluations/{evaluation_id}", data=data)
|
53
|
+
|
54
|
+
def prepare_list(self, project_id: str = FieldUnset) -> PreparedRequest:
|
55
|
+
"""
|
56
|
+
Prepare a request to list evaluations.
|
57
|
+
|
58
|
+
Usage:
|
59
|
+
>>> client.evals.list(project_id="project_id") # List all evaluations for a project
|
60
|
+
>>> client.evals.list() # List all evaluations (no project_id)
|
61
|
+
|
62
|
+
This does not work:
|
63
|
+
>>> client.evals.list(project_id=None)
|
64
|
+
|
65
|
+
Args:
|
66
|
+
project_id: The project ID to list evaluations for
|
67
|
+
|
68
|
+
Returns:
|
69
|
+
PreparedRequest: The prepared request
|
70
|
+
"""
|
71
|
+
params = ListEvaluationParams(project_id=project_id).model_dump(exclude_unset=True, exclude_defaults=True, mode="json")
|
72
|
+
return PreparedRequest(method="GET", url="/v1/evaluations", params=params)
|
73
|
+
|
74
|
+
def prepare_delete(self, id: str) -> PreparedRequest:
|
75
|
+
return PreparedRequest(method="DELETE", url=f"/v1/evaluations/{id}")
|
76
|
+
|
77
|
+
|
78
|
+
class Evaluations(SyncAPIResource, EvaluationsMixin):
|
79
|
+
"""Evaluations API wrapper"""
|
80
|
+
|
81
|
+
def __init__(self, *args, **kwargs):
|
82
|
+
super().__init__(*args, **kwargs)
|
83
|
+
self.documents = Documents(self._client)
|
84
|
+
self.iterations = Iterations(self._client)
|
85
|
+
|
86
|
+
def create(
|
87
|
+
self,
|
88
|
+
name: str,
|
89
|
+
json_schema: dict[str, Any],
|
90
|
+
project_id: str = FieldUnset,
|
91
|
+
default_inference_settings: InferenceSettings = FieldUnset,
|
92
|
+
) -> Evaluation:
|
93
|
+
"""
|
94
|
+
Create a new evaluation.
|
95
|
+
|
96
|
+
Args:
|
97
|
+
name: The name of the evaluation
|
98
|
+
json_schema: The JSON schema for the evaluation
|
99
|
+
project_id: The project ID to associate with the evaluation
|
100
|
+
documents: The documents to associate with the evaluation
|
101
|
+
default_inference_settings: The default inference settings to associate with the evaluation
|
102
|
+
|
103
|
+
Returns:
|
104
|
+
Evaluation: The created evaluation
|
105
|
+
Raises:
|
106
|
+
HTTPException if the request fails
|
107
|
+
"""
|
108
|
+
request = self.prepare_create(name, json_schema, project_id, default_inference_settings=default_inference_settings)
|
109
|
+
response = self._client._prepared_request(request)
|
110
|
+
return Evaluation(**response)
|
111
|
+
|
112
|
+
def get(self, evaluation_id: str) -> Evaluation:
|
113
|
+
"""
|
114
|
+
Get an evaluation by ID.
|
115
|
+
|
116
|
+
Args:
|
117
|
+
evaluation_id: The ID of the evaluation to retrieve
|
118
|
+
|
119
|
+
Returns:
|
120
|
+
Evaluation: The evaluation
|
121
|
+
Raises:
|
122
|
+
HTTPException if the request fails
|
123
|
+
"""
|
124
|
+
request = self.prepare_get(evaluation_id)
|
125
|
+
response = self._client._prepared_request(request)
|
126
|
+
return Evaluation(**response)
|
127
|
+
|
128
|
+
def update(
|
129
|
+
self,
|
130
|
+
evaluation_id: str,
|
131
|
+
name: str = FieldUnset,
|
132
|
+
project_id: str = FieldUnset,
|
133
|
+
json_schema: dict[str, Any] = FieldUnset,
|
134
|
+
default_inference_settings: InferenceSettings = FieldUnset,
|
135
|
+
) -> Evaluation:
|
136
|
+
"""
|
137
|
+
Update an evaluation with partial updates.
|
138
|
+
|
139
|
+
Args:
|
140
|
+
evaluation_id: The ID of the evaluation to update
|
141
|
+
name: Optional new name for the evaluation
|
142
|
+
project_id: Optional new project ID
|
143
|
+
json_schema: Optional new JSON schema
|
144
|
+
documents: Optional list of documents to update
|
145
|
+
iterations: Optional list of iterations to update
|
146
|
+
default_inference_settings: Optional annotation properties
|
147
|
+
|
148
|
+
Returns:
|
149
|
+
Evaluation: The updated evaluation
|
150
|
+
Raises:
|
151
|
+
HTTPException if the request fails
|
152
|
+
"""
|
153
|
+
request = self.prepare_update(
|
154
|
+
evaluation_id=evaluation_id,
|
155
|
+
name=name,
|
156
|
+
project_id=project_id,
|
157
|
+
json_schema=json_schema,
|
158
|
+
default_inference_settings=default_inference_settings,
|
159
|
+
)
|
160
|
+
response = self._client._prepared_request(request)
|
161
|
+
return Evaluation(**response)
|
162
|
+
|
163
|
+
def list(self, project_id: str = FieldUnset) -> List[Evaluation]:
|
164
|
+
"""
|
165
|
+
List evaluations for a project.
|
166
|
+
|
167
|
+
Args:
|
168
|
+
project_id: The project ID to list evaluations for
|
169
|
+
|
170
|
+
Returns:
|
171
|
+
List[Evaluation]: List of evaluations
|
172
|
+
Raises:
|
173
|
+
HTTPException if the request fails
|
174
|
+
"""
|
175
|
+
request = self.prepare_list(project_id)
|
176
|
+
response = self._client._prepared_request(request)
|
177
|
+
return [Evaluation(**item) for item in response.get("data", [])]
|
178
|
+
|
179
|
+
def delete(self, evaluation_id: str) -> DeleteResponse:
|
180
|
+
"""
|
181
|
+
Delete an evaluation.
|
182
|
+
|
183
|
+
Args:
|
184
|
+
evaluation_id: The ID of the evaluation to delete
|
185
|
+
|
186
|
+
Returns:
|
187
|
+
DeleteResponse: The response containing success status and ID
|
188
|
+
Raises:
|
189
|
+
HTTPException if the request fails
|
190
|
+
"""
|
191
|
+
request = self.prepare_delete(evaluation_id)
|
192
|
+
return self._client._prepared_request(request)
|
193
|
+
|
194
|
+
|
195
|
+
class AsyncEvaluations(AsyncAPIResource, EvaluationsMixin):
|
196
|
+
"""Async Evaluations API wrapper"""
|
197
|
+
|
198
|
+
def __init__(self, *args, **kwargs):
|
199
|
+
super().__init__(*args, **kwargs)
|
200
|
+
self.documents = AsyncDocuments(self._client)
|
201
|
+
self.iterations = AsyncIterations(self._client)
|
202
|
+
|
203
|
+
async def create(self, name: str, json_schema: Dict[str, Any], project_id: str = FieldUnset) -> Evaluation:
|
204
|
+
"""
|
205
|
+
Create a new evaluation.
|
206
|
+
|
207
|
+
Args:
|
208
|
+
name: The name of the evaluation
|
209
|
+
json_schema: The JSON schema for the evaluation
|
210
|
+
project_id: The project ID to associate with the evaluation
|
211
|
+
|
212
|
+
Returns:
|
213
|
+
Evaluation: The created evaluation
|
214
|
+
Raises:
|
215
|
+
HTTPException if the request fails
|
216
|
+
"""
|
217
|
+
request = self.prepare_create(name, json_schema, project_id=project_id)
|
218
|
+
response = await self._client._prepared_request(request)
|
219
|
+
return Evaluation(**response)
|
220
|
+
|
221
|
+
async def get(self, evaluation_id: str) -> Evaluation:
|
222
|
+
"""
|
223
|
+
Get an evaluation by ID.
|
224
|
+
|
225
|
+
Args:
|
226
|
+
evaluation_id: The ID of the evaluation to retrieve
|
227
|
+
|
228
|
+
Returns:
|
229
|
+
Evaluation: The evaluation
|
230
|
+
Raises:
|
231
|
+
HTTPException if the request fails
|
232
|
+
"""
|
233
|
+
request = self.prepare_get(evaluation_id)
|
234
|
+
response = await self._client._prepared_request(request)
|
235
|
+
return Evaluation(**response)
|
236
|
+
|
237
|
+
async def update(
|
238
|
+
self,
|
239
|
+
evaluation_id: str,
|
240
|
+
name: str = FieldUnset,
|
241
|
+
project_id: str = FieldUnset,
|
242
|
+
json_schema: dict[str, Any] = FieldUnset,
|
243
|
+
default_inference_settings: InferenceSettings = FieldUnset,
|
244
|
+
) -> Evaluation:
|
245
|
+
"""
|
246
|
+
Update an evaluation with partial updates.
|
247
|
+
|
248
|
+
Args:
|
249
|
+
id: The ID of the evaluation to update
|
250
|
+
name: Optional new name for the evaluation
|
251
|
+
project_id: Optional new project ID
|
252
|
+
json_schema: Optional new JSON schema
|
253
|
+
documents: Optional list of documents to update
|
254
|
+
iterations: Optional list of iterations to update
|
255
|
+
default_inference_settings: Optional annotation properties
|
256
|
+
|
257
|
+
Returns:
|
258
|
+
Evaluation: The updated evaluation
|
259
|
+
Raises:
|
260
|
+
HTTPException if the request fails
|
261
|
+
"""
|
262
|
+
request = self.prepare_update(
|
263
|
+
evaluation_id=evaluation_id,
|
264
|
+
name=name,
|
265
|
+
project_id=project_id,
|
266
|
+
json_schema=json_schema,
|
267
|
+
default_inference_settings=default_inference_settings,
|
268
|
+
)
|
269
|
+
response = await self._client._prepared_request(request)
|
270
|
+
return Evaluation(**response)
|
271
|
+
|
272
|
+
async def list(self, project_id: str = FieldUnset) -> List[Evaluation]:
|
273
|
+
"""
|
274
|
+
List evaluations for a project.
|
275
|
+
|
276
|
+
Args:
|
277
|
+
project_id: The project ID to list evaluations for
|
278
|
+
|
279
|
+
Returns:
|
280
|
+
List[Evaluation]: List of evaluations
|
281
|
+
Raises:
|
282
|
+
HTTPException if the request fails
|
283
|
+
"""
|
284
|
+
request = self.prepare_list(project_id)
|
285
|
+
response = await self._client._prepared_request(request)
|
286
|
+
return [Evaluation(**item) for item in response.get("data", [])]
|
287
|
+
|
288
|
+
async def delete(self, evaluation_id: str) -> DeleteResponse:
|
289
|
+
"""
|
290
|
+
Delete an evaluation.
|
291
|
+
|
292
|
+
Args:
|
293
|
+
evaluation_id: The ID of the evaluation to delete
|
294
|
+
|
295
|
+
Returns:
|
296
|
+
DeleteResponse: The response containing success status and ID
|
297
|
+
Raises:
|
298
|
+
HTTPException if the request fails
|
299
|
+
"""
|
300
|
+
request = self.prepare_delete(evaluation_id)
|
301
|
+
return await self._client._prepared_request(request)
|