agenta 0.24.1a0__py3-none-any.whl → 0.24.2__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.

Potentially problematic release.


This version of agenta might be problematic. Click here for more details.

Files changed (132) hide show
  1. agenta/cli/variant_commands.py +15 -10
  2. agenta/client/Readme.md +72 -64
  3. agenta/client/api.py +1 -1
  4. agenta/client/backend/__init__.py +14 -9
  5. agenta/client/backend/apps/client.py +1669 -0
  6. agenta/client/backend/bases/client.py +190 -0
  7. agenta/client/backend/client.py +2102 -868
  8. agenta/client/backend/configs/client.py +598 -0
  9. agenta/client/backend/containers/client.py +638 -0
  10. agenta/client/backend/{resources/containers → containers}/types/container_templates_response.py +1 -2
  11. agenta/client/backend/core/__init__.py +29 -0
  12. agenta/client/backend/core/client_wrapper.py +42 -9
  13. agenta/client/backend/core/datetime_utils.py +1 -1
  14. agenta/client/backend/core/file.py +43 -0
  15. agenta/client/backend/core/http_client.py +553 -0
  16. agenta/client/backend/core/jsonable_encoder.py +33 -39
  17. agenta/client/backend/core/pydantic_utilities.py +212 -0
  18. agenta/client/backend/core/query_encoder.py +60 -0
  19. agenta/client/backend/core/remove_none_from_dict.py +2 -2
  20. agenta/client/backend/core/request_options.py +32 -0
  21. agenta/client/backend/core/serialization.py +179 -0
  22. agenta/client/backend/environments/client.py +190 -0
  23. agenta/client/backend/evaluations/client.py +1462 -0
  24. agenta/client/backend/evaluators/client.py +911 -0
  25. agenta/client/backend/observability/client.py +1271 -0
  26. agenta/client/backend/testsets/client.py +1132 -0
  27. agenta/client/backend/types/__init__.py +8 -6
  28. agenta/client/backend/types/aggregated_result.py +14 -29
  29. agenta/client/backend/types/aggregated_result_evaluator_config.py +1 -2
  30. agenta/client/backend/types/app.py +13 -28
  31. agenta/client/backend/types/app_variant_response.py +21 -37
  32. agenta/client/backend/types/app_variant_revision.py +17 -32
  33. agenta/client/backend/types/base_output.py +13 -28
  34. agenta/client/backend/types/body_import_testset.py +16 -31
  35. agenta/client/backend/types/config_db.py +16 -31
  36. agenta/client/backend/types/correct_answer.py +22 -0
  37. agenta/client/backend/types/create_app_output.py +13 -28
  38. agenta/client/backend/types/create_span.py +33 -50
  39. agenta/client/backend/types/create_trace_response.py +16 -31
  40. agenta/client/backend/types/docker_env_vars.py +13 -28
  41. agenta/client/backend/types/environment_output.py +21 -36
  42. agenta/client/backend/types/environment_output_extended.py +21 -36
  43. agenta/client/backend/types/environment_revision.py +18 -33
  44. agenta/client/backend/types/error.py +16 -31
  45. agenta/client/backend/types/evaluation.py +20 -34
  46. agenta/client/backend/types/evaluation_scenario.py +18 -33
  47. agenta/client/backend/types/evaluation_scenario_input.py +16 -31
  48. agenta/client/backend/types/evaluation_scenario_output.py +18 -33
  49. agenta/client/backend/types/evaluation_scenario_result.py +14 -29
  50. agenta/client/backend/types/evaluation_scenario_score_update.py +13 -28
  51. agenta/client/backend/types/evaluation_status_enum.py +11 -33
  52. agenta/client/backend/types/evaluation_type.py +3 -21
  53. agenta/client/backend/types/evaluator.py +18 -32
  54. agenta/client/backend/types/evaluator_config.py +20 -33
  55. agenta/client/backend/types/get_config_response.py +16 -31
  56. agenta/client/backend/types/http_validation_error.py +14 -29
  57. agenta/client/backend/types/human_evaluation.py +17 -32
  58. agenta/client/backend/types/human_evaluation_scenario.py +21 -37
  59. agenta/client/backend/types/human_evaluation_scenario_input.py +13 -28
  60. agenta/client/backend/types/human_evaluation_scenario_output.py +13 -28
  61. agenta/client/backend/types/human_evaluation_scenario_update.py +26 -41
  62. agenta/client/backend/types/human_evaluation_update.py +14 -29
  63. agenta/client/backend/types/image.py +18 -33
  64. agenta/client/backend/types/invite_request.py +13 -28
  65. agenta/client/backend/types/list_api_keys_response.py +18 -33
  66. agenta/client/backend/types/llm_run_rate_limit.py +13 -28
  67. agenta/client/backend/types/llm_tokens.py +16 -31
  68. agenta/client/backend/types/lm_providers_enum.py +21 -0
  69. agenta/client/backend/types/new_human_evaluation.py +13 -28
  70. agenta/client/backend/types/new_testset.py +16 -31
  71. agenta/client/backend/types/organization.py +22 -36
  72. agenta/client/backend/types/organization_output.py +13 -28
  73. agenta/client/backend/types/outputs.py +5 -0
  74. agenta/client/backend/types/permission.py +36 -137
  75. agenta/client/backend/types/result.py +17 -32
  76. agenta/client/backend/types/simple_evaluation_output.py +13 -28
  77. agenta/client/backend/types/span.py +23 -38
  78. agenta/client/backend/types/span_detail.py +26 -40
  79. agenta/client/backend/types/span_status_code.py +1 -25
  80. agenta/client/backend/types/span_variant.py +16 -31
  81. agenta/client/backend/types/template.py +14 -29
  82. agenta/client/backend/types/template_image_info.py +21 -35
  83. agenta/client/backend/types/test_set_output_response.py +16 -32
  84. agenta/client/backend/types/test_set_simple_response.py +13 -28
  85. agenta/client/backend/types/trace_detail.py +26 -40
  86. agenta/client/backend/types/update_app_output.py +22 -0
  87. agenta/client/backend/types/uri.py +13 -28
  88. agenta/client/backend/types/validation_error.py +13 -28
  89. agenta/client/backend/types/variant_action.py +14 -29
  90. agenta/client/backend/types/variant_action_enum.py +1 -19
  91. agenta/client/backend/types/with_pagination.py +14 -30
  92. agenta/client/backend/types/workspace_member_response.py +14 -29
  93. agenta/client/backend/types/workspace_permission.py +18 -33
  94. agenta/client/backend/types/workspace_response.py +20 -35
  95. agenta/client/backend/types/workspace_role.py +11 -37
  96. agenta/client/backend/types/workspace_role_response.py +17 -32
  97. agenta/client/backend/variants/client.py +1447 -0
  98. agenta/client/backend/variants/types/add_variant_from_base_and_config_response.py +8 -0
  99. agenta/sdk/decorators/llm_entrypoint.py +8 -13
  100. agenta/sdk/tracing/llm_tracing.py +10 -12
  101. {agenta-0.24.1a0.dist-info → agenta-0.24.2.dist-info}/METADATA +1 -1
  102. agenta-0.24.2.dist-info/RECORD +175 -0
  103. agenta/client/backend/resources/__init__.py +0 -31
  104. agenta/client/backend/resources/apps/client.py +0 -977
  105. agenta/client/backend/resources/bases/client.py +0 -127
  106. agenta/client/backend/resources/configs/client.py +0 -377
  107. agenta/client/backend/resources/containers/client.py +0 -383
  108. agenta/client/backend/resources/environments/client.py +0 -131
  109. agenta/client/backend/resources/evaluations/client.py +0 -1008
  110. agenta/client/backend/resources/evaluators/client.py +0 -594
  111. agenta/client/backend/resources/observability/client.py +0 -1187
  112. agenta/client/backend/resources/testsets/client.py +0 -689
  113. agenta/client/backend/resources/variants/client.py +0 -796
  114. agenta/client/backend/resources/variants/types/add_variant_from_base_and_config_response.py +0 -7
  115. agenta/client/backend/types/evaluation_webhook.py +0 -36
  116. agenta/client/backend/types/feedback.py +0 -40
  117. agenta/client/backend/types/span_kind.py +0 -49
  118. agenta-0.24.1a0.dist-info/RECORD +0 -169
  119. /agenta/client/backend/{resources/apps → apps}/__init__.py +0 -0
  120. /agenta/client/backend/{resources/bases → bases}/__init__.py +0 -0
  121. /agenta/client/backend/{resources/configs → configs}/__init__.py +0 -0
  122. /agenta/client/backend/{resources/containers → containers}/__init__.py +0 -0
  123. /agenta/client/backend/{resources/containers → containers}/types/__init__.py +0 -0
  124. /agenta/client/backend/{resources/environments → environments}/__init__.py +0 -0
  125. /agenta/client/backend/{resources/evaluations → evaluations}/__init__.py +0 -0
  126. /agenta/client/backend/{resources/evaluators → evaluators}/__init__.py +0 -0
  127. /agenta/client/backend/{resources/observability → observability}/__init__.py +0 -0
  128. /agenta/client/backend/{resources/testsets → testsets}/__init__.py +0 -0
  129. /agenta/client/backend/{resources/variants → variants}/__init__.py +0 -0
  130. /agenta/client/backend/{resources/variants → variants}/types/__init__.py +0 -0
  131. {agenta-0.24.1a0.dist-info → agenta-0.24.2.dist-info}/WHEEL +0 -0
  132. {agenta-0.24.1a0.dist-info → agenta-0.24.2.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,1462 @@
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 ..core.pydantic_utilities import parse_obj_as
7
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
8
+ from ..types.http_validation_error import HttpValidationError
9
+ from json.decoder import JSONDecodeError
10
+ from ..core.api_error import ApiError
11
+ from ..types.evaluation import Evaluation
12
+ from ..types.llm_run_rate_limit import LlmRunRateLimit
13
+ from ..core.jsonable_encoder import jsonable_encoder
14
+ from ..types.evaluation_scenario import EvaluationScenario
15
+ from ..core.client_wrapper import AsyncClientWrapper
16
+
17
+ # this is used as the default value for optional parameters
18
+ OMIT = typing.cast(typing.Any, ...)
19
+
20
+
21
+ class EvaluationsClient:
22
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
23
+ self._client_wrapper = client_wrapper
24
+
25
+ def fetch_evaluation_ids(
26
+ self,
27
+ *,
28
+ app_id: str,
29
+ resource_type: str,
30
+ resource_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
31
+ request_options: typing.Optional[RequestOptions] = None,
32
+ ) -> typing.List[str]:
33
+ """
34
+ Fetches evaluation ids for a given resource type and id.
35
+
36
+ Arguments:
37
+ app_id (str): The ID of the app for which to fetch evaluations.
38
+ resource_type (str): The type of resource for which to fetch evaluations.
39
+ resource_ids List[ObjectId]: The IDs of resource for which to fetch evaluations.
40
+
41
+ Raises:
42
+ HTTPException: If the resource_type is invalid or access is denied.
43
+
44
+ Returns:
45
+ List[str]: A list of evaluation ids.
46
+
47
+ Parameters
48
+ ----------
49
+ app_id : str
50
+
51
+ resource_type : str
52
+
53
+ resource_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
54
+
55
+ request_options : typing.Optional[RequestOptions]
56
+ Request-specific configuration.
57
+
58
+ Returns
59
+ -------
60
+ typing.List[str]
61
+ Successful Response
62
+
63
+ Examples
64
+ --------
65
+ from agenta import AgentaApi
66
+
67
+ client = AgentaApi(
68
+ api_key="YOUR_API_KEY",
69
+ base_url="https://yourhost.com/path/to/api",
70
+ )
71
+ client.evaluations.fetch_evaluation_ids(
72
+ app_id="app_id",
73
+ resource_type="resource_type",
74
+ )
75
+ """
76
+ _response = self._client_wrapper.httpx_client.request(
77
+ "evaluations/by_resource",
78
+ method="GET",
79
+ params={
80
+ "app_id": app_id,
81
+ "resource_type": resource_type,
82
+ "resource_ids": resource_ids,
83
+ },
84
+ request_options=request_options,
85
+ )
86
+ try:
87
+ if 200 <= _response.status_code < 300:
88
+ return typing.cast(
89
+ typing.List[str],
90
+ parse_obj_as(
91
+ type_=typing.List[str], # type: ignore
92
+ object_=_response.json(),
93
+ ),
94
+ )
95
+ if _response.status_code == 422:
96
+ raise UnprocessableEntityError(
97
+ typing.cast(
98
+ HttpValidationError,
99
+ parse_obj_as(
100
+ type_=HttpValidationError, # type: ignore
101
+ object_=_response.json(),
102
+ ),
103
+ )
104
+ )
105
+ _response_json = _response.json()
106
+ except JSONDecodeError:
107
+ raise ApiError(status_code=_response.status_code, body=_response.text)
108
+ raise ApiError(status_code=_response.status_code, body=_response_json)
109
+
110
+ def fetch_list_evaluations(
111
+ self, *, app_id: str, request_options: typing.Optional[RequestOptions] = None
112
+ ) -> typing.List[Evaluation]:
113
+ """
114
+ Fetches a list of evaluations, optionally filtered by an app ID.
115
+
116
+ Args:
117
+ app_id (Optional[str]): An optional app ID to filter the evaluations.
118
+
119
+ Returns:
120
+ List[Evaluation]: A list of evaluations.
121
+
122
+ Parameters
123
+ ----------
124
+ app_id : str
125
+
126
+ request_options : typing.Optional[RequestOptions]
127
+ Request-specific configuration.
128
+
129
+ Returns
130
+ -------
131
+ typing.List[Evaluation]
132
+ Successful Response
133
+
134
+ Examples
135
+ --------
136
+ from agenta import AgentaApi
137
+
138
+ client = AgentaApi(
139
+ api_key="YOUR_API_KEY",
140
+ base_url="https://yourhost.com/path/to/api",
141
+ )
142
+ client.evaluations.fetch_list_evaluations(
143
+ app_id="app_id",
144
+ )
145
+ """
146
+ _response = self._client_wrapper.httpx_client.request(
147
+ "evaluations",
148
+ method="GET",
149
+ params={
150
+ "app_id": app_id,
151
+ },
152
+ request_options=request_options,
153
+ )
154
+ try:
155
+ if 200 <= _response.status_code < 300:
156
+ return typing.cast(
157
+ typing.List[Evaluation],
158
+ parse_obj_as(
159
+ type_=typing.List[Evaluation], # type: ignore
160
+ object_=_response.json(),
161
+ ),
162
+ )
163
+ if _response.status_code == 422:
164
+ raise UnprocessableEntityError(
165
+ typing.cast(
166
+ HttpValidationError,
167
+ parse_obj_as(
168
+ type_=HttpValidationError, # type: ignore
169
+ object_=_response.json(),
170
+ ),
171
+ )
172
+ )
173
+ _response_json = _response.json()
174
+ except JSONDecodeError:
175
+ raise ApiError(status_code=_response.status_code, body=_response.text)
176
+ raise ApiError(status_code=_response.status_code, body=_response_json)
177
+
178
+ def create_evaluation(
179
+ self,
180
+ *,
181
+ app_id: str,
182
+ variant_ids: typing.Sequence[str],
183
+ evaluators_configs: typing.Sequence[str],
184
+ testset_id: str,
185
+ rate_limit: LlmRunRateLimit,
186
+ lm_providers_keys: typing.Optional[
187
+ typing.Dict[str, typing.Optional[str]]
188
+ ] = OMIT,
189
+ correct_answer_column: typing.Optional[str] = OMIT,
190
+ request_options: typing.Optional[RequestOptions] = None,
191
+ ) -> typing.List[Evaluation]:
192
+ """
193
+ Creates a new comparison table document
194
+ Raises:
195
+ HTTPException: _description_
196
+ Returns:
197
+ _description_
198
+
199
+ Parameters
200
+ ----------
201
+ app_id : str
202
+
203
+ variant_ids : typing.Sequence[str]
204
+
205
+ evaluators_configs : typing.Sequence[str]
206
+
207
+ testset_id : str
208
+
209
+ rate_limit : LlmRunRateLimit
210
+
211
+ lm_providers_keys : typing.Optional[typing.Dict[str, typing.Optional[str]]]
212
+
213
+ correct_answer_column : typing.Optional[str]
214
+
215
+ request_options : typing.Optional[RequestOptions]
216
+ Request-specific configuration.
217
+
218
+ Returns
219
+ -------
220
+ typing.List[Evaluation]
221
+ Successful Response
222
+
223
+ Examples
224
+ --------
225
+ from agenta import AgentaApi, LlmRunRateLimit
226
+
227
+ client = AgentaApi(
228
+ api_key="YOUR_API_KEY",
229
+ base_url="https://yourhost.com/path/to/api",
230
+ )
231
+ client.evaluations.create_evaluation(
232
+ app_id="app_id",
233
+ variant_ids=["variant_ids"],
234
+ evaluators_configs=["evaluators_configs"],
235
+ testset_id="testset_id",
236
+ rate_limit=LlmRunRateLimit(
237
+ batch_size=1,
238
+ max_retries=1,
239
+ retry_delay=1,
240
+ delay_between_batches=1,
241
+ ),
242
+ )
243
+ """
244
+ _response = self._client_wrapper.httpx_client.request(
245
+ "evaluations",
246
+ method="POST",
247
+ json={
248
+ "app_id": app_id,
249
+ "variant_ids": variant_ids,
250
+ "evaluators_configs": evaluators_configs,
251
+ "testset_id": testset_id,
252
+ "rate_limit": rate_limit,
253
+ "lm_providers_keys": lm_providers_keys,
254
+ "correct_answer_column": correct_answer_column,
255
+ },
256
+ request_options=request_options,
257
+ omit=OMIT,
258
+ )
259
+ try:
260
+ if 200 <= _response.status_code < 300:
261
+ return typing.cast(
262
+ typing.List[Evaluation],
263
+ parse_obj_as(
264
+ type_=typing.List[Evaluation], # type: ignore
265
+ object_=_response.json(),
266
+ ),
267
+ )
268
+ if _response.status_code == 422:
269
+ raise UnprocessableEntityError(
270
+ typing.cast(
271
+ HttpValidationError,
272
+ parse_obj_as(
273
+ type_=HttpValidationError, # type: ignore
274
+ object_=_response.json(),
275
+ ),
276
+ )
277
+ )
278
+ _response_json = _response.json()
279
+ except JSONDecodeError:
280
+ raise ApiError(status_code=_response.status_code, body=_response.text)
281
+ raise ApiError(status_code=_response.status_code, body=_response_json)
282
+
283
+ def delete_evaluations(
284
+ self,
285
+ *,
286
+ evaluations_ids: typing.Sequence[str],
287
+ request_options: typing.Optional[RequestOptions] = None,
288
+ ) -> typing.List[str]:
289
+ """
290
+ Delete specific comparison tables based on their unique IDs.
291
+
292
+ Args:
293
+ delete_evaluations (List[str]): The unique identifiers of the comparison tables to delete.
294
+
295
+ Returns:
296
+ A list of the deleted comparison tables' IDs.
297
+
298
+ Parameters
299
+ ----------
300
+ evaluations_ids : typing.Sequence[str]
301
+
302
+ request_options : typing.Optional[RequestOptions]
303
+ Request-specific configuration.
304
+
305
+ Returns
306
+ -------
307
+ typing.List[str]
308
+ Successful Response
309
+
310
+ Examples
311
+ --------
312
+ from agenta import AgentaApi
313
+
314
+ client = AgentaApi(
315
+ api_key="YOUR_API_KEY",
316
+ base_url="https://yourhost.com/path/to/api",
317
+ )
318
+ client.evaluations.delete_evaluations(
319
+ evaluations_ids=["evaluations_ids"],
320
+ )
321
+ """
322
+ _response = self._client_wrapper.httpx_client.request(
323
+ "evaluations",
324
+ method="DELETE",
325
+ json={
326
+ "evaluations_ids": evaluations_ids,
327
+ },
328
+ request_options=request_options,
329
+ omit=OMIT,
330
+ )
331
+ try:
332
+ if 200 <= _response.status_code < 300:
333
+ return typing.cast(
334
+ typing.List[str],
335
+ parse_obj_as(
336
+ type_=typing.List[str], # type: ignore
337
+ object_=_response.json(),
338
+ ),
339
+ )
340
+ if _response.status_code == 422:
341
+ raise UnprocessableEntityError(
342
+ typing.cast(
343
+ HttpValidationError,
344
+ parse_obj_as(
345
+ type_=HttpValidationError, # type: ignore
346
+ object_=_response.json(),
347
+ ),
348
+ )
349
+ )
350
+ _response_json = _response.json()
351
+ except JSONDecodeError:
352
+ raise ApiError(status_code=_response.status_code, body=_response.text)
353
+ raise ApiError(status_code=_response.status_code, body=_response_json)
354
+
355
+ def fetch_evaluation_status(
356
+ self,
357
+ evaluation_id: str,
358
+ *,
359
+ request_options: typing.Optional[RequestOptions] = None,
360
+ ) -> typing.Optional[typing.Any]:
361
+ """
362
+ Fetches the status of the evaluation.
363
+
364
+ Args:
365
+ evaluation_id (str): the evaluation id
366
+ request (Request): the request object
367
+
368
+ Returns:
369
+ (str): the evaluation status
370
+
371
+ Parameters
372
+ ----------
373
+ evaluation_id : str
374
+
375
+ request_options : typing.Optional[RequestOptions]
376
+ Request-specific configuration.
377
+
378
+ Returns
379
+ -------
380
+ typing.Optional[typing.Any]
381
+ Successful Response
382
+
383
+ Examples
384
+ --------
385
+ from agenta import AgentaApi
386
+
387
+ client = AgentaApi(
388
+ api_key="YOUR_API_KEY",
389
+ base_url="https://yourhost.com/path/to/api",
390
+ )
391
+ client.evaluations.fetch_evaluation_status(
392
+ evaluation_id="evaluation_id",
393
+ )
394
+ """
395
+ _response = self._client_wrapper.httpx_client.request(
396
+ f"evaluations/{jsonable_encoder(evaluation_id)}/status",
397
+ method="GET",
398
+ request_options=request_options,
399
+ )
400
+ try:
401
+ if 200 <= _response.status_code < 300:
402
+ return typing.cast(
403
+ typing.Optional[typing.Any],
404
+ parse_obj_as(
405
+ type_=typing.Optional[typing.Any], # type: ignore
406
+ object_=_response.json(),
407
+ ),
408
+ )
409
+ if _response.status_code == 422:
410
+ raise UnprocessableEntityError(
411
+ typing.cast(
412
+ HttpValidationError,
413
+ parse_obj_as(
414
+ type_=HttpValidationError, # type: ignore
415
+ object_=_response.json(),
416
+ ),
417
+ )
418
+ )
419
+ _response_json = _response.json()
420
+ except JSONDecodeError:
421
+ raise ApiError(status_code=_response.status_code, body=_response.text)
422
+ raise ApiError(status_code=_response.status_code, body=_response_json)
423
+
424
+ def fetch_evaluation_results(
425
+ self,
426
+ evaluation_id: str,
427
+ *,
428
+ request_options: typing.Optional[RequestOptions] = None,
429
+ ) -> typing.Optional[typing.Any]:
430
+ """
431
+ Fetches the results of the evaluation
432
+
433
+ Args:
434
+ evaluation_id (str): the evaluation id
435
+ request (Request): the request object
436
+
437
+ Returns:
438
+ _type_: _description_
439
+
440
+ Parameters
441
+ ----------
442
+ evaluation_id : str
443
+
444
+ request_options : typing.Optional[RequestOptions]
445
+ Request-specific configuration.
446
+
447
+ Returns
448
+ -------
449
+ typing.Optional[typing.Any]
450
+ Successful Response
451
+
452
+ Examples
453
+ --------
454
+ from agenta import AgentaApi
455
+
456
+ client = AgentaApi(
457
+ api_key="YOUR_API_KEY",
458
+ base_url="https://yourhost.com/path/to/api",
459
+ )
460
+ client.evaluations.fetch_evaluation_results(
461
+ evaluation_id="evaluation_id",
462
+ )
463
+ """
464
+ _response = self._client_wrapper.httpx_client.request(
465
+ f"evaluations/{jsonable_encoder(evaluation_id)}/results",
466
+ method="GET",
467
+ request_options=request_options,
468
+ )
469
+ try:
470
+ if 200 <= _response.status_code < 300:
471
+ return typing.cast(
472
+ typing.Optional[typing.Any],
473
+ parse_obj_as(
474
+ type_=typing.Optional[typing.Any], # type: ignore
475
+ object_=_response.json(),
476
+ ),
477
+ )
478
+ if _response.status_code == 422:
479
+ raise UnprocessableEntityError(
480
+ typing.cast(
481
+ HttpValidationError,
482
+ parse_obj_as(
483
+ type_=HttpValidationError, # type: ignore
484
+ object_=_response.json(),
485
+ ),
486
+ )
487
+ )
488
+ _response_json = _response.json()
489
+ except JSONDecodeError:
490
+ raise ApiError(status_code=_response.status_code, body=_response.text)
491
+ raise ApiError(status_code=_response.status_code, body=_response_json)
492
+
493
+ def fetch_evaluation_scenarios(
494
+ self,
495
+ evaluation_id: str,
496
+ *,
497
+ request_options: typing.Optional[RequestOptions] = None,
498
+ ) -> typing.List[EvaluationScenario]:
499
+ """
500
+ Fetches evaluation scenarios for a given evaluation ID.
501
+
502
+ Arguments:
503
+ evaluation_id (str): The ID of the evaluation for which to fetch scenarios.
504
+
505
+ Raises:
506
+ HTTPException: If the evaluation is not found or access is denied.
507
+
508
+ Returns:
509
+ List[EvaluationScenario]: A list of evaluation scenarios.
510
+
511
+ Parameters
512
+ ----------
513
+ evaluation_id : str
514
+
515
+ request_options : typing.Optional[RequestOptions]
516
+ Request-specific configuration.
517
+
518
+ Returns
519
+ -------
520
+ typing.List[EvaluationScenario]
521
+ Successful Response
522
+
523
+ Examples
524
+ --------
525
+ from agenta import AgentaApi
526
+
527
+ client = AgentaApi(
528
+ api_key="YOUR_API_KEY",
529
+ base_url="https://yourhost.com/path/to/api",
530
+ )
531
+ client.evaluations.fetch_evaluation_scenarios(
532
+ evaluation_id="evaluation_id",
533
+ )
534
+ """
535
+ _response = self._client_wrapper.httpx_client.request(
536
+ f"evaluations/{jsonable_encoder(evaluation_id)}/evaluation_scenarios",
537
+ method="GET",
538
+ request_options=request_options,
539
+ )
540
+ try:
541
+ if 200 <= _response.status_code < 300:
542
+ return typing.cast(
543
+ typing.List[EvaluationScenario],
544
+ parse_obj_as(
545
+ type_=typing.List[EvaluationScenario], # type: ignore
546
+ object_=_response.json(),
547
+ ),
548
+ )
549
+ if _response.status_code == 422:
550
+ raise UnprocessableEntityError(
551
+ typing.cast(
552
+ HttpValidationError,
553
+ parse_obj_as(
554
+ type_=HttpValidationError, # type: ignore
555
+ object_=_response.json(),
556
+ ),
557
+ )
558
+ )
559
+ _response_json = _response.json()
560
+ except JSONDecodeError:
561
+ raise ApiError(status_code=_response.status_code, body=_response.text)
562
+ raise ApiError(status_code=_response.status_code, body=_response_json)
563
+
564
+ def fetch_evaluation(
565
+ self,
566
+ evaluation_id: str,
567
+ *,
568
+ request_options: typing.Optional[RequestOptions] = None,
569
+ ) -> Evaluation:
570
+ """
571
+ Fetches a single evaluation based on its ID.
572
+
573
+ Args:
574
+ evaluation_id (str): The ID of the evaluation to fetch.
575
+
576
+ Returns:
577
+ Evaluation: The fetched evaluation.
578
+
579
+ Parameters
580
+ ----------
581
+ evaluation_id : str
582
+
583
+ request_options : typing.Optional[RequestOptions]
584
+ Request-specific configuration.
585
+
586
+ Returns
587
+ -------
588
+ Evaluation
589
+ Successful Response
590
+
591
+ Examples
592
+ --------
593
+ from agenta import AgentaApi
594
+
595
+ client = AgentaApi(
596
+ api_key="YOUR_API_KEY",
597
+ base_url="https://yourhost.com/path/to/api",
598
+ )
599
+ client.evaluations.fetch_evaluation(
600
+ evaluation_id="evaluation_id",
601
+ )
602
+ """
603
+ _response = self._client_wrapper.httpx_client.request(
604
+ f"evaluations/{jsonable_encoder(evaluation_id)}",
605
+ method="GET",
606
+ request_options=request_options,
607
+ )
608
+ try:
609
+ if 200 <= _response.status_code < 300:
610
+ return typing.cast(
611
+ Evaluation,
612
+ parse_obj_as(
613
+ type_=Evaluation, # type: ignore
614
+ object_=_response.json(),
615
+ ),
616
+ )
617
+ if _response.status_code == 422:
618
+ raise UnprocessableEntityError(
619
+ typing.cast(
620
+ HttpValidationError,
621
+ parse_obj_as(
622
+ type_=HttpValidationError, # type: ignore
623
+ object_=_response.json(),
624
+ ),
625
+ )
626
+ )
627
+ _response_json = _response.json()
628
+ except JSONDecodeError:
629
+ raise ApiError(status_code=_response.status_code, body=_response.text)
630
+ raise ApiError(status_code=_response.status_code, body=_response_json)
631
+
632
+ def fetch_evaluation_scenarios(
633
+ self,
634
+ *,
635
+ evaluations_ids: str,
636
+ request_options: typing.Optional[RequestOptions] = None,
637
+ ) -> typing.Optional[typing.Any]:
638
+ """
639
+ Fetches evaluation scenarios for a given evaluation ID.
640
+
641
+ Arguments:
642
+ evaluation_id (str): The ID of the evaluation for which to fetch scenarios.
643
+
644
+ Raises:
645
+ HTTPException: If the evaluation is not found or access is denied.
646
+
647
+ Returns:
648
+ List[EvaluationScenario]: A list of evaluation scenarios.
649
+
650
+ Parameters
651
+ ----------
652
+ evaluations_ids : str
653
+
654
+ request_options : typing.Optional[RequestOptions]
655
+ Request-specific configuration.
656
+
657
+ Returns
658
+ -------
659
+ typing.Optional[typing.Any]
660
+ Successful Response
661
+
662
+ Examples
663
+ --------
664
+ from agenta import AgentaApi
665
+
666
+ client = AgentaApi(
667
+ api_key="YOUR_API_KEY",
668
+ base_url="https://yourhost.com/path/to/api",
669
+ )
670
+ client.evaluations.fetch_evaluation_scenarios(
671
+ evaluations_ids="evaluations_ids",
672
+ )
673
+ """
674
+ _response = self._client_wrapper.httpx_client.request(
675
+ "evaluations/evaluation_scenarios/comparison-results",
676
+ method="GET",
677
+ params={
678
+ "evaluations_ids": evaluations_ids,
679
+ },
680
+ request_options=request_options,
681
+ )
682
+ try:
683
+ if 200 <= _response.status_code < 300:
684
+ return typing.cast(
685
+ typing.Optional[typing.Any],
686
+ parse_obj_as(
687
+ type_=typing.Optional[typing.Any], # type: ignore
688
+ object_=_response.json(),
689
+ ),
690
+ )
691
+ if _response.status_code == 422:
692
+ raise UnprocessableEntityError(
693
+ typing.cast(
694
+ HttpValidationError,
695
+ parse_obj_as(
696
+ type_=HttpValidationError, # type: ignore
697
+ object_=_response.json(),
698
+ ),
699
+ )
700
+ )
701
+ _response_json = _response.json()
702
+ except JSONDecodeError:
703
+ raise ApiError(status_code=_response.status_code, body=_response.text)
704
+ raise ApiError(status_code=_response.status_code, body=_response_json)
705
+
706
+
707
+ class AsyncEvaluationsClient:
708
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
709
+ self._client_wrapper = client_wrapper
710
+
711
+ async def fetch_evaluation_ids(
712
+ self,
713
+ *,
714
+ app_id: str,
715
+ resource_type: str,
716
+ resource_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
717
+ request_options: typing.Optional[RequestOptions] = None,
718
+ ) -> typing.List[str]:
719
+ """
720
+ Fetches evaluation ids for a given resource type and id.
721
+
722
+ Arguments:
723
+ app_id (str): The ID of the app for which to fetch evaluations.
724
+ resource_type (str): The type of resource for which to fetch evaluations.
725
+ resource_ids List[ObjectId]: The IDs of resource for which to fetch evaluations.
726
+
727
+ Raises:
728
+ HTTPException: If the resource_type is invalid or access is denied.
729
+
730
+ Returns:
731
+ List[str]: A list of evaluation ids.
732
+
733
+ Parameters
734
+ ----------
735
+ app_id : str
736
+
737
+ resource_type : str
738
+
739
+ resource_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
740
+
741
+ request_options : typing.Optional[RequestOptions]
742
+ Request-specific configuration.
743
+
744
+ Returns
745
+ -------
746
+ typing.List[str]
747
+ Successful Response
748
+
749
+ Examples
750
+ --------
751
+ import asyncio
752
+
753
+ from agenta import AsyncAgentaApi
754
+
755
+ client = AsyncAgentaApi(
756
+ api_key="YOUR_API_KEY",
757
+ base_url="https://yourhost.com/path/to/api",
758
+ )
759
+
760
+
761
+ async def main() -> None:
762
+ await client.evaluations.fetch_evaluation_ids(
763
+ app_id="app_id",
764
+ resource_type="resource_type",
765
+ )
766
+
767
+
768
+ asyncio.run(main())
769
+ """
770
+ _response = await self._client_wrapper.httpx_client.request(
771
+ "evaluations/by_resource",
772
+ method="GET",
773
+ params={
774
+ "app_id": app_id,
775
+ "resource_type": resource_type,
776
+ "resource_ids": resource_ids,
777
+ },
778
+ request_options=request_options,
779
+ )
780
+ try:
781
+ if 200 <= _response.status_code < 300:
782
+ return typing.cast(
783
+ typing.List[str],
784
+ parse_obj_as(
785
+ type_=typing.List[str], # type: ignore
786
+ object_=_response.json(),
787
+ ),
788
+ )
789
+ if _response.status_code == 422:
790
+ raise UnprocessableEntityError(
791
+ typing.cast(
792
+ HttpValidationError,
793
+ parse_obj_as(
794
+ type_=HttpValidationError, # type: ignore
795
+ object_=_response.json(),
796
+ ),
797
+ )
798
+ )
799
+ _response_json = _response.json()
800
+ except JSONDecodeError:
801
+ raise ApiError(status_code=_response.status_code, body=_response.text)
802
+ raise ApiError(status_code=_response.status_code, body=_response_json)
803
+
804
+ async def fetch_list_evaluations(
805
+ self, *, app_id: str, request_options: typing.Optional[RequestOptions] = None
806
+ ) -> typing.List[Evaluation]:
807
+ """
808
+ Fetches a list of evaluations, optionally filtered by an app ID.
809
+
810
+ Args:
811
+ app_id (Optional[str]): An optional app ID to filter the evaluations.
812
+
813
+ Returns:
814
+ List[Evaluation]: A list of evaluations.
815
+
816
+ Parameters
817
+ ----------
818
+ app_id : str
819
+
820
+ request_options : typing.Optional[RequestOptions]
821
+ Request-specific configuration.
822
+
823
+ Returns
824
+ -------
825
+ typing.List[Evaluation]
826
+ Successful Response
827
+
828
+ Examples
829
+ --------
830
+ import asyncio
831
+
832
+ from agenta import AsyncAgentaApi
833
+
834
+ client = AsyncAgentaApi(
835
+ api_key="YOUR_API_KEY",
836
+ base_url="https://yourhost.com/path/to/api",
837
+ )
838
+
839
+
840
+ async def main() -> None:
841
+ await client.evaluations.fetch_list_evaluations(
842
+ app_id="app_id",
843
+ )
844
+
845
+
846
+ asyncio.run(main())
847
+ """
848
+ _response = await self._client_wrapper.httpx_client.request(
849
+ "evaluations",
850
+ method="GET",
851
+ params={
852
+ "app_id": app_id,
853
+ },
854
+ request_options=request_options,
855
+ )
856
+ try:
857
+ if 200 <= _response.status_code < 300:
858
+ return typing.cast(
859
+ typing.List[Evaluation],
860
+ parse_obj_as(
861
+ type_=typing.List[Evaluation], # type: ignore
862
+ object_=_response.json(),
863
+ ),
864
+ )
865
+ if _response.status_code == 422:
866
+ raise UnprocessableEntityError(
867
+ typing.cast(
868
+ HttpValidationError,
869
+ parse_obj_as(
870
+ type_=HttpValidationError, # type: ignore
871
+ object_=_response.json(),
872
+ ),
873
+ )
874
+ )
875
+ _response_json = _response.json()
876
+ except JSONDecodeError:
877
+ raise ApiError(status_code=_response.status_code, body=_response.text)
878
+ raise ApiError(status_code=_response.status_code, body=_response_json)
879
+
880
+ async def create_evaluation(
881
+ self,
882
+ *,
883
+ app_id: str,
884
+ variant_ids: typing.Sequence[str],
885
+ evaluators_configs: typing.Sequence[str],
886
+ testset_id: str,
887
+ rate_limit: LlmRunRateLimit,
888
+ lm_providers_keys: typing.Optional[
889
+ typing.Dict[str, typing.Optional[str]]
890
+ ] = OMIT,
891
+ correct_answer_column: typing.Optional[str] = OMIT,
892
+ request_options: typing.Optional[RequestOptions] = None,
893
+ ) -> typing.List[Evaluation]:
894
+ """
895
+ Creates a new comparison table document
896
+ Raises:
897
+ HTTPException: _description_
898
+ Returns:
899
+ _description_
900
+
901
+ Parameters
902
+ ----------
903
+ app_id : str
904
+
905
+ variant_ids : typing.Sequence[str]
906
+
907
+ evaluators_configs : typing.Sequence[str]
908
+
909
+ testset_id : str
910
+
911
+ rate_limit : LlmRunRateLimit
912
+
913
+ lm_providers_keys : typing.Optional[typing.Dict[str, typing.Optional[str]]]
914
+
915
+ correct_answer_column : typing.Optional[str]
916
+
917
+ request_options : typing.Optional[RequestOptions]
918
+ Request-specific configuration.
919
+
920
+ Returns
921
+ -------
922
+ typing.List[Evaluation]
923
+ Successful Response
924
+
925
+ Examples
926
+ --------
927
+ import asyncio
928
+
929
+ from agenta import AsyncAgentaApi, LlmRunRateLimit
930
+
931
+ client = AsyncAgentaApi(
932
+ api_key="YOUR_API_KEY",
933
+ base_url="https://yourhost.com/path/to/api",
934
+ )
935
+
936
+
937
+ async def main() -> None:
938
+ await client.evaluations.create_evaluation(
939
+ app_id="app_id",
940
+ variant_ids=["variant_ids"],
941
+ evaluators_configs=["evaluators_configs"],
942
+ testset_id="testset_id",
943
+ rate_limit=LlmRunRateLimit(
944
+ batch_size=1,
945
+ max_retries=1,
946
+ retry_delay=1,
947
+ delay_between_batches=1,
948
+ ),
949
+ )
950
+
951
+
952
+ asyncio.run(main())
953
+ """
954
+ _response = await self._client_wrapper.httpx_client.request(
955
+ "evaluations",
956
+ method="POST",
957
+ json={
958
+ "app_id": app_id,
959
+ "variant_ids": variant_ids,
960
+ "evaluators_configs": evaluators_configs,
961
+ "testset_id": testset_id,
962
+ "rate_limit": rate_limit,
963
+ "lm_providers_keys": lm_providers_keys,
964
+ "correct_answer_column": correct_answer_column,
965
+ },
966
+ request_options=request_options,
967
+ omit=OMIT,
968
+ )
969
+ try:
970
+ if 200 <= _response.status_code < 300:
971
+ return typing.cast(
972
+ typing.List[Evaluation],
973
+ parse_obj_as(
974
+ type_=typing.List[Evaluation], # type: ignore
975
+ object_=_response.json(),
976
+ ),
977
+ )
978
+ if _response.status_code == 422:
979
+ raise UnprocessableEntityError(
980
+ typing.cast(
981
+ HttpValidationError,
982
+ parse_obj_as(
983
+ type_=HttpValidationError, # type: ignore
984
+ object_=_response.json(),
985
+ ),
986
+ )
987
+ )
988
+ _response_json = _response.json()
989
+ except JSONDecodeError:
990
+ raise ApiError(status_code=_response.status_code, body=_response.text)
991
+ raise ApiError(status_code=_response.status_code, body=_response_json)
992
+
993
+ async def delete_evaluations(
994
+ self,
995
+ *,
996
+ evaluations_ids: typing.Sequence[str],
997
+ request_options: typing.Optional[RequestOptions] = None,
998
+ ) -> typing.List[str]:
999
+ """
1000
+ Delete specific comparison tables based on their unique IDs.
1001
+
1002
+ Args:
1003
+ delete_evaluations (List[str]): The unique identifiers of the comparison tables to delete.
1004
+
1005
+ Returns:
1006
+ A list of the deleted comparison tables' IDs.
1007
+
1008
+ Parameters
1009
+ ----------
1010
+ evaluations_ids : typing.Sequence[str]
1011
+
1012
+ request_options : typing.Optional[RequestOptions]
1013
+ Request-specific configuration.
1014
+
1015
+ Returns
1016
+ -------
1017
+ typing.List[str]
1018
+ Successful Response
1019
+
1020
+ Examples
1021
+ --------
1022
+ import asyncio
1023
+
1024
+ from agenta import AsyncAgentaApi
1025
+
1026
+ client = AsyncAgentaApi(
1027
+ api_key="YOUR_API_KEY",
1028
+ base_url="https://yourhost.com/path/to/api",
1029
+ )
1030
+
1031
+
1032
+ async def main() -> None:
1033
+ await client.evaluations.delete_evaluations(
1034
+ evaluations_ids=["evaluations_ids"],
1035
+ )
1036
+
1037
+
1038
+ asyncio.run(main())
1039
+ """
1040
+ _response = await self._client_wrapper.httpx_client.request(
1041
+ "evaluations",
1042
+ method="DELETE",
1043
+ json={
1044
+ "evaluations_ids": evaluations_ids,
1045
+ },
1046
+ request_options=request_options,
1047
+ omit=OMIT,
1048
+ )
1049
+ try:
1050
+ if 200 <= _response.status_code < 300:
1051
+ return typing.cast(
1052
+ typing.List[str],
1053
+ parse_obj_as(
1054
+ type_=typing.List[str], # type: ignore
1055
+ object_=_response.json(),
1056
+ ),
1057
+ )
1058
+ if _response.status_code == 422:
1059
+ raise UnprocessableEntityError(
1060
+ typing.cast(
1061
+ HttpValidationError,
1062
+ parse_obj_as(
1063
+ type_=HttpValidationError, # type: ignore
1064
+ object_=_response.json(),
1065
+ ),
1066
+ )
1067
+ )
1068
+ _response_json = _response.json()
1069
+ except JSONDecodeError:
1070
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1071
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1072
+
1073
+ async def fetch_evaluation_status(
1074
+ self,
1075
+ evaluation_id: str,
1076
+ *,
1077
+ request_options: typing.Optional[RequestOptions] = None,
1078
+ ) -> typing.Optional[typing.Any]:
1079
+ """
1080
+ Fetches the status of the evaluation.
1081
+
1082
+ Args:
1083
+ evaluation_id (str): the evaluation id
1084
+ request (Request): the request object
1085
+
1086
+ Returns:
1087
+ (str): the evaluation status
1088
+
1089
+ Parameters
1090
+ ----------
1091
+ evaluation_id : str
1092
+
1093
+ request_options : typing.Optional[RequestOptions]
1094
+ Request-specific configuration.
1095
+
1096
+ Returns
1097
+ -------
1098
+ typing.Optional[typing.Any]
1099
+ Successful Response
1100
+
1101
+ Examples
1102
+ --------
1103
+ import asyncio
1104
+
1105
+ from agenta import AsyncAgentaApi
1106
+
1107
+ client = AsyncAgentaApi(
1108
+ api_key="YOUR_API_KEY",
1109
+ base_url="https://yourhost.com/path/to/api",
1110
+ )
1111
+
1112
+
1113
+ async def main() -> None:
1114
+ await client.evaluations.fetch_evaluation_status(
1115
+ evaluation_id="evaluation_id",
1116
+ )
1117
+
1118
+
1119
+ asyncio.run(main())
1120
+ """
1121
+ _response = await self._client_wrapper.httpx_client.request(
1122
+ f"evaluations/{jsonable_encoder(evaluation_id)}/status",
1123
+ method="GET",
1124
+ request_options=request_options,
1125
+ )
1126
+ try:
1127
+ if 200 <= _response.status_code < 300:
1128
+ return typing.cast(
1129
+ typing.Optional[typing.Any],
1130
+ parse_obj_as(
1131
+ type_=typing.Optional[typing.Any], # type: ignore
1132
+ object_=_response.json(),
1133
+ ),
1134
+ )
1135
+ if _response.status_code == 422:
1136
+ raise UnprocessableEntityError(
1137
+ typing.cast(
1138
+ HttpValidationError,
1139
+ parse_obj_as(
1140
+ type_=HttpValidationError, # type: ignore
1141
+ object_=_response.json(),
1142
+ ),
1143
+ )
1144
+ )
1145
+ _response_json = _response.json()
1146
+ except JSONDecodeError:
1147
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1148
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1149
+
1150
+ async def fetch_evaluation_results(
1151
+ self,
1152
+ evaluation_id: str,
1153
+ *,
1154
+ request_options: typing.Optional[RequestOptions] = None,
1155
+ ) -> typing.Optional[typing.Any]:
1156
+ """
1157
+ Fetches the results of the evaluation
1158
+
1159
+ Args:
1160
+ evaluation_id (str): the evaluation id
1161
+ request (Request): the request object
1162
+
1163
+ Returns:
1164
+ _type_: _description_
1165
+
1166
+ Parameters
1167
+ ----------
1168
+ evaluation_id : str
1169
+
1170
+ request_options : typing.Optional[RequestOptions]
1171
+ Request-specific configuration.
1172
+
1173
+ Returns
1174
+ -------
1175
+ typing.Optional[typing.Any]
1176
+ Successful Response
1177
+
1178
+ Examples
1179
+ --------
1180
+ import asyncio
1181
+
1182
+ from agenta import AsyncAgentaApi
1183
+
1184
+ client = AsyncAgentaApi(
1185
+ api_key="YOUR_API_KEY",
1186
+ base_url="https://yourhost.com/path/to/api",
1187
+ )
1188
+
1189
+
1190
+ async def main() -> None:
1191
+ await client.evaluations.fetch_evaluation_results(
1192
+ evaluation_id="evaluation_id",
1193
+ )
1194
+
1195
+
1196
+ asyncio.run(main())
1197
+ """
1198
+ _response = await self._client_wrapper.httpx_client.request(
1199
+ f"evaluations/{jsonable_encoder(evaluation_id)}/results",
1200
+ method="GET",
1201
+ request_options=request_options,
1202
+ )
1203
+ try:
1204
+ if 200 <= _response.status_code < 300:
1205
+ return typing.cast(
1206
+ typing.Optional[typing.Any],
1207
+ parse_obj_as(
1208
+ type_=typing.Optional[typing.Any], # type: ignore
1209
+ object_=_response.json(),
1210
+ ),
1211
+ )
1212
+ if _response.status_code == 422:
1213
+ raise UnprocessableEntityError(
1214
+ typing.cast(
1215
+ HttpValidationError,
1216
+ parse_obj_as(
1217
+ type_=HttpValidationError, # type: ignore
1218
+ object_=_response.json(),
1219
+ ),
1220
+ )
1221
+ )
1222
+ _response_json = _response.json()
1223
+ except JSONDecodeError:
1224
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1225
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1226
+
1227
+ async def fetch_evaluation_scenarios(
1228
+ self,
1229
+ evaluation_id: str,
1230
+ *,
1231
+ request_options: typing.Optional[RequestOptions] = None,
1232
+ ) -> typing.List[EvaluationScenario]:
1233
+ """
1234
+ Fetches evaluation scenarios for a given evaluation ID.
1235
+
1236
+ Arguments:
1237
+ evaluation_id (str): The ID of the evaluation for which to fetch scenarios.
1238
+
1239
+ Raises:
1240
+ HTTPException: If the evaluation is not found or access is denied.
1241
+
1242
+ Returns:
1243
+ List[EvaluationScenario]: A list of evaluation scenarios.
1244
+
1245
+ Parameters
1246
+ ----------
1247
+ evaluation_id : str
1248
+
1249
+ request_options : typing.Optional[RequestOptions]
1250
+ Request-specific configuration.
1251
+
1252
+ Returns
1253
+ -------
1254
+ typing.List[EvaluationScenario]
1255
+ Successful Response
1256
+
1257
+ Examples
1258
+ --------
1259
+ import asyncio
1260
+
1261
+ from agenta import AsyncAgentaApi
1262
+
1263
+ client = AsyncAgentaApi(
1264
+ api_key="YOUR_API_KEY",
1265
+ base_url="https://yourhost.com/path/to/api",
1266
+ )
1267
+
1268
+
1269
+ async def main() -> None:
1270
+ await client.evaluations.fetch_evaluation_scenarios(
1271
+ evaluation_id="evaluation_id",
1272
+ )
1273
+
1274
+
1275
+ asyncio.run(main())
1276
+ """
1277
+ _response = await self._client_wrapper.httpx_client.request(
1278
+ f"evaluations/{jsonable_encoder(evaluation_id)}/evaluation_scenarios",
1279
+ method="GET",
1280
+ request_options=request_options,
1281
+ )
1282
+ try:
1283
+ if 200 <= _response.status_code < 300:
1284
+ return typing.cast(
1285
+ typing.List[EvaluationScenario],
1286
+ parse_obj_as(
1287
+ type_=typing.List[EvaluationScenario], # type: ignore
1288
+ object_=_response.json(),
1289
+ ),
1290
+ )
1291
+ if _response.status_code == 422:
1292
+ raise UnprocessableEntityError(
1293
+ typing.cast(
1294
+ HttpValidationError,
1295
+ parse_obj_as(
1296
+ type_=HttpValidationError, # type: ignore
1297
+ object_=_response.json(),
1298
+ ),
1299
+ )
1300
+ )
1301
+ _response_json = _response.json()
1302
+ except JSONDecodeError:
1303
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1304
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1305
+
1306
+ async def fetch_evaluation(
1307
+ self,
1308
+ evaluation_id: str,
1309
+ *,
1310
+ request_options: typing.Optional[RequestOptions] = None,
1311
+ ) -> Evaluation:
1312
+ """
1313
+ Fetches a single evaluation based on its ID.
1314
+
1315
+ Args:
1316
+ evaluation_id (str): The ID of the evaluation to fetch.
1317
+
1318
+ Returns:
1319
+ Evaluation: The fetched evaluation.
1320
+
1321
+ Parameters
1322
+ ----------
1323
+ evaluation_id : str
1324
+
1325
+ request_options : typing.Optional[RequestOptions]
1326
+ Request-specific configuration.
1327
+
1328
+ Returns
1329
+ -------
1330
+ Evaluation
1331
+ Successful Response
1332
+
1333
+ Examples
1334
+ --------
1335
+ import asyncio
1336
+
1337
+ from agenta import AsyncAgentaApi
1338
+
1339
+ client = AsyncAgentaApi(
1340
+ api_key="YOUR_API_KEY",
1341
+ base_url="https://yourhost.com/path/to/api",
1342
+ )
1343
+
1344
+
1345
+ async def main() -> None:
1346
+ await client.evaluations.fetch_evaluation(
1347
+ evaluation_id="evaluation_id",
1348
+ )
1349
+
1350
+
1351
+ asyncio.run(main())
1352
+ """
1353
+ _response = await self._client_wrapper.httpx_client.request(
1354
+ f"evaluations/{jsonable_encoder(evaluation_id)}",
1355
+ method="GET",
1356
+ request_options=request_options,
1357
+ )
1358
+ try:
1359
+ if 200 <= _response.status_code < 300:
1360
+ return typing.cast(
1361
+ Evaluation,
1362
+ parse_obj_as(
1363
+ type_=Evaluation, # type: ignore
1364
+ object_=_response.json(),
1365
+ ),
1366
+ )
1367
+ if _response.status_code == 422:
1368
+ raise UnprocessableEntityError(
1369
+ typing.cast(
1370
+ HttpValidationError,
1371
+ parse_obj_as(
1372
+ type_=HttpValidationError, # type: ignore
1373
+ object_=_response.json(),
1374
+ ),
1375
+ )
1376
+ )
1377
+ _response_json = _response.json()
1378
+ except JSONDecodeError:
1379
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1380
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1381
+
1382
+ async def fetch_evaluation_scenarios(
1383
+ self,
1384
+ *,
1385
+ evaluations_ids: str,
1386
+ request_options: typing.Optional[RequestOptions] = None,
1387
+ ) -> typing.Optional[typing.Any]:
1388
+ """
1389
+ Fetches evaluation scenarios for a given evaluation ID.
1390
+
1391
+ Arguments:
1392
+ evaluation_id (str): The ID of the evaluation for which to fetch scenarios.
1393
+
1394
+ Raises:
1395
+ HTTPException: If the evaluation is not found or access is denied.
1396
+
1397
+ Returns:
1398
+ List[EvaluationScenario]: A list of evaluation scenarios.
1399
+
1400
+ Parameters
1401
+ ----------
1402
+ evaluations_ids : str
1403
+
1404
+ request_options : typing.Optional[RequestOptions]
1405
+ Request-specific configuration.
1406
+
1407
+ Returns
1408
+ -------
1409
+ typing.Optional[typing.Any]
1410
+ Successful Response
1411
+
1412
+ Examples
1413
+ --------
1414
+ import asyncio
1415
+
1416
+ from agenta import AsyncAgentaApi
1417
+
1418
+ client = AsyncAgentaApi(
1419
+ api_key="YOUR_API_KEY",
1420
+ base_url="https://yourhost.com/path/to/api",
1421
+ )
1422
+
1423
+
1424
+ async def main() -> None:
1425
+ await client.evaluations.fetch_evaluation_scenarios(
1426
+ evaluations_ids="evaluations_ids",
1427
+ )
1428
+
1429
+
1430
+ asyncio.run(main())
1431
+ """
1432
+ _response = await self._client_wrapper.httpx_client.request(
1433
+ "evaluations/evaluation_scenarios/comparison-results",
1434
+ method="GET",
1435
+ params={
1436
+ "evaluations_ids": evaluations_ids,
1437
+ },
1438
+ request_options=request_options,
1439
+ )
1440
+ try:
1441
+ if 200 <= _response.status_code < 300:
1442
+ return typing.cast(
1443
+ typing.Optional[typing.Any],
1444
+ parse_obj_as(
1445
+ type_=typing.Optional[typing.Any], # type: ignore
1446
+ object_=_response.json(),
1447
+ ),
1448
+ )
1449
+ if _response.status_code == 422:
1450
+ raise UnprocessableEntityError(
1451
+ typing.cast(
1452
+ HttpValidationError,
1453
+ parse_obj_as(
1454
+ type_=HttpValidationError, # type: ignore
1455
+ object_=_response.json(),
1456
+ ),
1457
+ )
1458
+ )
1459
+ _response_json = _response.json()
1460
+ except JSONDecodeError:
1461
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1462
+ raise ApiError(status_code=_response.status_code, body=_response_json)