agenta 0.32.0a1__py3-none-any.whl → 0.33.0__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.
- agenta/__init__.py +2 -0
- agenta/client/backend/__init__.py +39 -31
- agenta/client/backend/admin/__init__.py +1 -0
- agenta/client/backend/admin/client.py +576 -0
- agenta/client/backend/apps/client.py +450 -68
- agenta/client/backend/bases/client.py +10 -10
- agenta/client/backend/client.py +112 -122
- agenta/client/backend/containers/client.py +70 -28
- agenta/client/backend/core/http_client.py +3 -3
- agenta/client/backend/environments/client.py +8 -8
- agenta/client/backend/evaluations/client.py +46 -52
- agenta/client/backend/evaluators/client.py +32 -32
- agenta/client/backend/human_evaluations/__init__.py +1 -0
- agenta/client/backend/human_evaluations/client.py +1692 -0
- agenta/client/backend/observability/__init__.py +4 -0
- agenta/client/backend/observability/client.py +221 -744
- agenta/client/backend/testsets/client.py +38 -202
- agenta/client/backend/types/__init__.py +34 -28
- agenta/client/backend/types/account_response.py +24 -0
- agenta/client/backend/types/app_variant_revision.py +2 -1
- agenta/client/backend/types/{create_trace_response.py → delete_evaluation.py} +2 -3
- agenta/client/backend/types/{evaluation_scenario_score_update.py → legacy_scope_request.py} +2 -2
- agenta/client/backend/types/legacy_scopes_response.py +29 -0
- agenta/client/backend/types/{human_evaluation_update.py → legacy_user_request.py} +4 -4
- agenta/client/backend/types/{span_variant.py → legacy_user_response.py} +2 -4
- agenta/client/backend/types/organization_membership_request.py +25 -0
- agenta/client/backend/types/organization_request.py +23 -0
- agenta/client/backend/types/permission.py +4 -0
- agenta/client/backend/types/{llm_tokens.py → project_membership_request.py} +8 -5
- agenta/client/backend/types/project_request.py +26 -0
- agenta/client/backend/types/project_scope.py +29 -0
- agenta/client/backend/types/provider_kind.py +1 -1
- agenta/client/backend/types/reference.py +22 -0
- agenta/client/backend/types/role.py +15 -0
- agenta/client/backend/types/scopes_response_model.py +22 -0
- agenta/client/backend/types/score.py +1 -1
- agenta/client/backend/types/secret_response_dto.py +2 -2
- agenta/client/backend/types/user_request.py +22 -0
- agenta/client/backend/types/workspace_membership_request.py +26 -0
- agenta/client/backend/types/workspace_request.py +25 -0
- agenta/client/backend/variants/client.py +208 -42
- agenta/client/backend/vault/client.py +11 -9
- agenta/sdk/__init__.py +3 -0
- agenta/sdk/agenta_init.py +3 -1
- agenta/sdk/assets.py +4 -4
- agenta/sdk/decorators/routing.py +129 -23
- agenta/sdk/decorators/tracing.py +16 -4
- agenta/sdk/litellm/litellm.py +44 -8
- agenta/sdk/litellm/mockllm.py +2 -2
- agenta/sdk/litellm/mocks/__init__.py +9 -3
- agenta/sdk/managers/apps.py +64 -0
- agenta/sdk/managers/shared.py +2 -2
- agenta/sdk/middleware/auth.py +156 -53
- agenta/sdk/middleware/config.py +28 -16
- agenta/sdk/middleware/inline.py +1 -1
- agenta/sdk/middleware/mock.py +1 -1
- agenta/sdk/middleware/otel.py +1 -1
- agenta/sdk/middleware/vault.py +1 -1
- agenta/sdk/tracing/exporters.py +0 -1
- agenta/sdk/tracing/inline.py +26 -30
- agenta/sdk/types.py +12 -9
- {agenta-0.32.0a1.dist-info → agenta-0.33.0.dist-info}/METADATA +23 -20
- {agenta-0.32.0a1.dist-info → agenta-0.33.0.dist-info}/RECORD +69 -63
- agenta/client/backend/observability_v_1/__init__.py +0 -5
- agenta/client/backend/observability_v_1/client.py +0 -763
- agenta/client/backend/types/create_span.py +0 -45
- agenta/client/backend/types/human_evaluation_scenario_update.py +0 -30
- agenta/client/backend/types/new_human_evaluation.py +0 -27
- agenta/client/backend/types/outputs.py +0 -5
- agenta/client/backend/types/span.py +0 -42
- agenta/client/backend/types/span_detail.py +0 -44
- agenta/client/backend/types/span_status_code.py +0 -5
- agenta/client/backend/types/trace_detail.py +0 -44
- agenta/client/backend/types/with_pagination.py +0 -26
- /agenta/client/backend/{observability_v_1 → observability}/types/__init__.py +0 -0
- /agenta/client/backend/{observability_v_1 → observability}/types/format.py +0 -0
- /agenta/client/backend/{observability_v_1 → observability}/types/query_analytics_response.py +0 -0
- /agenta/client/backend/{observability_v_1 → observability}/types/query_traces_response.py +0 -0
- {agenta-0.32.0a1.dist-info → agenta-0.33.0.dist-info}/WHEEL +0 -0
- {agenta-0.32.0a1.dist-info → agenta-0.33.0.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,1692 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from ..core.client_wrapper import SyncClientWrapper
|
|
5
|
+
from ..core.request_options import RequestOptions
|
|
6
|
+
from ..types.human_evaluation import HumanEvaluation
|
|
7
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
8
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
9
|
+
from ..types.http_validation_error import HttpValidationError
|
|
10
|
+
from json.decoder import JSONDecodeError
|
|
11
|
+
from ..core.api_error import ApiError
|
|
12
|
+
from ..types.evaluation_type import EvaluationType
|
|
13
|
+
from ..types.simple_evaluation_output import SimpleEvaluationOutput
|
|
14
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
15
|
+
from ..types.evaluation_status_enum import EvaluationStatusEnum
|
|
16
|
+
from ..types.human_evaluation_scenario import HumanEvaluationScenario
|
|
17
|
+
from ..types.score import Score
|
|
18
|
+
from ..types.human_evaluation_scenario_output import HumanEvaluationScenarioOutput
|
|
19
|
+
from ..types.human_evaluation_scenario_input import HumanEvaluationScenarioInput
|
|
20
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
21
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
22
|
+
|
|
23
|
+
# this is used as the default value for optional parameters
|
|
24
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class HumanEvaluationsClient:
|
|
28
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
29
|
+
self._client_wrapper = client_wrapper
|
|
30
|
+
|
|
31
|
+
def fetch_list_human_evaluations(
|
|
32
|
+
self, *, app_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
33
|
+
) -> typing.List[HumanEvaluation]:
|
|
34
|
+
"""
|
|
35
|
+
Fetches a list of evaluations, optionally filtered by an app ID.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
app_id (Optional[str]): An optional app ID to filter the evaluations.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
List[HumanEvaluation]: A list of evaluations.
|
|
42
|
+
|
|
43
|
+
Parameters
|
|
44
|
+
----------
|
|
45
|
+
app_id : str
|
|
46
|
+
|
|
47
|
+
request_options : typing.Optional[RequestOptions]
|
|
48
|
+
Request-specific configuration.
|
|
49
|
+
|
|
50
|
+
Returns
|
|
51
|
+
-------
|
|
52
|
+
typing.List[HumanEvaluation]
|
|
53
|
+
Successful Response
|
|
54
|
+
|
|
55
|
+
Examples
|
|
56
|
+
--------
|
|
57
|
+
from agenta import AgentaApi
|
|
58
|
+
|
|
59
|
+
client = AgentaApi(
|
|
60
|
+
api_key="YOUR_API_KEY",
|
|
61
|
+
base_url="https://yourhost.com/path/to/api",
|
|
62
|
+
)
|
|
63
|
+
client.human_evaluations.fetch_list_human_evaluations(
|
|
64
|
+
app_id="app_id",
|
|
65
|
+
)
|
|
66
|
+
"""
|
|
67
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
68
|
+
"human-evaluations",
|
|
69
|
+
method="GET",
|
|
70
|
+
params={
|
|
71
|
+
"app_id": app_id,
|
|
72
|
+
},
|
|
73
|
+
request_options=request_options,
|
|
74
|
+
)
|
|
75
|
+
try:
|
|
76
|
+
if 200 <= _response.status_code < 300:
|
|
77
|
+
return typing.cast(
|
|
78
|
+
typing.List[HumanEvaluation],
|
|
79
|
+
parse_obj_as(
|
|
80
|
+
type_=typing.List[HumanEvaluation], # type: ignore
|
|
81
|
+
object_=_response.json(),
|
|
82
|
+
),
|
|
83
|
+
)
|
|
84
|
+
if _response.status_code == 422:
|
|
85
|
+
raise UnprocessableEntityError(
|
|
86
|
+
typing.cast(
|
|
87
|
+
HttpValidationError,
|
|
88
|
+
parse_obj_as(
|
|
89
|
+
type_=HttpValidationError, # type: ignore
|
|
90
|
+
object_=_response.json(),
|
|
91
|
+
),
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
_response_json = _response.json()
|
|
95
|
+
except JSONDecodeError:
|
|
96
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
97
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
98
|
+
|
|
99
|
+
def create_human_evaluation(
|
|
100
|
+
self,
|
|
101
|
+
*,
|
|
102
|
+
app_id: str,
|
|
103
|
+
variant_ids: typing.Sequence[str],
|
|
104
|
+
evaluation_type: EvaluationType,
|
|
105
|
+
inputs: typing.Sequence[str],
|
|
106
|
+
testset_id: str,
|
|
107
|
+
status: str,
|
|
108
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
109
|
+
) -> SimpleEvaluationOutput:
|
|
110
|
+
"""
|
|
111
|
+
Creates a new comparison table document
|
|
112
|
+
Raises:
|
|
113
|
+
HTTPException: _description_
|
|
114
|
+
Returns:
|
|
115
|
+
_description_
|
|
116
|
+
|
|
117
|
+
Parameters
|
|
118
|
+
----------
|
|
119
|
+
app_id : str
|
|
120
|
+
|
|
121
|
+
variant_ids : typing.Sequence[str]
|
|
122
|
+
|
|
123
|
+
evaluation_type : EvaluationType
|
|
124
|
+
|
|
125
|
+
inputs : typing.Sequence[str]
|
|
126
|
+
|
|
127
|
+
testset_id : str
|
|
128
|
+
|
|
129
|
+
status : str
|
|
130
|
+
|
|
131
|
+
request_options : typing.Optional[RequestOptions]
|
|
132
|
+
Request-specific configuration.
|
|
133
|
+
|
|
134
|
+
Returns
|
|
135
|
+
-------
|
|
136
|
+
SimpleEvaluationOutput
|
|
137
|
+
Successful Response
|
|
138
|
+
|
|
139
|
+
Examples
|
|
140
|
+
--------
|
|
141
|
+
from agenta import AgentaApi
|
|
142
|
+
|
|
143
|
+
client = AgentaApi(
|
|
144
|
+
api_key="YOUR_API_KEY",
|
|
145
|
+
base_url="https://yourhost.com/path/to/api",
|
|
146
|
+
)
|
|
147
|
+
client.human_evaluations.create_human_evaluation(
|
|
148
|
+
app_id="app_id",
|
|
149
|
+
variant_ids=["variant_ids"],
|
|
150
|
+
evaluation_type="human_a_b_testing",
|
|
151
|
+
inputs=["inputs"],
|
|
152
|
+
testset_id="testset_id",
|
|
153
|
+
status="status",
|
|
154
|
+
)
|
|
155
|
+
"""
|
|
156
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
157
|
+
"human-evaluations",
|
|
158
|
+
method="POST",
|
|
159
|
+
json={
|
|
160
|
+
"app_id": app_id,
|
|
161
|
+
"variant_ids": variant_ids,
|
|
162
|
+
"evaluation_type": evaluation_type,
|
|
163
|
+
"inputs": inputs,
|
|
164
|
+
"testset_id": testset_id,
|
|
165
|
+
"status": status,
|
|
166
|
+
},
|
|
167
|
+
headers={
|
|
168
|
+
"content-type": "application/json",
|
|
169
|
+
},
|
|
170
|
+
request_options=request_options,
|
|
171
|
+
omit=OMIT,
|
|
172
|
+
)
|
|
173
|
+
try:
|
|
174
|
+
if 200 <= _response.status_code < 300:
|
|
175
|
+
return typing.cast(
|
|
176
|
+
SimpleEvaluationOutput,
|
|
177
|
+
parse_obj_as(
|
|
178
|
+
type_=SimpleEvaluationOutput, # type: ignore
|
|
179
|
+
object_=_response.json(),
|
|
180
|
+
),
|
|
181
|
+
)
|
|
182
|
+
if _response.status_code == 422:
|
|
183
|
+
raise UnprocessableEntityError(
|
|
184
|
+
typing.cast(
|
|
185
|
+
HttpValidationError,
|
|
186
|
+
parse_obj_as(
|
|
187
|
+
type_=HttpValidationError, # type: ignore
|
|
188
|
+
object_=_response.json(),
|
|
189
|
+
),
|
|
190
|
+
)
|
|
191
|
+
)
|
|
192
|
+
_response_json = _response.json()
|
|
193
|
+
except JSONDecodeError:
|
|
194
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
195
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
196
|
+
|
|
197
|
+
def delete_evaluations(
|
|
198
|
+
self,
|
|
199
|
+
*,
|
|
200
|
+
evaluations_ids: typing.Sequence[str],
|
|
201
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
202
|
+
) -> typing.List[str]:
|
|
203
|
+
"""
|
|
204
|
+
Delete specific comparison tables based on their unique IDs.
|
|
205
|
+
|
|
206
|
+
Args:
|
|
207
|
+
payload (List[str]): The unique identifiers of the comparison tables to delete.
|
|
208
|
+
|
|
209
|
+
Returns:
|
|
210
|
+
A list of the deleted comparison tables' IDs.
|
|
211
|
+
|
|
212
|
+
Parameters
|
|
213
|
+
----------
|
|
214
|
+
evaluations_ids : typing.Sequence[str]
|
|
215
|
+
|
|
216
|
+
request_options : typing.Optional[RequestOptions]
|
|
217
|
+
Request-specific configuration.
|
|
218
|
+
|
|
219
|
+
Returns
|
|
220
|
+
-------
|
|
221
|
+
typing.List[str]
|
|
222
|
+
Successful Response
|
|
223
|
+
|
|
224
|
+
Examples
|
|
225
|
+
--------
|
|
226
|
+
from agenta import AgentaApi
|
|
227
|
+
|
|
228
|
+
client = AgentaApi(
|
|
229
|
+
api_key="YOUR_API_KEY",
|
|
230
|
+
base_url="https://yourhost.com/path/to/api",
|
|
231
|
+
)
|
|
232
|
+
client.human_evaluations.delete_evaluations(
|
|
233
|
+
evaluations_ids=["evaluations_ids"],
|
|
234
|
+
)
|
|
235
|
+
"""
|
|
236
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
237
|
+
"human-evaluations",
|
|
238
|
+
method="DELETE",
|
|
239
|
+
json={
|
|
240
|
+
"evaluations_ids": evaluations_ids,
|
|
241
|
+
},
|
|
242
|
+
request_options=request_options,
|
|
243
|
+
omit=OMIT,
|
|
244
|
+
)
|
|
245
|
+
try:
|
|
246
|
+
if 200 <= _response.status_code < 300:
|
|
247
|
+
return typing.cast(
|
|
248
|
+
typing.List[str],
|
|
249
|
+
parse_obj_as(
|
|
250
|
+
type_=typing.List[str], # type: ignore
|
|
251
|
+
object_=_response.json(),
|
|
252
|
+
),
|
|
253
|
+
)
|
|
254
|
+
if _response.status_code == 422:
|
|
255
|
+
raise UnprocessableEntityError(
|
|
256
|
+
typing.cast(
|
|
257
|
+
HttpValidationError,
|
|
258
|
+
parse_obj_as(
|
|
259
|
+
type_=HttpValidationError, # type: ignore
|
|
260
|
+
object_=_response.json(),
|
|
261
|
+
),
|
|
262
|
+
)
|
|
263
|
+
)
|
|
264
|
+
_response_json = _response.json()
|
|
265
|
+
except JSONDecodeError:
|
|
266
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
267
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
268
|
+
|
|
269
|
+
def fetch_human_evaluation(
|
|
270
|
+
self,
|
|
271
|
+
evaluation_id: str,
|
|
272
|
+
*,
|
|
273
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
274
|
+
) -> HumanEvaluation:
|
|
275
|
+
"""
|
|
276
|
+
Fetches a single evaluation based on its ID.
|
|
277
|
+
|
|
278
|
+
Args:
|
|
279
|
+
evaluation_id (str): The ID of the evaluation to fetch.
|
|
280
|
+
|
|
281
|
+
Returns:
|
|
282
|
+
HumanEvaluation: The fetched evaluation.
|
|
283
|
+
|
|
284
|
+
Parameters
|
|
285
|
+
----------
|
|
286
|
+
evaluation_id : str
|
|
287
|
+
|
|
288
|
+
request_options : typing.Optional[RequestOptions]
|
|
289
|
+
Request-specific configuration.
|
|
290
|
+
|
|
291
|
+
Returns
|
|
292
|
+
-------
|
|
293
|
+
HumanEvaluation
|
|
294
|
+
Successful Response
|
|
295
|
+
|
|
296
|
+
Examples
|
|
297
|
+
--------
|
|
298
|
+
from agenta import AgentaApi
|
|
299
|
+
|
|
300
|
+
client = AgentaApi(
|
|
301
|
+
api_key="YOUR_API_KEY",
|
|
302
|
+
base_url="https://yourhost.com/path/to/api",
|
|
303
|
+
)
|
|
304
|
+
client.human_evaluations.fetch_human_evaluation(
|
|
305
|
+
evaluation_id="evaluation_id",
|
|
306
|
+
)
|
|
307
|
+
"""
|
|
308
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
309
|
+
f"human-evaluations/{jsonable_encoder(evaluation_id)}",
|
|
310
|
+
method="GET",
|
|
311
|
+
request_options=request_options,
|
|
312
|
+
)
|
|
313
|
+
try:
|
|
314
|
+
if 200 <= _response.status_code < 300:
|
|
315
|
+
return typing.cast(
|
|
316
|
+
HumanEvaluation,
|
|
317
|
+
parse_obj_as(
|
|
318
|
+
type_=HumanEvaluation, # type: ignore
|
|
319
|
+
object_=_response.json(),
|
|
320
|
+
),
|
|
321
|
+
)
|
|
322
|
+
if _response.status_code == 422:
|
|
323
|
+
raise UnprocessableEntityError(
|
|
324
|
+
typing.cast(
|
|
325
|
+
HttpValidationError,
|
|
326
|
+
parse_obj_as(
|
|
327
|
+
type_=HttpValidationError, # type: ignore
|
|
328
|
+
object_=_response.json(),
|
|
329
|
+
),
|
|
330
|
+
)
|
|
331
|
+
)
|
|
332
|
+
_response_json = _response.json()
|
|
333
|
+
except JSONDecodeError:
|
|
334
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
335
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
336
|
+
|
|
337
|
+
def update_human_evaluation(
|
|
338
|
+
self,
|
|
339
|
+
evaluation_id: str,
|
|
340
|
+
*,
|
|
341
|
+
status: typing.Optional[EvaluationStatusEnum] = OMIT,
|
|
342
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
343
|
+
) -> typing.Optional[typing.Any]:
|
|
344
|
+
"""
|
|
345
|
+
Updates an evaluation's status.
|
|
346
|
+
|
|
347
|
+
Raises:
|
|
348
|
+
HTTPException: If the columns in the test set do not match with the inputs in the variant.
|
|
349
|
+
|
|
350
|
+
Returns:
|
|
351
|
+
None: A 204 No Content status code, indicating that the update was successful.
|
|
352
|
+
|
|
353
|
+
Parameters
|
|
354
|
+
----------
|
|
355
|
+
evaluation_id : str
|
|
356
|
+
|
|
357
|
+
status : typing.Optional[EvaluationStatusEnum]
|
|
358
|
+
|
|
359
|
+
request_options : typing.Optional[RequestOptions]
|
|
360
|
+
Request-specific configuration.
|
|
361
|
+
|
|
362
|
+
Returns
|
|
363
|
+
-------
|
|
364
|
+
typing.Optional[typing.Any]
|
|
365
|
+
Successful Response
|
|
366
|
+
|
|
367
|
+
Examples
|
|
368
|
+
--------
|
|
369
|
+
from agenta import AgentaApi
|
|
370
|
+
|
|
371
|
+
client = AgentaApi(
|
|
372
|
+
api_key="YOUR_API_KEY",
|
|
373
|
+
base_url="https://yourhost.com/path/to/api",
|
|
374
|
+
)
|
|
375
|
+
client.human_evaluations.update_human_evaluation(
|
|
376
|
+
evaluation_id="evaluation_id",
|
|
377
|
+
)
|
|
378
|
+
"""
|
|
379
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
380
|
+
f"human-evaluations/{jsonable_encoder(evaluation_id)}",
|
|
381
|
+
method="PUT",
|
|
382
|
+
json={
|
|
383
|
+
"status": status,
|
|
384
|
+
},
|
|
385
|
+
headers={
|
|
386
|
+
"content-type": "application/json",
|
|
387
|
+
},
|
|
388
|
+
request_options=request_options,
|
|
389
|
+
omit=OMIT,
|
|
390
|
+
)
|
|
391
|
+
try:
|
|
392
|
+
if 200 <= _response.status_code < 300:
|
|
393
|
+
return typing.cast(
|
|
394
|
+
typing.Optional[typing.Any],
|
|
395
|
+
parse_obj_as(
|
|
396
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
397
|
+
object_=_response.json(),
|
|
398
|
+
),
|
|
399
|
+
)
|
|
400
|
+
if _response.status_code == 422:
|
|
401
|
+
raise UnprocessableEntityError(
|
|
402
|
+
typing.cast(
|
|
403
|
+
HttpValidationError,
|
|
404
|
+
parse_obj_as(
|
|
405
|
+
type_=HttpValidationError, # type: ignore
|
|
406
|
+
object_=_response.json(),
|
|
407
|
+
),
|
|
408
|
+
)
|
|
409
|
+
)
|
|
410
|
+
_response_json = _response.json()
|
|
411
|
+
except JSONDecodeError:
|
|
412
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
413
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
414
|
+
|
|
415
|
+
def fetch_human_evaluation_scenarios(
|
|
416
|
+
self,
|
|
417
|
+
evaluation_id: str,
|
|
418
|
+
*,
|
|
419
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
420
|
+
) -> typing.List[HumanEvaluationScenario]:
|
|
421
|
+
"""
|
|
422
|
+
Fetches evaluation scenarios for a given evaluation ID.
|
|
423
|
+
|
|
424
|
+
Arguments:
|
|
425
|
+
evaluation_id (str): The ID of the evaluation for which to fetch scenarios.
|
|
426
|
+
|
|
427
|
+
Raises:
|
|
428
|
+
HTTPException: If the evaluation is not found or access is denied.
|
|
429
|
+
|
|
430
|
+
Returns:
|
|
431
|
+
List[EvaluationScenario]: A list of evaluation scenarios.
|
|
432
|
+
|
|
433
|
+
Parameters
|
|
434
|
+
----------
|
|
435
|
+
evaluation_id : str
|
|
436
|
+
|
|
437
|
+
request_options : typing.Optional[RequestOptions]
|
|
438
|
+
Request-specific configuration.
|
|
439
|
+
|
|
440
|
+
Returns
|
|
441
|
+
-------
|
|
442
|
+
typing.List[HumanEvaluationScenario]
|
|
443
|
+
Successful Response
|
|
444
|
+
|
|
445
|
+
Examples
|
|
446
|
+
--------
|
|
447
|
+
from agenta import AgentaApi
|
|
448
|
+
|
|
449
|
+
client = AgentaApi(
|
|
450
|
+
api_key="YOUR_API_KEY",
|
|
451
|
+
base_url="https://yourhost.com/path/to/api",
|
|
452
|
+
)
|
|
453
|
+
client.human_evaluations.fetch_human_evaluation_scenarios(
|
|
454
|
+
evaluation_id="evaluation_id",
|
|
455
|
+
)
|
|
456
|
+
"""
|
|
457
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
458
|
+
f"human-evaluations/{jsonable_encoder(evaluation_id)}/evaluation_scenarios",
|
|
459
|
+
method="GET",
|
|
460
|
+
request_options=request_options,
|
|
461
|
+
)
|
|
462
|
+
try:
|
|
463
|
+
if 200 <= _response.status_code < 300:
|
|
464
|
+
return typing.cast(
|
|
465
|
+
typing.List[HumanEvaluationScenario],
|
|
466
|
+
parse_obj_as(
|
|
467
|
+
type_=typing.List[HumanEvaluationScenario], # type: ignore
|
|
468
|
+
object_=_response.json(),
|
|
469
|
+
),
|
|
470
|
+
)
|
|
471
|
+
if _response.status_code == 422:
|
|
472
|
+
raise UnprocessableEntityError(
|
|
473
|
+
typing.cast(
|
|
474
|
+
HttpValidationError,
|
|
475
|
+
parse_obj_as(
|
|
476
|
+
type_=HttpValidationError, # type: ignore
|
|
477
|
+
object_=_response.json(),
|
|
478
|
+
),
|
|
479
|
+
)
|
|
480
|
+
)
|
|
481
|
+
_response_json = _response.json()
|
|
482
|
+
except JSONDecodeError:
|
|
483
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
484
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
485
|
+
|
|
486
|
+
def update_evaluation_scenario_router(
|
|
487
|
+
self,
|
|
488
|
+
evaluation_id: str,
|
|
489
|
+
evaluation_scenario_id: str,
|
|
490
|
+
evaluation_type: EvaluationType,
|
|
491
|
+
*,
|
|
492
|
+
vote: typing.Optional[str] = OMIT,
|
|
493
|
+
score: typing.Optional[Score] = OMIT,
|
|
494
|
+
correct_answer: typing.Optional[str] = OMIT,
|
|
495
|
+
outputs: typing.Optional[typing.Sequence[HumanEvaluationScenarioOutput]] = OMIT,
|
|
496
|
+
inputs: typing.Optional[typing.Sequence[HumanEvaluationScenarioInput]] = OMIT,
|
|
497
|
+
is_pinned: typing.Optional[bool] = OMIT,
|
|
498
|
+
note: typing.Optional[str] = OMIT,
|
|
499
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
500
|
+
) -> typing.Optional[typing.Any]:
|
|
501
|
+
"""
|
|
502
|
+
Updates an evaluation scenario's vote or score based on its type.
|
|
503
|
+
|
|
504
|
+
Raises:
|
|
505
|
+
HTTPException: If update fails or unauthorized.
|
|
506
|
+
|
|
507
|
+
Returns:
|
|
508
|
+
None: 204 No Content status code upon successful update.
|
|
509
|
+
|
|
510
|
+
Parameters
|
|
511
|
+
----------
|
|
512
|
+
evaluation_id : str
|
|
513
|
+
|
|
514
|
+
evaluation_scenario_id : str
|
|
515
|
+
|
|
516
|
+
evaluation_type : EvaluationType
|
|
517
|
+
|
|
518
|
+
vote : typing.Optional[str]
|
|
519
|
+
|
|
520
|
+
score : typing.Optional[Score]
|
|
521
|
+
|
|
522
|
+
correct_answer : typing.Optional[str]
|
|
523
|
+
|
|
524
|
+
outputs : typing.Optional[typing.Sequence[HumanEvaluationScenarioOutput]]
|
|
525
|
+
|
|
526
|
+
inputs : typing.Optional[typing.Sequence[HumanEvaluationScenarioInput]]
|
|
527
|
+
|
|
528
|
+
is_pinned : typing.Optional[bool]
|
|
529
|
+
|
|
530
|
+
note : typing.Optional[str]
|
|
531
|
+
|
|
532
|
+
request_options : typing.Optional[RequestOptions]
|
|
533
|
+
Request-specific configuration.
|
|
534
|
+
|
|
535
|
+
Returns
|
|
536
|
+
-------
|
|
537
|
+
typing.Optional[typing.Any]
|
|
538
|
+
Successful Response
|
|
539
|
+
|
|
540
|
+
Examples
|
|
541
|
+
--------
|
|
542
|
+
from agenta import AgentaApi
|
|
543
|
+
|
|
544
|
+
client = AgentaApi(
|
|
545
|
+
api_key="YOUR_API_KEY",
|
|
546
|
+
base_url="https://yourhost.com/path/to/api",
|
|
547
|
+
)
|
|
548
|
+
client.human_evaluations.update_evaluation_scenario_router(
|
|
549
|
+
evaluation_id="evaluation_id",
|
|
550
|
+
evaluation_scenario_id="evaluation_scenario_id",
|
|
551
|
+
evaluation_type="human_a_b_testing",
|
|
552
|
+
)
|
|
553
|
+
"""
|
|
554
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
555
|
+
f"human-evaluations/{jsonable_encoder(evaluation_id)}/evaluation_scenario/{jsonable_encoder(evaluation_scenario_id)}/{jsonable_encoder(evaluation_type)}",
|
|
556
|
+
method="PUT",
|
|
557
|
+
json={
|
|
558
|
+
"vote": vote,
|
|
559
|
+
"score": score,
|
|
560
|
+
"correct_answer": correct_answer,
|
|
561
|
+
"outputs": convert_and_respect_annotation_metadata(
|
|
562
|
+
object_=outputs,
|
|
563
|
+
annotation=typing.Sequence[HumanEvaluationScenarioOutput],
|
|
564
|
+
direction="write",
|
|
565
|
+
),
|
|
566
|
+
"inputs": convert_and_respect_annotation_metadata(
|
|
567
|
+
object_=inputs,
|
|
568
|
+
annotation=typing.Sequence[HumanEvaluationScenarioInput],
|
|
569
|
+
direction="write",
|
|
570
|
+
),
|
|
571
|
+
"is_pinned": is_pinned,
|
|
572
|
+
"note": note,
|
|
573
|
+
},
|
|
574
|
+
headers={
|
|
575
|
+
"content-type": "application/json",
|
|
576
|
+
},
|
|
577
|
+
request_options=request_options,
|
|
578
|
+
omit=OMIT,
|
|
579
|
+
)
|
|
580
|
+
try:
|
|
581
|
+
if 200 <= _response.status_code < 300:
|
|
582
|
+
return typing.cast(
|
|
583
|
+
typing.Optional[typing.Any],
|
|
584
|
+
parse_obj_as(
|
|
585
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
586
|
+
object_=_response.json(),
|
|
587
|
+
),
|
|
588
|
+
)
|
|
589
|
+
if _response.status_code == 422:
|
|
590
|
+
raise UnprocessableEntityError(
|
|
591
|
+
typing.cast(
|
|
592
|
+
HttpValidationError,
|
|
593
|
+
parse_obj_as(
|
|
594
|
+
type_=HttpValidationError, # type: ignore
|
|
595
|
+
object_=_response.json(),
|
|
596
|
+
),
|
|
597
|
+
)
|
|
598
|
+
)
|
|
599
|
+
_response_json = _response.json()
|
|
600
|
+
except JSONDecodeError:
|
|
601
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
602
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
603
|
+
|
|
604
|
+
def get_evaluation_scenario_score_router(
|
|
605
|
+
self,
|
|
606
|
+
evaluation_scenario_id: str,
|
|
607
|
+
*,
|
|
608
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
609
|
+
) -> typing.Dict[str, str]:
|
|
610
|
+
"""
|
|
611
|
+
Fetch the score of a specific evaluation scenario.
|
|
612
|
+
|
|
613
|
+
Args:
|
|
614
|
+
evaluation_scenario_id: The ID of the evaluation scenario to fetch.
|
|
615
|
+
stoken_session: Session data, verified by `verify_session`.
|
|
616
|
+
|
|
617
|
+
Returns:
|
|
618
|
+
Dictionary containing the scenario ID and its score.
|
|
619
|
+
|
|
620
|
+
Parameters
|
|
621
|
+
----------
|
|
622
|
+
evaluation_scenario_id : str
|
|
623
|
+
|
|
624
|
+
request_options : typing.Optional[RequestOptions]
|
|
625
|
+
Request-specific configuration.
|
|
626
|
+
|
|
627
|
+
Returns
|
|
628
|
+
-------
|
|
629
|
+
typing.Dict[str, str]
|
|
630
|
+
Successful Response
|
|
631
|
+
|
|
632
|
+
Examples
|
|
633
|
+
--------
|
|
634
|
+
from agenta import AgentaApi
|
|
635
|
+
|
|
636
|
+
client = AgentaApi(
|
|
637
|
+
api_key="YOUR_API_KEY",
|
|
638
|
+
base_url="https://yourhost.com/path/to/api",
|
|
639
|
+
)
|
|
640
|
+
client.human_evaluations.get_evaluation_scenario_score_router(
|
|
641
|
+
evaluation_scenario_id="evaluation_scenario_id",
|
|
642
|
+
)
|
|
643
|
+
"""
|
|
644
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
645
|
+
f"human-evaluations/evaluation_scenario/{jsonable_encoder(evaluation_scenario_id)}/score",
|
|
646
|
+
method="GET",
|
|
647
|
+
request_options=request_options,
|
|
648
|
+
)
|
|
649
|
+
try:
|
|
650
|
+
if 200 <= _response.status_code < 300:
|
|
651
|
+
return typing.cast(
|
|
652
|
+
typing.Dict[str, str],
|
|
653
|
+
parse_obj_as(
|
|
654
|
+
type_=typing.Dict[str, str], # type: ignore
|
|
655
|
+
object_=_response.json(),
|
|
656
|
+
),
|
|
657
|
+
)
|
|
658
|
+
if _response.status_code == 422:
|
|
659
|
+
raise UnprocessableEntityError(
|
|
660
|
+
typing.cast(
|
|
661
|
+
HttpValidationError,
|
|
662
|
+
parse_obj_as(
|
|
663
|
+
type_=HttpValidationError, # type: ignore
|
|
664
|
+
object_=_response.json(),
|
|
665
|
+
),
|
|
666
|
+
)
|
|
667
|
+
)
|
|
668
|
+
_response_json = _response.json()
|
|
669
|
+
except JSONDecodeError:
|
|
670
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
671
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
672
|
+
|
|
673
|
+
def update_evaluation_scenario_score_router(
|
|
674
|
+
self,
|
|
675
|
+
evaluation_scenario_id: str,
|
|
676
|
+
*,
|
|
677
|
+
score: float,
|
|
678
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
679
|
+
) -> typing.Optional[typing.Any]:
|
|
680
|
+
"""
|
|
681
|
+
Updates the score of an evaluation scenario.
|
|
682
|
+
|
|
683
|
+
Raises:
|
|
684
|
+
HTTPException: Server error if the evaluation update fails.
|
|
685
|
+
|
|
686
|
+
Returns:
|
|
687
|
+
None: 204 No Content status code upon successful update.
|
|
688
|
+
|
|
689
|
+
Parameters
|
|
690
|
+
----------
|
|
691
|
+
evaluation_scenario_id : str
|
|
692
|
+
|
|
693
|
+
score : float
|
|
694
|
+
|
|
695
|
+
request_options : typing.Optional[RequestOptions]
|
|
696
|
+
Request-specific configuration.
|
|
697
|
+
|
|
698
|
+
Returns
|
|
699
|
+
-------
|
|
700
|
+
typing.Optional[typing.Any]
|
|
701
|
+
Successful Response
|
|
702
|
+
|
|
703
|
+
Examples
|
|
704
|
+
--------
|
|
705
|
+
from agenta import AgentaApi
|
|
706
|
+
|
|
707
|
+
client = AgentaApi(
|
|
708
|
+
api_key="YOUR_API_KEY",
|
|
709
|
+
base_url="https://yourhost.com/path/to/api",
|
|
710
|
+
)
|
|
711
|
+
client.human_evaluations.update_evaluation_scenario_score_router(
|
|
712
|
+
evaluation_scenario_id="evaluation_scenario_id",
|
|
713
|
+
score=1.1,
|
|
714
|
+
)
|
|
715
|
+
"""
|
|
716
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
717
|
+
f"human-evaluations/evaluation_scenario/{jsonable_encoder(evaluation_scenario_id)}/score",
|
|
718
|
+
method="PUT",
|
|
719
|
+
json={
|
|
720
|
+
"score": score,
|
|
721
|
+
},
|
|
722
|
+
headers={
|
|
723
|
+
"content-type": "application/json",
|
|
724
|
+
},
|
|
725
|
+
request_options=request_options,
|
|
726
|
+
omit=OMIT,
|
|
727
|
+
)
|
|
728
|
+
try:
|
|
729
|
+
if 200 <= _response.status_code < 300:
|
|
730
|
+
return typing.cast(
|
|
731
|
+
typing.Optional[typing.Any],
|
|
732
|
+
parse_obj_as(
|
|
733
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
734
|
+
object_=_response.json(),
|
|
735
|
+
),
|
|
736
|
+
)
|
|
737
|
+
if _response.status_code == 422:
|
|
738
|
+
raise UnprocessableEntityError(
|
|
739
|
+
typing.cast(
|
|
740
|
+
HttpValidationError,
|
|
741
|
+
parse_obj_as(
|
|
742
|
+
type_=HttpValidationError, # type: ignore
|
|
743
|
+
object_=_response.json(),
|
|
744
|
+
),
|
|
745
|
+
)
|
|
746
|
+
)
|
|
747
|
+
_response_json = _response.json()
|
|
748
|
+
except JSONDecodeError:
|
|
749
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
750
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
751
|
+
|
|
752
|
+
def fetch_results(
|
|
753
|
+
self,
|
|
754
|
+
evaluation_id: str,
|
|
755
|
+
*,
|
|
756
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
757
|
+
) -> typing.Optional[typing.Any]:
|
|
758
|
+
"""
|
|
759
|
+
Fetch all the results for one the comparison table
|
|
760
|
+
|
|
761
|
+
Arguments:
|
|
762
|
+
evaluation_id -- _description_
|
|
763
|
+
|
|
764
|
+
Returns:
|
|
765
|
+
_description_
|
|
766
|
+
|
|
767
|
+
Parameters
|
|
768
|
+
----------
|
|
769
|
+
evaluation_id : str
|
|
770
|
+
|
|
771
|
+
request_options : typing.Optional[RequestOptions]
|
|
772
|
+
Request-specific configuration.
|
|
773
|
+
|
|
774
|
+
Returns
|
|
775
|
+
-------
|
|
776
|
+
typing.Optional[typing.Any]
|
|
777
|
+
Successful Response
|
|
778
|
+
|
|
779
|
+
Examples
|
|
780
|
+
--------
|
|
781
|
+
from agenta import AgentaApi
|
|
782
|
+
|
|
783
|
+
client = AgentaApi(
|
|
784
|
+
api_key="YOUR_API_KEY",
|
|
785
|
+
base_url="https://yourhost.com/path/to/api",
|
|
786
|
+
)
|
|
787
|
+
client.human_evaluations.fetch_results(
|
|
788
|
+
evaluation_id="evaluation_id",
|
|
789
|
+
)
|
|
790
|
+
"""
|
|
791
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
792
|
+
f"human-evaluations/{jsonable_encoder(evaluation_id)}/results",
|
|
793
|
+
method="GET",
|
|
794
|
+
request_options=request_options,
|
|
795
|
+
)
|
|
796
|
+
try:
|
|
797
|
+
if 200 <= _response.status_code < 300:
|
|
798
|
+
return typing.cast(
|
|
799
|
+
typing.Optional[typing.Any],
|
|
800
|
+
parse_obj_as(
|
|
801
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
802
|
+
object_=_response.json(),
|
|
803
|
+
),
|
|
804
|
+
)
|
|
805
|
+
if _response.status_code == 422:
|
|
806
|
+
raise UnprocessableEntityError(
|
|
807
|
+
typing.cast(
|
|
808
|
+
HttpValidationError,
|
|
809
|
+
parse_obj_as(
|
|
810
|
+
type_=HttpValidationError, # type: ignore
|
|
811
|
+
object_=_response.json(),
|
|
812
|
+
),
|
|
813
|
+
)
|
|
814
|
+
)
|
|
815
|
+
_response_json = _response.json()
|
|
816
|
+
except JSONDecodeError:
|
|
817
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
818
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
class AsyncHumanEvaluationsClient:
|
|
822
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
823
|
+
self._client_wrapper = client_wrapper
|
|
824
|
+
|
|
825
|
+
async def fetch_list_human_evaluations(
|
|
826
|
+
self, *, app_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
827
|
+
) -> typing.List[HumanEvaluation]:
|
|
828
|
+
"""
|
|
829
|
+
Fetches a list of evaluations, optionally filtered by an app ID.
|
|
830
|
+
|
|
831
|
+
Args:
|
|
832
|
+
app_id (Optional[str]): An optional app ID to filter the evaluations.
|
|
833
|
+
|
|
834
|
+
Returns:
|
|
835
|
+
List[HumanEvaluation]: A list of evaluations.
|
|
836
|
+
|
|
837
|
+
Parameters
|
|
838
|
+
----------
|
|
839
|
+
app_id : str
|
|
840
|
+
|
|
841
|
+
request_options : typing.Optional[RequestOptions]
|
|
842
|
+
Request-specific configuration.
|
|
843
|
+
|
|
844
|
+
Returns
|
|
845
|
+
-------
|
|
846
|
+
typing.List[HumanEvaluation]
|
|
847
|
+
Successful Response
|
|
848
|
+
|
|
849
|
+
Examples
|
|
850
|
+
--------
|
|
851
|
+
import asyncio
|
|
852
|
+
|
|
853
|
+
from agenta import AsyncAgentaApi
|
|
854
|
+
|
|
855
|
+
client = AsyncAgentaApi(
|
|
856
|
+
api_key="YOUR_API_KEY",
|
|
857
|
+
base_url="https://yourhost.com/path/to/api",
|
|
858
|
+
)
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
async def main() -> None:
|
|
862
|
+
await client.human_evaluations.fetch_list_human_evaluations(
|
|
863
|
+
app_id="app_id",
|
|
864
|
+
)
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
asyncio.run(main())
|
|
868
|
+
"""
|
|
869
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
870
|
+
"human-evaluations",
|
|
871
|
+
method="GET",
|
|
872
|
+
params={
|
|
873
|
+
"app_id": app_id,
|
|
874
|
+
},
|
|
875
|
+
request_options=request_options,
|
|
876
|
+
)
|
|
877
|
+
try:
|
|
878
|
+
if 200 <= _response.status_code < 300:
|
|
879
|
+
return typing.cast(
|
|
880
|
+
typing.List[HumanEvaluation],
|
|
881
|
+
parse_obj_as(
|
|
882
|
+
type_=typing.List[HumanEvaluation], # type: ignore
|
|
883
|
+
object_=_response.json(),
|
|
884
|
+
),
|
|
885
|
+
)
|
|
886
|
+
if _response.status_code == 422:
|
|
887
|
+
raise UnprocessableEntityError(
|
|
888
|
+
typing.cast(
|
|
889
|
+
HttpValidationError,
|
|
890
|
+
parse_obj_as(
|
|
891
|
+
type_=HttpValidationError, # type: ignore
|
|
892
|
+
object_=_response.json(),
|
|
893
|
+
),
|
|
894
|
+
)
|
|
895
|
+
)
|
|
896
|
+
_response_json = _response.json()
|
|
897
|
+
except JSONDecodeError:
|
|
898
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
899
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
900
|
+
|
|
901
|
+
async def create_human_evaluation(
|
|
902
|
+
self,
|
|
903
|
+
*,
|
|
904
|
+
app_id: str,
|
|
905
|
+
variant_ids: typing.Sequence[str],
|
|
906
|
+
evaluation_type: EvaluationType,
|
|
907
|
+
inputs: typing.Sequence[str],
|
|
908
|
+
testset_id: str,
|
|
909
|
+
status: str,
|
|
910
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
911
|
+
) -> SimpleEvaluationOutput:
|
|
912
|
+
"""
|
|
913
|
+
Creates a new comparison table document
|
|
914
|
+
Raises:
|
|
915
|
+
HTTPException: _description_
|
|
916
|
+
Returns:
|
|
917
|
+
_description_
|
|
918
|
+
|
|
919
|
+
Parameters
|
|
920
|
+
----------
|
|
921
|
+
app_id : str
|
|
922
|
+
|
|
923
|
+
variant_ids : typing.Sequence[str]
|
|
924
|
+
|
|
925
|
+
evaluation_type : EvaluationType
|
|
926
|
+
|
|
927
|
+
inputs : typing.Sequence[str]
|
|
928
|
+
|
|
929
|
+
testset_id : str
|
|
930
|
+
|
|
931
|
+
status : str
|
|
932
|
+
|
|
933
|
+
request_options : typing.Optional[RequestOptions]
|
|
934
|
+
Request-specific configuration.
|
|
935
|
+
|
|
936
|
+
Returns
|
|
937
|
+
-------
|
|
938
|
+
SimpleEvaluationOutput
|
|
939
|
+
Successful Response
|
|
940
|
+
|
|
941
|
+
Examples
|
|
942
|
+
--------
|
|
943
|
+
import asyncio
|
|
944
|
+
|
|
945
|
+
from agenta import AsyncAgentaApi
|
|
946
|
+
|
|
947
|
+
client = AsyncAgentaApi(
|
|
948
|
+
api_key="YOUR_API_KEY",
|
|
949
|
+
base_url="https://yourhost.com/path/to/api",
|
|
950
|
+
)
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
async def main() -> None:
|
|
954
|
+
await client.human_evaluations.create_human_evaluation(
|
|
955
|
+
app_id="app_id",
|
|
956
|
+
variant_ids=["variant_ids"],
|
|
957
|
+
evaluation_type="human_a_b_testing",
|
|
958
|
+
inputs=["inputs"],
|
|
959
|
+
testset_id="testset_id",
|
|
960
|
+
status="status",
|
|
961
|
+
)
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
asyncio.run(main())
|
|
965
|
+
"""
|
|
966
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
967
|
+
"human-evaluations",
|
|
968
|
+
method="POST",
|
|
969
|
+
json={
|
|
970
|
+
"app_id": app_id,
|
|
971
|
+
"variant_ids": variant_ids,
|
|
972
|
+
"evaluation_type": evaluation_type,
|
|
973
|
+
"inputs": inputs,
|
|
974
|
+
"testset_id": testset_id,
|
|
975
|
+
"status": status,
|
|
976
|
+
},
|
|
977
|
+
headers={
|
|
978
|
+
"content-type": "application/json",
|
|
979
|
+
},
|
|
980
|
+
request_options=request_options,
|
|
981
|
+
omit=OMIT,
|
|
982
|
+
)
|
|
983
|
+
try:
|
|
984
|
+
if 200 <= _response.status_code < 300:
|
|
985
|
+
return typing.cast(
|
|
986
|
+
SimpleEvaluationOutput,
|
|
987
|
+
parse_obj_as(
|
|
988
|
+
type_=SimpleEvaluationOutput, # type: ignore
|
|
989
|
+
object_=_response.json(),
|
|
990
|
+
),
|
|
991
|
+
)
|
|
992
|
+
if _response.status_code == 422:
|
|
993
|
+
raise UnprocessableEntityError(
|
|
994
|
+
typing.cast(
|
|
995
|
+
HttpValidationError,
|
|
996
|
+
parse_obj_as(
|
|
997
|
+
type_=HttpValidationError, # type: ignore
|
|
998
|
+
object_=_response.json(),
|
|
999
|
+
),
|
|
1000
|
+
)
|
|
1001
|
+
)
|
|
1002
|
+
_response_json = _response.json()
|
|
1003
|
+
except JSONDecodeError:
|
|
1004
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1005
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1006
|
+
|
|
1007
|
+
async def delete_evaluations(
|
|
1008
|
+
self,
|
|
1009
|
+
*,
|
|
1010
|
+
evaluations_ids: typing.Sequence[str],
|
|
1011
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1012
|
+
) -> typing.List[str]:
|
|
1013
|
+
"""
|
|
1014
|
+
Delete specific comparison tables based on their unique IDs.
|
|
1015
|
+
|
|
1016
|
+
Args:
|
|
1017
|
+
payload (List[str]): The unique identifiers of the comparison tables to delete.
|
|
1018
|
+
|
|
1019
|
+
Returns:
|
|
1020
|
+
A list of the deleted comparison tables' IDs.
|
|
1021
|
+
|
|
1022
|
+
Parameters
|
|
1023
|
+
----------
|
|
1024
|
+
evaluations_ids : typing.Sequence[str]
|
|
1025
|
+
|
|
1026
|
+
request_options : typing.Optional[RequestOptions]
|
|
1027
|
+
Request-specific configuration.
|
|
1028
|
+
|
|
1029
|
+
Returns
|
|
1030
|
+
-------
|
|
1031
|
+
typing.List[str]
|
|
1032
|
+
Successful Response
|
|
1033
|
+
|
|
1034
|
+
Examples
|
|
1035
|
+
--------
|
|
1036
|
+
import asyncio
|
|
1037
|
+
|
|
1038
|
+
from agenta import AsyncAgentaApi
|
|
1039
|
+
|
|
1040
|
+
client = AsyncAgentaApi(
|
|
1041
|
+
api_key="YOUR_API_KEY",
|
|
1042
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1043
|
+
)
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
async def main() -> None:
|
|
1047
|
+
await client.human_evaluations.delete_evaluations(
|
|
1048
|
+
evaluations_ids=["evaluations_ids"],
|
|
1049
|
+
)
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
asyncio.run(main())
|
|
1053
|
+
"""
|
|
1054
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1055
|
+
"human-evaluations",
|
|
1056
|
+
method="DELETE",
|
|
1057
|
+
json={
|
|
1058
|
+
"evaluations_ids": evaluations_ids,
|
|
1059
|
+
},
|
|
1060
|
+
request_options=request_options,
|
|
1061
|
+
omit=OMIT,
|
|
1062
|
+
)
|
|
1063
|
+
try:
|
|
1064
|
+
if 200 <= _response.status_code < 300:
|
|
1065
|
+
return typing.cast(
|
|
1066
|
+
typing.List[str],
|
|
1067
|
+
parse_obj_as(
|
|
1068
|
+
type_=typing.List[str], # type: ignore
|
|
1069
|
+
object_=_response.json(),
|
|
1070
|
+
),
|
|
1071
|
+
)
|
|
1072
|
+
if _response.status_code == 422:
|
|
1073
|
+
raise UnprocessableEntityError(
|
|
1074
|
+
typing.cast(
|
|
1075
|
+
HttpValidationError,
|
|
1076
|
+
parse_obj_as(
|
|
1077
|
+
type_=HttpValidationError, # type: ignore
|
|
1078
|
+
object_=_response.json(),
|
|
1079
|
+
),
|
|
1080
|
+
)
|
|
1081
|
+
)
|
|
1082
|
+
_response_json = _response.json()
|
|
1083
|
+
except JSONDecodeError:
|
|
1084
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1085
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1086
|
+
|
|
1087
|
+
async def fetch_human_evaluation(
|
|
1088
|
+
self,
|
|
1089
|
+
evaluation_id: str,
|
|
1090
|
+
*,
|
|
1091
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1092
|
+
) -> HumanEvaluation:
|
|
1093
|
+
"""
|
|
1094
|
+
Fetches a single evaluation based on its ID.
|
|
1095
|
+
|
|
1096
|
+
Args:
|
|
1097
|
+
evaluation_id (str): The ID of the evaluation to fetch.
|
|
1098
|
+
|
|
1099
|
+
Returns:
|
|
1100
|
+
HumanEvaluation: The fetched evaluation.
|
|
1101
|
+
|
|
1102
|
+
Parameters
|
|
1103
|
+
----------
|
|
1104
|
+
evaluation_id : str
|
|
1105
|
+
|
|
1106
|
+
request_options : typing.Optional[RequestOptions]
|
|
1107
|
+
Request-specific configuration.
|
|
1108
|
+
|
|
1109
|
+
Returns
|
|
1110
|
+
-------
|
|
1111
|
+
HumanEvaluation
|
|
1112
|
+
Successful Response
|
|
1113
|
+
|
|
1114
|
+
Examples
|
|
1115
|
+
--------
|
|
1116
|
+
import asyncio
|
|
1117
|
+
|
|
1118
|
+
from agenta import AsyncAgentaApi
|
|
1119
|
+
|
|
1120
|
+
client = AsyncAgentaApi(
|
|
1121
|
+
api_key="YOUR_API_KEY",
|
|
1122
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1123
|
+
)
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
async def main() -> None:
|
|
1127
|
+
await client.human_evaluations.fetch_human_evaluation(
|
|
1128
|
+
evaluation_id="evaluation_id",
|
|
1129
|
+
)
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
asyncio.run(main())
|
|
1133
|
+
"""
|
|
1134
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1135
|
+
f"human-evaluations/{jsonable_encoder(evaluation_id)}",
|
|
1136
|
+
method="GET",
|
|
1137
|
+
request_options=request_options,
|
|
1138
|
+
)
|
|
1139
|
+
try:
|
|
1140
|
+
if 200 <= _response.status_code < 300:
|
|
1141
|
+
return typing.cast(
|
|
1142
|
+
HumanEvaluation,
|
|
1143
|
+
parse_obj_as(
|
|
1144
|
+
type_=HumanEvaluation, # type: ignore
|
|
1145
|
+
object_=_response.json(),
|
|
1146
|
+
),
|
|
1147
|
+
)
|
|
1148
|
+
if _response.status_code == 422:
|
|
1149
|
+
raise UnprocessableEntityError(
|
|
1150
|
+
typing.cast(
|
|
1151
|
+
HttpValidationError,
|
|
1152
|
+
parse_obj_as(
|
|
1153
|
+
type_=HttpValidationError, # type: ignore
|
|
1154
|
+
object_=_response.json(),
|
|
1155
|
+
),
|
|
1156
|
+
)
|
|
1157
|
+
)
|
|
1158
|
+
_response_json = _response.json()
|
|
1159
|
+
except JSONDecodeError:
|
|
1160
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1161
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1162
|
+
|
|
1163
|
+
async def update_human_evaluation(
|
|
1164
|
+
self,
|
|
1165
|
+
evaluation_id: str,
|
|
1166
|
+
*,
|
|
1167
|
+
status: typing.Optional[EvaluationStatusEnum] = OMIT,
|
|
1168
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1169
|
+
) -> typing.Optional[typing.Any]:
|
|
1170
|
+
"""
|
|
1171
|
+
Updates an evaluation's status.
|
|
1172
|
+
|
|
1173
|
+
Raises:
|
|
1174
|
+
HTTPException: If the columns in the test set do not match with the inputs in the variant.
|
|
1175
|
+
|
|
1176
|
+
Returns:
|
|
1177
|
+
None: A 204 No Content status code, indicating that the update was successful.
|
|
1178
|
+
|
|
1179
|
+
Parameters
|
|
1180
|
+
----------
|
|
1181
|
+
evaluation_id : str
|
|
1182
|
+
|
|
1183
|
+
status : typing.Optional[EvaluationStatusEnum]
|
|
1184
|
+
|
|
1185
|
+
request_options : typing.Optional[RequestOptions]
|
|
1186
|
+
Request-specific configuration.
|
|
1187
|
+
|
|
1188
|
+
Returns
|
|
1189
|
+
-------
|
|
1190
|
+
typing.Optional[typing.Any]
|
|
1191
|
+
Successful Response
|
|
1192
|
+
|
|
1193
|
+
Examples
|
|
1194
|
+
--------
|
|
1195
|
+
import asyncio
|
|
1196
|
+
|
|
1197
|
+
from agenta import AsyncAgentaApi
|
|
1198
|
+
|
|
1199
|
+
client = AsyncAgentaApi(
|
|
1200
|
+
api_key="YOUR_API_KEY",
|
|
1201
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1202
|
+
)
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
async def main() -> None:
|
|
1206
|
+
await client.human_evaluations.update_human_evaluation(
|
|
1207
|
+
evaluation_id="evaluation_id",
|
|
1208
|
+
)
|
|
1209
|
+
|
|
1210
|
+
|
|
1211
|
+
asyncio.run(main())
|
|
1212
|
+
"""
|
|
1213
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1214
|
+
f"human-evaluations/{jsonable_encoder(evaluation_id)}",
|
|
1215
|
+
method="PUT",
|
|
1216
|
+
json={
|
|
1217
|
+
"status": status,
|
|
1218
|
+
},
|
|
1219
|
+
headers={
|
|
1220
|
+
"content-type": "application/json",
|
|
1221
|
+
},
|
|
1222
|
+
request_options=request_options,
|
|
1223
|
+
omit=OMIT,
|
|
1224
|
+
)
|
|
1225
|
+
try:
|
|
1226
|
+
if 200 <= _response.status_code < 300:
|
|
1227
|
+
return typing.cast(
|
|
1228
|
+
typing.Optional[typing.Any],
|
|
1229
|
+
parse_obj_as(
|
|
1230
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1231
|
+
object_=_response.json(),
|
|
1232
|
+
),
|
|
1233
|
+
)
|
|
1234
|
+
if _response.status_code == 422:
|
|
1235
|
+
raise UnprocessableEntityError(
|
|
1236
|
+
typing.cast(
|
|
1237
|
+
HttpValidationError,
|
|
1238
|
+
parse_obj_as(
|
|
1239
|
+
type_=HttpValidationError, # type: ignore
|
|
1240
|
+
object_=_response.json(),
|
|
1241
|
+
),
|
|
1242
|
+
)
|
|
1243
|
+
)
|
|
1244
|
+
_response_json = _response.json()
|
|
1245
|
+
except JSONDecodeError:
|
|
1246
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1247
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1248
|
+
|
|
1249
|
+
async def fetch_human_evaluation_scenarios(
|
|
1250
|
+
self,
|
|
1251
|
+
evaluation_id: str,
|
|
1252
|
+
*,
|
|
1253
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1254
|
+
) -> typing.List[HumanEvaluationScenario]:
|
|
1255
|
+
"""
|
|
1256
|
+
Fetches evaluation scenarios for a given evaluation ID.
|
|
1257
|
+
|
|
1258
|
+
Arguments:
|
|
1259
|
+
evaluation_id (str): The ID of the evaluation for which to fetch scenarios.
|
|
1260
|
+
|
|
1261
|
+
Raises:
|
|
1262
|
+
HTTPException: If the evaluation is not found or access is denied.
|
|
1263
|
+
|
|
1264
|
+
Returns:
|
|
1265
|
+
List[EvaluationScenario]: A list of evaluation scenarios.
|
|
1266
|
+
|
|
1267
|
+
Parameters
|
|
1268
|
+
----------
|
|
1269
|
+
evaluation_id : str
|
|
1270
|
+
|
|
1271
|
+
request_options : typing.Optional[RequestOptions]
|
|
1272
|
+
Request-specific configuration.
|
|
1273
|
+
|
|
1274
|
+
Returns
|
|
1275
|
+
-------
|
|
1276
|
+
typing.List[HumanEvaluationScenario]
|
|
1277
|
+
Successful Response
|
|
1278
|
+
|
|
1279
|
+
Examples
|
|
1280
|
+
--------
|
|
1281
|
+
import asyncio
|
|
1282
|
+
|
|
1283
|
+
from agenta import AsyncAgentaApi
|
|
1284
|
+
|
|
1285
|
+
client = AsyncAgentaApi(
|
|
1286
|
+
api_key="YOUR_API_KEY",
|
|
1287
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1288
|
+
)
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
async def main() -> None:
|
|
1292
|
+
await client.human_evaluations.fetch_human_evaluation_scenarios(
|
|
1293
|
+
evaluation_id="evaluation_id",
|
|
1294
|
+
)
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
asyncio.run(main())
|
|
1298
|
+
"""
|
|
1299
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1300
|
+
f"human-evaluations/{jsonable_encoder(evaluation_id)}/evaluation_scenarios",
|
|
1301
|
+
method="GET",
|
|
1302
|
+
request_options=request_options,
|
|
1303
|
+
)
|
|
1304
|
+
try:
|
|
1305
|
+
if 200 <= _response.status_code < 300:
|
|
1306
|
+
return typing.cast(
|
|
1307
|
+
typing.List[HumanEvaluationScenario],
|
|
1308
|
+
parse_obj_as(
|
|
1309
|
+
type_=typing.List[HumanEvaluationScenario], # type: ignore
|
|
1310
|
+
object_=_response.json(),
|
|
1311
|
+
),
|
|
1312
|
+
)
|
|
1313
|
+
if _response.status_code == 422:
|
|
1314
|
+
raise UnprocessableEntityError(
|
|
1315
|
+
typing.cast(
|
|
1316
|
+
HttpValidationError,
|
|
1317
|
+
parse_obj_as(
|
|
1318
|
+
type_=HttpValidationError, # type: ignore
|
|
1319
|
+
object_=_response.json(),
|
|
1320
|
+
),
|
|
1321
|
+
)
|
|
1322
|
+
)
|
|
1323
|
+
_response_json = _response.json()
|
|
1324
|
+
except JSONDecodeError:
|
|
1325
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1326
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1327
|
+
|
|
1328
|
+
async def update_evaluation_scenario_router(
|
|
1329
|
+
self,
|
|
1330
|
+
evaluation_id: str,
|
|
1331
|
+
evaluation_scenario_id: str,
|
|
1332
|
+
evaluation_type: EvaluationType,
|
|
1333
|
+
*,
|
|
1334
|
+
vote: typing.Optional[str] = OMIT,
|
|
1335
|
+
score: typing.Optional[Score] = OMIT,
|
|
1336
|
+
correct_answer: typing.Optional[str] = OMIT,
|
|
1337
|
+
outputs: typing.Optional[typing.Sequence[HumanEvaluationScenarioOutput]] = OMIT,
|
|
1338
|
+
inputs: typing.Optional[typing.Sequence[HumanEvaluationScenarioInput]] = OMIT,
|
|
1339
|
+
is_pinned: typing.Optional[bool] = OMIT,
|
|
1340
|
+
note: typing.Optional[str] = OMIT,
|
|
1341
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1342
|
+
) -> typing.Optional[typing.Any]:
|
|
1343
|
+
"""
|
|
1344
|
+
Updates an evaluation scenario's vote or score based on its type.
|
|
1345
|
+
|
|
1346
|
+
Raises:
|
|
1347
|
+
HTTPException: If update fails or unauthorized.
|
|
1348
|
+
|
|
1349
|
+
Returns:
|
|
1350
|
+
None: 204 No Content status code upon successful update.
|
|
1351
|
+
|
|
1352
|
+
Parameters
|
|
1353
|
+
----------
|
|
1354
|
+
evaluation_id : str
|
|
1355
|
+
|
|
1356
|
+
evaluation_scenario_id : str
|
|
1357
|
+
|
|
1358
|
+
evaluation_type : EvaluationType
|
|
1359
|
+
|
|
1360
|
+
vote : typing.Optional[str]
|
|
1361
|
+
|
|
1362
|
+
score : typing.Optional[Score]
|
|
1363
|
+
|
|
1364
|
+
correct_answer : typing.Optional[str]
|
|
1365
|
+
|
|
1366
|
+
outputs : typing.Optional[typing.Sequence[HumanEvaluationScenarioOutput]]
|
|
1367
|
+
|
|
1368
|
+
inputs : typing.Optional[typing.Sequence[HumanEvaluationScenarioInput]]
|
|
1369
|
+
|
|
1370
|
+
is_pinned : typing.Optional[bool]
|
|
1371
|
+
|
|
1372
|
+
note : typing.Optional[str]
|
|
1373
|
+
|
|
1374
|
+
request_options : typing.Optional[RequestOptions]
|
|
1375
|
+
Request-specific configuration.
|
|
1376
|
+
|
|
1377
|
+
Returns
|
|
1378
|
+
-------
|
|
1379
|
+
typing.Optional[typing.Any]
|
|
1380
|
+
Successful Response
|
|
1381
|
+
|
|
1382
|
+
Examples
|
|
1383
|
+
--------
|
|
1384
|
+
import asyncio
|
|
1385
|
+
|
|
1386
|
+
from agenta import AsyncAgentaApi
|
|
1387
|
+
|
|
1388
|
+
client = AsyncAgentaApi(
|
|
1389
|
+
api_key="YOUR_API_KEY",
|
|
1390
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1391
|
+
)
|
|
1392
|
+
|
|
1393
|
+
|
|
1394
|
+
async def main() -> None:
|
|
1395
|
+
await client.human_evaluations.update_evaluation_scenario_router(
|
|
1396
|
+
evaluation_id="evaluation_id",
|
|
1397
|
+
evaluation_scenario_id="evaluation_scenario_id",
|
|
1398
|
+
evaluation_type="human_a_b_testing",
|
|
1399
|
+
)
|
|
1400
|
+
|
|
1401
|
+
|
|
1402
|
+
asyncio.run(main())
|
|
1403
|
+
"""
|
|
1404
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1405
|
+
f"human-evaluations/{jsonable_encoder(evaluation_id)}/evaluation_scenario/{jsonable_encoder(evaluation_scenario_id)}/{jsonable_encoder(evaluation_type)}",
|
|
1406
|
+
method="PUT",
|
|
1407
|
+
json={
|
|
1408
|
+
"vote": vote,
|
|
1409
|
+
"score": score,
|
|
1410
|
+
"correct_answer": correct_answer,
|
|
1411
|
+
"outputs": convert_and_respect_annotation_metadata(
|
|
1412
|
+
object_=outputs,
|
|
1413
|
+
annotation=typing.Sequence[HumanEvaluationScenarioOutput],
|
|
1414
|
+
direction="write",
|
|
1415
|
+
),
|
|
1416
|
+
"inputs": convert_and_respect_annotation_metadata(
|
|
1417
|
+
object_=inputs,
|
|
1418
|
+
annotation=typing.Sequence[HumanEvaluationScenarioInput],
|
|
1419
|
+
direction="write",
|
|
1420
|
+
),
|
|
1421
|
+
"is_pinned": is_pinned,
|
|
1422
|
+
"note": note,
|
|
1423
|
+
},
|
|
1424
|
+
headers={
|
|
1425
|
+
"content-type": "application/json",
|
|
1426
|
+
},
|
|
1427
|
+
request_options=request_options,
|
|
1428
|
+
omit=OMIT,
|
|
1429
|
+
)
|
|
1430
|
+
try:
|
|
1431
|
+
if 200 <= _response.status_code < 300:
|
|
1432
|
+
return typing.cast(
|
|
1433
|
+
typing.Optional[typing.Any],
|
|
1434
|
+
parse_obj_as(
|
|
1435
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1436
|
+
object_=_response.json(),
|
|
1437
|
+
),
|
|
1438
|
+
)
|
|
1439
|
+
if _response.status_code == 422:
|
|
1440
|
+
raise UnprocessableEntityError(
|
|
1441
|
+
typing.cast(
|
|
1442
|
+
HttpValidationError,
|
|
1443
|
+
parse_obj_as(
|
|
1444
|
+
type_=HttpValidationError, # type: ignore
|
|
1445
|
+
object_=_response.json(),
|
|
1446
|
+
),
|
|
1447
|
+
)
|
|
1448
|
+
)
|
|
1449
|
+
_response_json = _response.json()
|
|
1450
|
+
except JSONDecodeError:
|
|
1451
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1452
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1453
|
+
|
|
1454
|
+
async def get_evaluation_scenario_score_router(
|
|
1455
|
+
self,
|
|
1456
|
+
evaluation_scenario_id: str,
|
|
1457
|
+
*,
|
|
1458
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1459
|
+
) -> typing.Dict[str, str]:
|
|
1460
|
+
"""
|
|
1461
|
+
Fetch the score of a specific evaluation scenario.
|
|
1462
|
+
|
|
1463
|
+
Args:
|
|
1464
|
+
evaluation_scenario_id: The ID of the evaluation scenario to fetch.
|
|
1465
|
+
stoken_session: Session data, verified by `verify_session`.
|
|
1466
|
+
|
|
1467
|
+
Returns:
|
|
1468
|
+
Dictionary containing the scenario ID and its score.
|
|
1469
|
+
|
|
1470
|
+
Parameters
|
|
1471
|
+
----------
|
|
1472
|
+
evaluation_scenario_id : str
|
|
1473
|
+
|
|
1474
|
+
request_options : typing.Optional[RequestOptions]
|
|
1475
|
+
Request-specific configuration.
|
|
1476
|
+
|
|
1477
|
+
Returns
|
|
1478
|
+
-------
|
|
1479
|
+
typing.Dict[str, str]
|
|
1480
|
+
Successful Response
|
|
1481
|
+
|
|
1482
|
+
Examples
|
|
1483
|
+
--------
|
|
1484
|
+
import asyncio
|
|
1485
|
+
|
|
1486
|
+
from agenta import AsyncAgentaApi
|
|
1487
|
+
|
|
1488
|
+
client = AsyncAgentaApi(
|
|
1489
|
+
api_key="YOUR_API_KEY",
|
|
1490
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1491
|
+
)
|
|
1492
|
+
|
|
1493
|
+
|
|
1494
|
+
async def main() -> None:
|
|
1495
|
+
await client.human_evaluations.get_evaluation_scenario_score_router(
|
|
1496
|
+
evaluation_scenario_id="evaluation_scenario_id",
|
|
1497
|
+
)
|
|
1498
|
+
|
|
1499
|
+
|
|
1500
|
+
asyncio.run(main())
|
|
1501
|
+
"""
|
|
1502
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1503
|
+
f"human-evaluations/evaluation_scenario/{jsonable_encoder(evaluation_scenario_id)}/score",
|
|
1504
|
+
method="GET",
|
|
1505
|
+
request_options=request_options,
|
|
1506
|
+
)
|
|
1507
|
+
try:
|
|
1508
|
+
if 200 <= _response.status_code < 300:
|
|
1509
|
+
return typing.cast(
|
|
1510
|
+
typing.Dict[str, str],
|
|
1511
|
+
parse_obj_as(
|
|
1512
|
+
type_=typing.Dict[str, str], # type: ignore
|
|
1513
|
+
object_=_response.json(),
|
|
1514
|
+
),
|
|
1515
|
+
)
|
|
1516
|
+
if _response.status_code == 422:
|
|
1517
|
+
raise UnprocessableEntityError(
|
|
1518
|
+
typing.cast(
|
|
1519
|
+
HttpValidationError,
|
|
1520
|
+
parse_obj_as(
|
|
1521
|
+
type_=HttpValidationError, # type: ignore
|
|
1522
|
+
object_=_response.json(),
|
|
1523
|
+
),
|
|
1524
|
+
)
|
|
1525
|
+
)
|
|
1526
|
+
_response_json = _response.json()
|
|
1527
|
+
except JSONDecodeError:
|
|
1528
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1529
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1530
|
+
|
|
1531
|
+
async def update_evaluation_scenario_score_router(
|
|
1532
|
+
self,
|
|
1533
|
+
evaluation_scenario_id: str,
|
|
1534
|
+
*,
|
|
1535
|
+
score: float,
|
|
1536
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1537
|
+
) -> typing.Optional[typing.Any]:
|
|
1538
|
+
"""
|
|
1539
|
+
Updates the score of an evaluation scenario.
|
|
1540
|
+
|
|
1541
|
+
Raises:
|
|
1542
|
+
HTTPException: Server error if the evaluation update fails.
|
|
1543
|
+
|
|
1544
|
+
Returns:
|
|
1545
|
+
None: 204 No Content status code upon successful update.
|
|
1546
|
+
|
|
1547
|
+
Parameters
|
|
1548
|
+
----------
|
|
1549
|
+
evaluation_scenario_id : str
|
|
1550
|
+
|
|
1551
|
+
score : float
|
|
1552
|
+
|
|
1553
|
+
request_options : typing.Optional[RequestOptions]
|
|
1554
|
+
Request-specific configuration.
|
|
1555
|
+
|
|
1556
|
+
Returns
|
|
1557
|
+
-------
|
|
1558
|
+
typing.Optional[typing.Any]
|
|
1559
|
+
Successful Response
|
|
1560
|
+
|
|
1561
|
+
Examples
|
|
1562
|
+
--------
|
|
1563
|
+
import asyncio
|
|
1564
|
+
|
|
1565
|
+
from agenta import AsyncAgentaApi
|
|
1566
|
+
|
|
1567
|
+
client = AsyncAgentaApi(
|
|
1568
|
+
api_key="YOUR_API_KEY",
|
|
1569
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1570
|
+
)
|
|
1571
|
+
|
|
1572
|
+
|
|
1573
|
+
async def main() -> None:
|
|
1574
|
+
await client.human_evaluations.update_evaluation_scenario_score_router(
|
|
1575
|
+
evaluation_scenario_id="evaluation_scenario_id",
|
|
1576
|
+
score=1.1,
|
|
1577
|
+
)
|
|
1578
|
+
|
|
1579
|
+
|
|
1580
|
+
asyncio.run(main())
|
|
1581
|
+
"""
|
|
1582
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1583
|
+
f"human-evaluations/evaluation_scenario/{jsonable_encoder(evaluation_scenario_id)}/score",
|
|
1584
|
+
method="PUT",
|
|
1585
|
+
json={
|
|
1586
|
+
"score": score,
|
|
1587
|
+
},
|
|
1588
|
+
headers={
|
|
1589
|
+
"content-type": "application/json",
|
|
1590
|
+
},
|
|
1591
|
+
request_options=request_options,
|
|
1592
|
+
omit=OMIT,
|
|
1593
|
+
)
|
|
1594
|
+
try:
|
|
1595
|
+
if 200 <= _response.status_code < 300:
|
|
1596
|
+
return typing.cast(
|
|
1597
|
+
typing.Optional[typing.Any],
|
|
1598
|
+
parse_obj_as(
|
|
1599
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1600
|
+
object_=_response.json(),
|
|
1601
|
+
),
|
|
1602
|
+
)
|
|
1603
|
+
if _response.status_code == 422:
|
|
1604
|
+
raise UnprocessableEntityError(
|
|
1605
|
+
typing.cast(
|
|
1606
|
+
HttpValidationError,
|
|
1607
|
+
parse_obj_as(
|
|
1608
|
+
type_=HttpValidationError, # type: ignore
|
|
1609
|
+
object_=_response.json(),
|
|
1610
|
+
),
|
|
1611
|
+
)
|
|
1612
|
+
)
|
|
1613
|
+
_response_json = _response.json()
|
|
1614
|
+
except JSONDecodeError:
|
|
1615
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1616
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1617
|
+
|
|
1618
|
+
async def fetch_results(
|
|
1619
|
+
self,
|
|
1620
|
+
evaluation_id: str,
|
|
1621
|
+
*,
|
|
1622
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1623
|
+
) -> typing.Optional[typing.Any]:
|
|
1624
|
+
"""
|
|
1625
|
+
Fetch all the results for one the comparison table
|
|
1626
|
+
|
|
1627
|
+
Arguments:
|
|
1628
|
+
evaluation_id -- _description_
|
|
1629
|
+
|
|
1630
|
+
Returns:
|
|
1631
|
+
_description_
|
|
1632
|
+
|
|
1633
|
+
Parameters
|
|
1634
|
+
----------
|
|
1635
|
+
evaluation_id : str
|
|
1636
|
+
|
|
1637
|
+
request_options : typing.Optional[RequestOptions]
|
|
1638
|
+
Request-specific configuration.
|
|
1639
|
+
|
|
1640
|
+
Returns
|
|
1641
|
+
-------
|
|
1642
|
+
typing.Optional[typing.Any]
|
|
1643
|
+
Successful Response
|
|
1644
|
+
|
|
1645
|
+
Examples
|
|
1646
|
+
--------
|
|
1647
|
+
import asyncio
|
|
1648
|
+
|
|
1649
|
+
from agenta import AsyncAgentaApi
|
|
1650
|
+
|
|
1651
|
+
client = AsyncAgentaApi(
|
|
1652
|
+
api_key="YOUR_API_KEY",
|
|
1653
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1654
|
+
)
|
|
1655
|
+
|
|
1656
|
+
|
|
1657
|
+
async def main() -> None:
|
|
1658
|
+
await client.human_evaluations.fetch_results(
|
|
1659
|
+
evaluation_id="evaluation_id",
|
|
1660
|
+
)
|
|
1661
|
+
|
|
1662
|
+
|
|
1663
|
+
asyncio.run(main())
|
|
1664
|
+
"""
|
|
1665
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1666
|
+
f"human-evaluations/{jsonable_encoder(evaluation_id)}/results",
|
|
1667
|
+
method="GET",
|
|
1668
|
+
request_options=request_options,
|
|
1669
|
+
)
|
|
1670
|
+
try:
|
|
1671
|
+
if 200 <= _response.status_code < 300:
|
|
1672
|
+
return typing.cast(
|
|
1673
|
+
typing.Optional[typing.Any],
|
|
1674
|
+
parse_obj_as(
|
|
1675
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1676
|
+
object_=_response.json(),
|
|
1677
|
+
),
|
|
1678
|
+
)
|
|
1679
|
+
if _response.status_code == 422:
|
|
1680
|
+
raise UnprocessableEntityError(
|
|
1681
|
+
typing.cast(
|
|
1682
|
+
HttpValidationError,
|
|
1683
|
+
parse_obj_as(
|
|
1684
|
+
type_=HttpValidationError, # type: ignore
|
|
1685
|
+
object_=_response.json(),
|
|
1686
|
+
),
|
|
1687
|
+
)
|
|
1688
|
+
)
|
|
1689
|
+
_response_json = _response.json()
|
|
1690
|
+
except JSONDecodeError:
|
|
1691
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1692
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|