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,1283 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from ..core.client_wrapper import SyncClientWrapper
5
+ from ..core.request_options import RequestOptions
6
+ from ..types.evaluator import Evaluator
7
+ from ..core.pydantic_utilities import parse_obj_as
8
+ from json.decoder import JSONDecodeError
9
+ from ..core.api_error import ApiError
10
+ from ..types.evaluator_mapping_output_interface import EvaluatorMappingOutputInterface
11
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
12
+ from ..types.http_validation_error import HttpValidationError
13
+ from ..types.evaluator_output_interface import EvaluatorOutputInterface
14
+ from ..core.jsonable_encoder import jsonable_encoder
15
+ from ..types.evaluator_config import EvaluatorConfig
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 EvaluatorsClient:
23
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
24
+ self._client_wrapper = client_wrapper
25
+
26
+ def get_evaluators_endpoint(
27
+ self, *, request_options: typing.Optional[RequestOptions] = None
28
+ ) -> typing.List[Evaluator]:
29
+ """
30
+ Endpoint to fetch a list of evaluators.
31
+
32
+ Returns:
33
+ List[Evaluator]: A list of evaluator objects.
34
+
35
+ Parameters
36
+ ----------
37
+ request_options : typing.Optional[RequestOptions]
38
+ Request-specific configuration.
39
+
40
+ Returns
41
+ -------
42
+ typing.List[Evaluator]
43
+ Successful Response
44
+
45
+ Examples
46
+ --------
47
+ from agenta import AgentaApi
48
+
49
+ client = AgentaApi(
50
+ api_key="YOUR_API_KEY",
51
+ base_url="https://yourhost.com/path/to/api",
52
+ )
53
+ client.evaluators.get_evaluators_endpoint()
54
+ """
55
+ _response = self._client_wrapper.httpx_client.request(
56
+ "evaluators",
57
+ method="GET",
58
+ request_options=request_options,
59
+ )
60
+ try:
61
+ if 200 <= _response.status_code < 300:
62
+ return typing.cast(
63
+ typing.List[Evaluator],
64
+ parse_obj_as(
65
+ type_=typing.List[Evaluator], # type: ignore
66
+ object_=_response.json(),
67
+ ),
68
+ )
69
+ _response_json = _response.json()
70
+ except JSONDecodeError:
71
+ raise ApiError(status_code=_response.status_code, body=_response.text)
72
+ raise ApiError(status_code=_response.status_code, body=_response_json)
73
+
74
+ def evaluator_data_map(
75
+ self,
76
+ *,
77
+ inputs: typing.Dict[str, typing.Optional[typing.Any]],
78
+ mapping: typing.Dict[str, typing.Optional[typing.Any]],
79
+ request_options: typing.Optional[RequestOptions] = None,
80
+ ) -> EvaluatorMappingOutputInterface:
81
+ """
82
+ Endpoint to map the experiment data tree to evaluator interface.
83
+
84
+ Args:
85
+ request (Request): The request object.
86
+ payload (EvaluatorMappingInputInterface): The payload containing the request data.
87
+
88
+ Returns:
89
+ EvaluatorMappingOutputInterface: the evaluator mapping output object
90
+
91
+ Parameters
92
+ ----------
93
+ inputs : typing.Dict[str, typing.Optional[typing.Any]]
94
+
95
+ mapping : typing.Dict[str, typing.Optional[typing.Any]]
96
+
97
+ request_options : typing.Optional[RequestOptions]
98
+ Request-specific configuration.
99
+
100
+ Returns
101
+ -------
102
+ EvaluatorMappingOutputInterface
103
+ Successful Response
104
+
105
+ Examples
106
+ --------
107
+ from agenta import AgentaApi
108
+
109
+ client = AgentaApi(
110
+ api_key="YOUR_API_KEY",
111
+ base_url="https://yourhost.com/path/to/api",
112
+ )
113
+ client.evaluators.evaluator_data_map(
114
+ inputs={"key": "value"},
115
+ mapping={"key": "value"},
116
+ )
117
+ """
118
+ _response = self._client_wrapper.httpx_client.request(
119
+ "evaluators/map",
120
+ method="POST",
121
+ json={
122
+ "inputs": inputs,
123
+ "mapping": mapping,
124
+ },
125
+ headers={
126
+ "content-type": "application/json",
127
+ },
128
+ request_options=request_options,
129
+ omit=OMIT,
130
+ )
131
+ try:
132
+ if 200 <= _response.status_code < 300:
133
+ return typing.cast(
134
+ EvaluatorMappingOutputInterface,
135
+ parse_obj_as(
136
+ type_=EvaluatorMappingOutputInterface, # type: ignore
137
+ object_=_response.json(),
138
+ ),
139
+ )
140
+ if _response.status_code == 422:
141
+ raise UnprocessableEntityError(
142
+ typing.cast(
143
+ HttpValidationError,
144
+ parse_obj_as(
145
+ type_=HttpValidationError, # type: ignore
146
+ object_=_response.json(),
147
+ ),
148
+ )
149
+ )
150
+ _response_json = _response.json()
151
+ except JSONDecodeError:
152
+ raise ApiError(status_code=_response.status_code, body=_response.text)
153
+ raise ApiError(status_code=_response.status_code, body=_response_json)
154
+
155
+ def evaluator_run(
156
+ self,
157
+ evaluator_key: str,
158
+ *,
159
+ inputs: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
160
+ settings: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
161
+ credentials: typing.Optional[
162
+ typing.Dict[str, typing.Optional[typing.Any]]
163
+ ] = OMIT,
164
+ request_options: typing.Optional[RequestOptions] = None,
165
+ ) -> EvaluatorOutputInterface:
166
+ """
167
+ Endpoint to evaluate LLM app run
168
+
169
+ Args:
170
+ request (Request): The request object.
171
+ evaluator_key (str): The key of the evaluator.
172
+ payload (EvaluatorInputInterface): The payload containing the request data.
173
+
174
+ Returns:
175
+ result: EvaluatorOutputInterface object containing the outputs.
176
+
177
+ Parameters
178
+ ----------
179
+ evaluator_key : str
180
+
181
+ inputs : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
182
+
183
+ settings : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
184
+
185
+ credentials : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
186
+
187
+ request_options : typing.Optional[RequestOptions]
188
+ Request-specific configuration.
189
+
190
+ Returns
191
+ -------
192
+ EvaluatorOutputInterface
193
+ Successful Response
194
+
195
+ Examples
196
+ --------
197
+ from agenta import AgentaApi
198
+
199
+ client = AgentaApi(
200
+ api_key="YOUR_API_KEY",
201
+ base_url="https://yourhost.com/path/to/api",
202
+ )
203
+ client.evaluators.evaluator_run(
204
+ evaluator_key="evaluator_key",
205
+ )
206
+ """
207
+ _response = self._client_wrapper.httpx_client.request(
208
+ f"evaluators/{jsonable_encoder(evaluator_key)}/run",
209
+ method="POST",
210
+ json={
211
+ "inputs": inputs,
212
+ "settings": settings,
213
+ "credentials": credentials,
214
+ },
215
+ headers={
216
+ "content-type": "application/json",
217
+ },
218
+ request_options=request_options,
219
+ omit=OMIT,
220
+ )
221
+ try:
222
+ if 200 <= _response.status_code < 300:
223
+ return typing.cast(
224
+ EvaluatorOutputInterface,
225
+ parse_obj_as(
226
+ type_=EvaluatorOutputInterface, # type: ignore
227
+ object_=_response.json(),
228
+ ),
229
+ )
230
+ if _response.status_code == 422:
231
+ raise UnprocessableEntityError(
232
+ typing.cast(
233
+ HttpValidationError,
234
+ parse_obj_as(
235
+ type_=HttpValidationError, # type: ignore
236
+ object_=_response.json(),
237
+ ),
238
+ )
239
+ )
240
+ _response_json = _response.json()
241
+ except JSONDecodeError:
242
+ raise ApiError(status_code=_response.status_code, body=_response.text)
243
+ raise ApiError(status_code=_response.status_code, body=_response_json)
244
+
245
+ def get_evaluator_configs(
246
+ self, *, app_id: str, request_options: typing.Optional[RequestOptions] = None
247
+ ) -> typing.List[EvaluatorConfig]:
248
+ """
249
+ Endpoint to fetch evaluator configurations for a specific app.
250
+
251
+ Args:
252
+ app_id (str): The ID of the app.
253
+
254
+ Returns:
255
+ List[EvaluatorConfigDB]: A list of evaluator configuration objects.
256
+
257
+ Parameters
258
+ ----------
259
+ app_id : str
260
+
261
+ request_options : typing.Optional[RequestOptions]
262
+ Request-specific configuration.
263
+
264
+ Returns
265
+ -------
266
+ typing.List[EvaluatorConfig]
267
+ Successful Response
268
+
269
+ Examples
270
+ --------
271
+ from agenta import AgentaApi
272
+
273
+ client = AgentaApi(
274
+ api_key="YOUR_API_KEY",
275
+ base_url="https://yourhost.com/path/to/api",
276
+ )
277
+ client.evaluators.get_evaluator_configs(
278
+ app_id="app_id",
279
+ )
280
+ """
281
+ _response = self._client_wrapper.httpx_client.request(
282
+ "evaluators/configs",
283
+ method="GET",
284
+ params={
285
+ "app_id": app_id,
286
+ },
287
+ request_options=request_options,
288
+ )
289
+ try:
290
+ if 200 <= _response.status_code < 300:
291
+ return typing.cast(
292
+ typing.List[EvaluatorConfig],
293
+ parse_obj_as(
294
+ type_=typing.List[EvaluatorConfig], # type: ignore
295
+ object_=_response.json(),
296
+ ),
297
+ )
298
+ if _response.status_code == 422:
299
+ raise UnprocessableEntityError(
300
+ typing.cast(
301
+ HttpValidationError,
302
+ parse_obj_as(
303
+ type_=HttpValidationError, # type: ignore
304
+ object_=_response.json(),
305
+ ),
306
+ )
307
+ )
308
+ _response_json = _response.json()
309
+ except JSONDecodeError:
310
+ raise ApiError(status_code=_response.status_code, body=_response.text)
311
+ raise ApiError(status_code=_response.status_code, body=_response_json)
312
+
313
+ def create_new_evaluator_config(
314
+ self,
315
+ *,
316
+ app_id: str,
317
+ name: str,
318
+ evaluator_key: str,
319
+ settings_values: typing.Dict[str, typing.Optional[typing.Any]],
320
+ request_options: typing.Optional[RequestOptions] = None,
321
+ ) -> EvaluatorConfig:
322
+ """
323
+ Endpoint to fetch evaluator configurations for a specific app.
324
+
325
+ Args:
326
+ app_id (str): The ID of the app.
327
+
328
+ Returns:
329
+ EvaluatorConfigDB: Evaluator configuration api model.
330
+
331
+ Parameters
332
+ ----------
333
+ app_id : str
334
+
335
+ name : str
336
+
337
+ evaluator_key : str
338
+
339
+ settings_values : typing.Dict[str, typing.Optional[typing.Any]]
340
+
341
+ request_options : typing.Optional[RequestOptions]
342
+ Request-specific configuration.
343
+
344
+ Returns
345
+ -------
346
+ EvaluatorConfig
347
+ Successful Response
348
+
349
+ Examples
350
+ --------
351
+ from agenta import AgentaApi
352
+
353
+ client = AgentaApi(
354
+ api_key="YOUR_API_KEY",
355
+ base_url="https://yourhost.com/path/to/api",
356
+ )
357
+ client.evaluators.create_new_evaluator_config(
358
+ app_id="app_id",
359
+ name="name",
360
+ evaluator_key="evaluator_key",
361
+ settings_values={"key": "value"},
362
+ )
363
+ """
364
+ _response = self._client_wrapper.httpx_client.request(
365
+ "evaluators/configs",
366
+ method="POST",
367
+ json={
368
+ "app_id": app_id,
369
+ "name": name,
370
+ "evaluator_key": evaluator_key,
371
+ "settings_values": settings_values,
372
+ },
373
+ headers={
374
+ "content-type": "application/json",
375
+ },
376
+ request_options=request_options,
377
+ omit=OMIT,
378
+ )
379
+ try:
380
+ if 200 <= _response.status_code < 300:
381
+ return typing.cast(
382
+ EvaluatorConfig,
383
+ parse_obj_as(
384
+ type_=EvaluatorConfig, # type: ignore
385
+ object_=_response.json(),
386
+ ),
387
+ )
388
+ if _response.status_code == 422:
389
+ raise UnprocessableEntityError(
390
+ typing.cast(
391
+ HttpValidationError,
392
+ parse_obj_as(
393
+ type_=HttpValidationError, # type: ignore
394
+ object_=_response.json(),
395
+ ),
396
+ )
397
+ )
398
+ _response_json = _response.json()
399
+ except JSONDecodeError:
400
+ raise ApiError(status_code=_response.status_code, body=_response.text)
401
+ raise ApiError(status_code=_response.status_code, body=_response_json)
402
+
403
+ def get_evaluator_config(
404
+ self,
405
+ evaluator_config_id: str,
406
+ *,
407
+ request_options: typing.Optional[RequestOptions] = None,
408
+ ) -> EvaluatorConfig:
409
+ """
410
+ Endpoint to fetch evaluator configurations for a specific app.
411
+
412
+ Returns:
413
+ List[EvaluatorConfigDB]: A list of evaluator configuration objects.
414
+
415
+ Parameters
416
+ ----------
417
+ evaluator_config_id : str
418
+
419
+ request_options : typing.Optional[RequestOptions]
420
+ Request-specific configuration.
421
+
422
+ Returns
423
+ -------
424
+ EvaluatorConfig
425
+ Successful Response
426
+
427
+ Examples
428
+ --------
429
+ from agenta import AgentaApi
430
+
431
+ client = AgentaApi(
432
+ api_key="YOUR_API_KEY",
433
+ base_url="https://yourhost.com/path/to/api",
434
+ )
435
+ client.evaluators.get_evaluator_config(
436
+ evaluator_config_id="evaluator_config_id",
437
+ )
438
+ """
439
+ _response = self._client_wrapper.httpx_client.request(
440
+ f"evaluators/configs/{jsonable_encoder(evaluator_config_id)}",
441
+ method="GET",
442
+ request_options=request_options,
443
+ )
444
+ try:
445
+ if 200 <= _response.status_code < 300:
446
+ return typing.cast(
447
+ EvaluatorConfig,
448
+ parse_obj_as(
449
+ type_=EvaluatorConfig, # type: ignore
450
+ object_=_response.json(),
451
+ ),
452
+ )
453
+ if _response.status_code == 422:
454
+ raise UnprocessableEntityError(
455
+ typing.cast(
456
+ HttpValidationError,
457
+ parse_obj_as(
458
+ type_=HttpValidationError, # type: ignore
459
+ object_=_response.json(),
460
+ ),
461
+ )
462
+ )
463
+ _response_json = _response.json()
464
+ except JSONDecodeError:
465
+ raise ApiError(status_code=_response.status_code, body=_response.text)
466
+ raise ApiError(status_code=_response.status_code, body=_response_json)
467
+
468
+ def update_evaluator_config(
469
+ self,
470
+ evaluator_config_id: str,
471
+ *,
472
+ name: typing.Optional[str] = OMIT,
473
+ evaluator_key: typing.Optional[str] = OMIT,
474
+ settings_values: typing.Optional[
475
+ typing.Dict[str, typing.Optional[typing.Any]]
476
+ ] = OMIT,
477
+ request_options: typing.Optional[RequestOptions] = None,
478
+ ) -> EvaluatorConfig:
479
+ """
480
+ Endpoint to update evaluator configurations for a specific app.
481
+
482
+ Returns:
483
+ List[EvaluatorConfigDB]: A list of evaluator configuration objects.
484
+
485
+ Parameters
486
+ ----------
487
+ evaluator_config_id : str
488
+
489
+ name : typing.Optional[str]
490
+
491
+ evaluator_key : typing.Optional[str]
492
+
493
+ settings_values : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
494
+
495
+ request_options : typing.Optional[RequestOptions]
496
+ Request-specific configuration.
497
+
498
+ Returns
499
+ -------
500
+ EvaluatorConfig
501
+ Successful Response
502
+
503
+ Examples
504
+ --------
505
+ from agenta import AgentaApi
506
+
507
+ client = AgentaApi(
508
+ api_key="YOUR_API_KEY",
509
+ base_url="https://yourhost.com/path/to/api",
510
+ )
511
+ client.evaluators.update_evaluator_config(
512
+ evaluator_config_id="evaluator_config_id",
513
+ )
514
+ """
515
+ _response = self._client_wrapper.httpx_client.request(
516
+ f"evaluators/configs/{jsonable_encoder(evaluator_config_id)}",
517
+ method="PUT",
518
+ json={
519
+ "name": name,
520
+ "evaluator_key": evaluator_key,
521
+ "settings_values": settings_values,
522
+ },
523
+ headers={
524
+ "content-type": "application/json",
525
+ },
526
+ request_options=request_options,
527
+ omit=OMIT,
528
+ )
529
+ try:
530
+ if 200 <= _response.status_code < 300:
531
+ return typing.cast(
532
+ EvaluatorConfig,
533
+ parse_obj_as(
534
+ type_=EvaluatorConfig, # type: ignore
535
+ object_=_response.json(),
536
+ ),
537
+ )
538
+ if _response.status_code == 422:
539
+ raise UnprocessableEntityError(
540
+ typing.cast(
541
+ HttpValidationError,
542
+ parse_obj_as(
543
+ type_=HttpValidationError, # type: ignore
544
+ object_=_response.json(),
545
+ ),
546
+ )
547
+ )
548
+ _response_json = _response.json()
549
+ except JSONDecodeError:
550
+ raise ApiError(status_code=_response.status_code, body=_response.text)
551
+ raise ApiError(status_code=_response.status_code, body=_response_json)
552
+
553
+ def delete_evaluator_config(
554
+ self,
555
+ evaluator_config_id: str,
556
+ *,
557
+ request_options: typing.Optional[RequestOptions] = None,
558
+ ) -> bool:
559
+ """
560
+ Endpoint to delete a specific evaluator configuration.
561
+
562
+ Args:
563
+ evaluator_config_id (str): The unique identifier of the evaluator configuration.
564
+
565
+ Returns:
566
+ bool: True if deletion was successful, False otherwise.
567
+
568
+ Parameters
569
+ ----------
570
+ evaluator_config_id : str
571
+
572
+ request_options : typing.Optional[RequestOptions]
573
+ Request-specific configuration.
574
+
575
+ Returns
576
+ -------
577
+ bool
578
+ Successful Response
579
+
580
+ Examples
581
+ --------
582
+ from agenta import AgentaApi
583
+
584
+ client = AgentaApi(
585
+ api_key="YOUR_API_KEY",
586
+ base_url="https://yourhost.com/path/to/api",
587
+ )
588
+ client.evaluators.delete_evaluator_config(
589
+ evaluator_config_id="evaluator_config_id",
590
+ )
591
+ """
592
+ _response = self._client_wrapper.httpx_client.request(
593
+ f"evaluators/configs/{jsonable_encoder(evaluator_config_id)}",
594
+ method="DELETE",
595
+ request_options=request_options,
596
+ )
597
+ try:
598
+ if 200 <= _response.status_code < 300:
599
+ return typing.cast(
600
+ bool,
601
+ parse_obj_as(
602
+ type_=bool, # type: ignore
603
+ object_=_response.json(),
604
+ ),
605
+ )
606
+ if _response.status_code == 422:
607
+ raise UnprocessableEntityError(
608
+ typing.cast(
609
+ HttpValidationError,
610
+ parse_obj_as(
611
+ type_=HttpValidationError, # type: ignore
612
+ object_=_response.json(),
613
+ ),
614
+ )
615
+ )
616
+ _response_json = _response.json()
617
+ except JSONDecodeError:
618
+ raise ApiError(status_code=_response.status_code, body=_response.text)
619
+ raise ApiError(status_code=_response.status_code, body=_response_json)
620
+
621
+
622
+ class AsyncEvaluatorsClient:
623
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
624
+ self._client_wrapper = client_wrapper
625
+
626
+ async def get_evaluators_endpoint(
627
+ self, *, request_options: typing.Optional[RequestOptions] = None
628
+ ) -> typing.List[Evaluator]:
629
+ """
630
+ Endpoint to fetch a list of evaluators.
631
+
632
+ Returns:
633
+ List[Evaluator]: A list of evaluator objects.
634
+
635
+ Parameters
636
+ ----------
637
+ request_options : typing.Optional[RequestOptions]
638
+ Request-specific configuration.
639
+
640
+ Returns
641
+ -------
642
+ typing.List[Evaluator]
643
+ Successful Response
644
+
645
+ Examples
646
+ --------
647
+ import asyncio
648
+
649
+ from agenta import AsyncAgentaApi
650
+
651
+ client = AsyncAgentaApi(
652
+ api_key="YOUR_API_KEY",
653
+ base_url="https://yourhost.com/path/to/api",
654
+ )
655
+
656
+
657
+ async def main() -> None:
658
+ await client.evaluators.get_evaluators_endpoint()
659
+
660
+
661
+ asyncio.run(main())
662
+ """
663
+ _response = await self._client_wrapper.httpx_client.request(
664
+ "evaluators",
665
+ method="GET",
666
+ request_options=request_options,
667
+ )
668
+ try:
669
+ if 200 <= _response.status_code < 300:
670
+ return typing.cast(
671
+ typing.List[Evaluator],
672
+ parse_obj_as(
673
+ type_=typing.List[Evaluator], # type: ignore
674
+ object_=_response.json(),
675
+ ),
676
+ )
677
+ _response_json = _response.json()
678
+ except JSONDecodeError:
679
+ raise ApiError(status_code=_response.status_code, body=_response.text)
680
+ raise ApiError(status_code=_response.status_code, body=_response_json)
681
+
682
+ async def evaluator_data_map(
683
+ self,
684
+ *,
685
+ inputs: typing.Dict[str, typing.Optional[typing.Any]],
686
+ mapping: typing.Dict[str, typing.Optional[typing.Any]],
687
+ request_options: typing.Optional[RequestOptions] = None,
688
+ ) -> EvaluatorMappingOutputInterface:
689
+ """
690
+ Endpoint to map the experiment data tree to evaluator interface.
691
+
692
+ Args:
693
+ request (Request): The request object.
694
+ payload (EvaluatorMappingInputInterface): The payload containing the request data.
695
+
696
+ Returns:
697
+ EvaluatorMappingOutputInterface: the evaluator mapping output object
698
+
699
+ Parameters
700
+ ----------
701
+ inputs : typing.Dict[str, typing.Optional[typing.Any]]
702
+
703
+ mapping : typing.Dict[str, typing.Optional[typing.Any]]
704
+
705
+ request_options : typing.Optional[RequestOptions]
706
+ Request-specific configuration.
707
+
708
+ Returns
709
+ -------
710
+ EvaluatorMappingOutputInterface
711
+ Successful Response
712
+
713
+ Examples
714
+ --------
715
+ import asyncio
716
+
717
+ from agenta import AsyncAgentaApi
718
+
719
+ client = AsyncAgentaApi(
720
+ api_key="YOUR_API_KEY",
721
+ base_url="https://yourhost.com/path/to/api",
722
+ )
723
+
724
+
725
+ async def main() -> None:
726
+ await client.evaluators.evaluator_data_map(
727
+ inputs={"key": "value"},
728
+ mapping={"key": "value"},
729
+ )
730
+
731
+
732
+ asyncio.run(main())
733
+ """
734
+ _response = await self._client_wrapper.httpx_client.request(
735
+ "evaluators/map",
736
+ method="POST",
737
+ json={
738
+ "inputs": inputs,
739
+ "mapping": mapping,
740
+ },
741
+ headers={
742
+ "content-type": "application/json",
743
+ },
744
+ request_options=request_options,
745
+ omit=OMIT,
746
+ )
747
+ try:
748
+ if 200 <= _response.status_code < 300:
749
+ return typing.cast(
750
+ EvaluatorMappingOutputInterface,
751
+ parse_obj_as(
752
+ type_=EvaluatorMappingOutputInterface, # type: ignore
753
+ object_=_response.json(),
754
+ ),
755
+ )
756
+ if _response.status_code == 422:
757
+ raise UnprocessableEntityError(
758
+ typing.cast(
759
+ HttpValidationError,
760
+ parse_obj_as(
761
+ type_=HttpValidationError, # type: ignore
762
+ object_=_response.json(),
763
+ ),
764
+ )
765
+ )
766
+ _response_json = _response.json()
767
+ except JSONDecodeError:
768
+ raise ApiError(status_code=_response.status_code, body=_response.text)
769
+ raise ApiError(status_code=_response.status_code, body=_response_json)
770
+
771
+ async def evaluator_run(
772
+ self,
773
+ evaluator_key: str,
774
+ *,
775
+ inputs: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
776
+ settings: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
777
+ credentials: typing.Optional[
778
+ typing.Dict[str, typing.Optional[typing.Any]]
779
+ ] = OMIT,
780
+ request_options: typing.Optional[RequestOptions] = None,
781
+ ) -> EvaluatorOutputInterface:
782
+ """
783
+ Endpoint to evaluate LLM app run
784
+
785
+ Args:
786
+ request (Request): The request object.
787
+ evaluator_key (str): The key of the evaluator.
788
+ payload (EvaluatorInputInterface): The payload containing the request data.
789
+
790
+ Returns:
791
+ result: EvaluatorOutputInterface object containing the outputs.
792
+
793
+ Parameters
794
+ ----------
795
+ evaluator_key : str
796
+
797
+ inputs : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
798
+
799
+ settings : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
800
+
801
+ credentials : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
802
+
803
+ request_options : typing.Optional[RequestOptions]
804
+ Request-specific configuration.
805
+
806
+ Returns
807
+ -------
808
+ EvaluatorOutputInterface
809
+ Successful Response
810
+
811
+ Examples
812
+ --------
813
+ import asyncio
814
+
815
+ from agenta import AsyncAgentaApi
816
+
817
+ client = AsyncAgentaApi(
818
+ api_key="YOUR_API_KEY",
819
+ base_url="https://yourhost.com/path/to/api",
820
+ )
821
+
822
+
823
+ async def main() -> None:
824
+ await client.evaluators.evaluator_run(
825
+ evaluator_key="evaluator_key",
826
+ )
827
+
828
+
829
+ asyncio.run(main())
830
+ """
831
+ _response = await self._client_wrapper.httpx_client.request(
832
+ f"evaluators/{jsonable_encoder(evaluator_key)}/run",
833
+ method="POST",
834
+ json={
835
+ "inputs": inputs,
836
+ "settings": settings,
837
+ "credentials": credentials,
838
+ },
839
+ headers={
840
+ "content-type": "application/json",
841
+ },
842
+ request_options=request_options,
843
+ omit=OMIT,
844
+ )
845
+ try:
846
+ if 200 <= _response.status_code < 300:
847
+ return typing.cast(
848
+ EvaluatorOutputInterface,
849
+ parse_obj_as(
850
+ type_=EvaluatorOutputInterface, # type: ignore
851
+ object_=_response.json(),
852
+ ),
853
+ )
854
+ if _response.status_code == 422:
855
+ raise UnprocessableEntityError(
856
+ typing.cast(
857
+ HttpValidationError,
858
+ parse_obj_as(
859
+ type_=HttpValidationError, # type: ignore
860
+ object_=_response.json(),
861
+ ),
862
+ )
863
+ )
864
+ _response_json = _response.json()
865
+ except JSONDecodeError:
866
+ raise ApiError(status_code=_response.status_code, body=_response.text)
867
+ raise ApiError(status_code=_response.status_code, body=_response_json)
868
+
869
+ async def get_evaluator_configs(
870
+ self, *, app_id: str, request_options: typing.Optional[RequestOptions] = None
871
+ ) -> typing.List[EvaluatorConfig]:
872
+ """
873
+ Endpoint to fetch evaluator configurations for a specific app.
874
+
875
+ Args:
876
+ app_id (str): The ID of the app.
877
+
878
+ Returns:
879
+ List[EvaluatorConfigDB]: A list of evaluator configuration objects.
880
+
881
+ Parameters
882
+ ----------
883
+ app_id : str
884
+
885
+ request_options : typing.Optional[RequestOptions]
886
+ Request-specific configuration.
887
+
888
+ Returns
889
+ -------
890
+ typing.List[EvaluatorConfig]
891
+ Successful Response
892
+
893
+ Examples
894
+ --------
895
+ import asyncio
896
+
897
+ from agenta import AsyncAgentaApi
898
+
899
+ client = AsyncAgentaApi(
900
+ api_key="YOUR_API_KEY",
901
+ base_url="https://yourhost.com/path/to/api",
902
+ )
903
+
904
+
905
+ async def main() -> None:
906
+ await client.evaluators.get_evaluator_configs(
907
+ app_id="app_id",
908
+ )
909
+
910
+
911
+ asyncio.run(main())
912
+ """
913
+ _response = await self._client_wrapper.httpx_client.request(
914
+ "evaluators/configs",
915
+ method="GET",
916
+ params={
917
+ "app_id": app_id,
918
+ },
919
+ request_options=request_options,
920
+ )
921
+ try:
922
+ if 200 <= _response.status_code < 300:
923
+ return typing.cast(
924
+ typing.List[EvaluatorConfig],
925
+ parse_obj_as(
926
+ type_=typing.List[EvaluatorConfig], # type: ignore
927
+ object_=_response.json(),
928
+ ),
929
+ )
930
+ if _response.status_code == 422:
931
+ raise UnprocessableEntityError(
932
+ typing.cast(
933
+ HttpValidationError,
934
+ parse_obj_as(
935
+ type_=HttpValidationError, # type: ignore
936
+ object_=_response.json(),
937
+ ),
938
+ )
939
+ )
940
+ _response_json = _response.json()
941
+ except JSONDecodeError:
942
+ raise ApiError(status_code=_response.status_code, body=_response.text)
943
+ raise ApiError(status_code=_response.status_code, body=_response_json)
944
+
945
+ async def create_new_evaluator_config(
946
+ self,
947
+ *,
948
+ app_id: str,
949
+ name: str,
950
+ evaluator_key: str,
951
+ settings_values: typing.Dict[str, typing.Optional[typing.Any]],
952
+ request_options: typing.Optional[RequestOptions] = None,
953
+ ) -> EvaluatorConfig:
954
+ """
955
+ Endpoint to fetch evaluator configurations for a specific app.
956
+
957
+ Args:
958
+ app_id (str): The ID of the app.
959
+
960
+ Returns:
961
+ EvaluatorConfigDB: Evaluator configuration api model.
962
+
963
+ Parameters
964
+ ----------
965
+ app_id : str
966
+
967
+ name : str
968
+
969
+ evaluator_key : str
970
+
971
+ settings_values : typing.Dict[str, typing.Optional[typing.Any]]
972
+
973
+ request_options : typing.Optional[RequestOptions]
974
+ Request-specific configuration.
975
+
976
+ Returns
977
+ -------
978
+ EvaluatorConfig
979
+ Successful Response
980
+
981
+ Examples
982
+ --------
983
+ import asyncio
984
+
985
+ from agenta import AsyncAgentaApi
986
+
987
+ client = AsyncAgentaApi(
988
+ api_key="YOUR_API_KEY",
989
+ base_url="https://yourhost.com/path/to/api",
990
+ )
991
+
992
+
993
+ async def main() -> None:
994
+ await client.evaluators.create_new_evaluator_config(
995
+ app_id="app_id",
996
+ name="name",
997
+ evaluator_key="evaluator_key",
998
+ settings_values={"key": "value"},
999
+ )
1000
+
1001
+
1002
+ asyncio.run(main())
1003
+ """
1004
+ _response = await self._client_wrapper.httpx_client.request(
1005
+ "evaluators/configs",
1006
+ method="POST",
1007
+ json={
1008
+ "app_id": app_id,
1009
+ "name": name,
1010
+ "evaluator_key": evaluator_key,
1011
+ "settings_values": settings_values,
1012
+ },
1013
+ headers={
1014
+ "content-type": "application/json",
1015
+ },
1016
+ request_options=request_options,
1017
+ omit=OMIT,
1018
+ )
1019
+ try:
1020
+ if 200 <= _response.status_code < 300:
1021
+ return typing.cast(
1022
+ EvaluatorConfig,
1023
+ parse_obj_as(
1024
+ type_=EvaluatorConfig, # type: ignore
1025
+ object_=_response.json(),
1026
+ ),
1027
+ )
1028
+ if _response.status_code == 422:
1029
+ raise UnprocessableEntityError(
1030
+ typing.cast(
1031
+ HttpValidationError,
1032
+ parse_obj_as(
1033
+ type_=HttpValidationError, # type: ignore
1034
+ object_=_response.json(),
1035
+ ),
1036
+ )
1037
+ )
1038
+ _response_json = _response.json()
1039
+ except JSONDecodeError:
1040
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1041
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1042
+
1043
+ async def get_evaluator_config(
1044
+ self,
1045
+ evaluator_config_id: str,
1046
+ *,
1047
+ request_options: typing.Optional[RequestOptions] = None,
1048
+ ) -> EvaluatorConfig:
1049
+ """
1050
+ Endpoint to fetch evaluator configurations for a specific app.
1051
+
1052
+ Returns:
1053
+ List[EvaluatorConfigDB]: A list of evaluator configuration objects.
1054
+
1055
+ Parameters
1056
+ ----------
1057
+ evaluator_config_id : str
1058
+
1059
+ request_options : typing.Optional[RequestOptions]
1060
+ Request-specific configuration.
1061
+
1062
+ Returns
1063
+ -------
1064
+ EvaluatorConfig
1065
+ Successful Response
1066
+
1067
+ Examples
1068
+ --------
1069
+ import asyncio
1070
+
1071
+ from agenta import AsyncAgentaApi
1072
+
1073
+ client = AsyncAgentaApi(
1074
+ api_key="YOUR_API_KEY",
1075
+ base_url="https://yourhost.com/path/to/api",
1076
+ )
1077
+
1078
+
1079
+ async def main() -> None:
1080
+ await client.evaluators.get_evaluator_config(
1081
+ evaluator_config_id="evaluator_config_id",
1082
+ )
1083
+
1084
+
1085
+ asyncio.run(main())
1086
+ """
1087
+ _response = await self._client_wrapper.httpx_client.request(
1088
+ f"evaluators/configs/{jsonable_encoder(evaluator_config_id)}",
1089
+ method="GET",
1090
+ request_options=request_options,
1091
+ )
1092
+ try:
1093
+ if 200 <= _response.status_code < 300:
1094
+ return typing.cast(
1095
+ EvaluatorConfig,
1096
+ parse_obj_as(
1097
+ type_=EvaluatorConfig, # type: ignore
1098
+ object_=_response.json(),
1099
+ ),
1100
+ )
1101
+ if _response.status_code == 422:
1102
+ raise UnprocessableEntityError(
1103
+ typing.cast(
1104
+ HttpValidationError,
1105
+ parse_obj_as(
1106
+ type_=HttpValidationError, # type: ignore
1107
+ object_=_response.json(),
1108
+ ),
1109
+ )
1110
+ )
1111
+ _response_json = _response.json()
1112
+ except JSONDecodeError:
1113
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1114
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1115
+
1116
+ async def update_evaluator_config(
1117
+ self,
1118
+ evaluator_config_id: str,
1119
+ *,
1120
+ name: typing.Optional[str] = OMIT,
1121
+ evaluator_key: typing.Optional[str] = OMIT,
1122
+ settings_values: typing.Optional[
1123
+ typing.Dict[str, typing.Optional[typing.Any]]
1124
+ ] = OMIT,
1125
+ request_options: typing.Optional[RequestOptions] = None,
1126
+ ) -> EvaluatorConfig:
1127
+ """
1128
+ Endpoint to update evaluator configurations for a specific app.
1129
+
1130
+ Returns:
1131
+ List[EvaluatorConfigDB]: A list of evaluator configuration objects.
1132
+
1133
+ Parameters
1134
+ ----------
1135
+ evaluator_config_id : str
1136
+
1137
+ name : typing.Optional[str]
1138
+
1139
+ evaluator_key : typing.Optional[str]
1140
+
1141
+ settings_values : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1142
+
1143
+ request_options : typing.Optional[RequestOptions]
1144
+ Request-specific configuration.
1145
+
1146
+ Returns
1147
+ -------
1148
+ EvaluatorConfig
1149
+ Successful Response
1150
+
1151
+ Examples
1152
+ --------
1153
+ import asyncio
1154
+
1155
+ from agenta import AsyncAgentaApi
1156
+
1157
+ client = AsyncAgentaApi(
1158
+ api_key="YOUR_API_KEY",
1159
+ base_url="https://yourhost.com/path/to/api",
1160
+ )
1161
+
1162
+
1163
+ async def main() -> None:
1164
+ await client.evaluators.update_evaluator_config(
1165
+ evaluator_config_id="evaluator_config_id",
1166
+ )
1167
+
1168
+
1169
+ asyncio.run(main())
1170
+ """
1171
+ _response = await self._client_wrapper.httpx_client.request(
1172
+ f"evaluators/configs/{jsonable_encoder(evaluator_config_id)}",
1173
+ method="PUT",
1174
+ json={
1175
+ "name": name,
1176
+ "evaluator_key": evaluator_key,
1177
+ "settings_values": settings_values,
1178
+ },
1179
+ headers={
1180
+ "content-type": "application/json",
1181
+ },
1182
+ request_options=request_options,
1183
+ omit=OMIT,
1184
+ )
1185
+ try:
1186
+ if 200 <= _response.status_code < 300:
1187
+ return typing.cast(
1188
+ EvaluatorConfig,
1189
+ parse_obj_as(
1190
+ type_=EvaluatorConfig, # type: ignore
1191
+ object_=_response.json(),
1192
+ ),
1193
+ )
1194
+ if _response.status_code == 422:
1195
+ raise UnprocessableEntityError(
1196
+ typing.cast(
1197
+ HttpValidationError,
1198
+ parse_obj_as(
1199
+ type_=HttpValidationError, # type: ignore
1200
+ object_=_response.json(),
1201
+ ),
1202
+ )
1203
+ )
1204
+ _response_json = _response.json()
1205
+ except JSONDecodeError:
1206
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1207
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1208
+
1209
+ async def delete_evaluator_config(
1210
+ self,
1211
+ evaluator_config_id: str,
1212
+ *,
1213
+ request_options: typing.Optional[RequestOptions] = None,
1214
+ ) -> bool:
1215
+ """
1216
+ Endpoint to delete a specific evaluator configuration.
1217
+
1218
+ Args:
1219
+ evaluator_config_id (str): The unique identifier of the evaluator configuration.
1220
+
1221
+ Returns:
1222
+ bool: True if deletion was successful, False otherwise.
1223
+
1224
+ Parameters
1225
+ ----------
1226
+ evaluator_config_id : str
1227
+
1228
+ request_options : typing.Optional[RequestOptions]
1229
+ Request-specific configuration.
1230
+
1231
+ Returns
1232
+ -------
1233
+ bool
1234
+ Successful Response
1235
+
1236
+ Examples
1237
+ --------
1238
+ import asyncio
1239
+
1240
+ from agenta import AsyncAgentaApi
1241
+
1242
+ client = AsyncAgentaApi(
1243
+ api_key="YOUR_API_KEY",
1244
+ base_url="https://yourhost.com/path/to/api",
1245
+ )
1246
+
1247
+
1248
+ async def main() -> None:
1249
+ await client.evaluators.delete_evaluator_config(
1250
+ evaluator_config_id="evaluator_config_id",
1251
+ )
1252
+
1253
+
1254
+ asyncio.run(main())
1255
+ """
1256
+ _response = await self._client_wrapper.httpx_client.request(
1257
+ f"evaluators/configs/{jsonable_encoder(evaluator_config_id)}",
1258
+ method="DELETE",
1259
+ request_options=request_options,
1260
+ )
1261
+ try:
1262
+ if 200 <= _response.status_code < 300:
1263
+ return typing.cast(
1264
+ bool,
1265
+ parse_obj_as(
1266
+ type_=bool, # type: ignore
1267
+ object_=_response.json(),
1268
+ ),
1269
+ )
1270
+ if _response.status_code == 422:
1271
+ raise UnprocessableEntityError(
1272
+ typing.cast(
1273
+ HttpValidationError,
1274
+ parse_obj_as(
1275
+ type_=HttpValidationError, # type: ignore
1276
+ object_=_response.json(),
1277
+ ),
1278
+ )
1279
+ )
1280
+ _response_json = _response.json()
1281
+ except JSONDecodeError:
1282
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1283
+ raise ApiError(status_code=_response.status_code, body=_response_json)