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