agenta 0.24.1__py3-none-any.whl → 0.24.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

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