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,648 @@
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 .. import core
6
+ from ..core.request_options import RequestOptions
7
+ from ..types.image import Image
8
+ from ..core.pydantic_utilities import parse_obj_as
9
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
10
+ from ..types.http_validation_error import HttpValidationError
11
+ from json.decoder import JSONDecodeError
12
+ from ..core.api_error import ApiError
13
+ from .types.container_templates_response import ContainerTemplatesResponse
14
+ from ..types.uri import Uri
15
+ from ..core.client_wrapper import AsyncClientWrapper
16
+
17
+ # this is used as the default value for optional parameters
18
+ OMIT = typing.cast(typing.Any, ...)
19
+
20
+
21
+ class ContainersClient:
22
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
23
+ self._client_wrapper = client_wrapper
24
+
25
+ def build_image(
26
+ self,
27
+ *,
28
+ app_id: str,
29
+ base_name: str,
30
+ tar_file: core.File,
31
+ request_options: typing.Optional[RequestOptions] = None,
32
+ ) -> Image:
33
+ """
34
+ Builds a Docker image from a tar file containing the application code.
35
+
36
+ Args:
37
+ app_id (str): The ID of the application to build the image for.
38
+ base_name (str): The base name of the image to build.
39
+ tar_file (UploadFile): The tar file containing the application code.
40
+ stoken_session (SessionContainer): The session container for the user making the request.
41
+
42
+ Returns:
43
+ Image: The Docker image that was built.
44
+
45
+ Parameters
46
+ ----------
47
+ app_id : str
48
+
49
+ base_name : str
50
+
51
+ tar_file : core.File
52
+ See core.File for more documentation
53
+
54
+ request_options : typing.Optional[RequestOptions]
55
+ Request-specific configuration.
56
+
57
+ Returns
58
+ -------
59
+ Image
60
+ Successful Response
61
+
62
+ Examples
63
+ --------
64
+ from agenta import AgentaApi
65
+
66
+ client = AgentaApi(
67
+ api_key="YOUR_API_KEY",
68
+ base_url="https://yourhost.com/path/to/api",
69
+ )
70
+ client.containers.build_image(
71
+ app_id="app_id",
72
+ base_name="base_name",
73
+ )
74
+ """
75
+ _response = self._client_wrapper.httpx_client.request(
76
+ "containers/build_image",
77
+ method="POST",
78
+ params={
79
+ "app_id": app_id,
80
+ "base_name": base_name,
81
+ },
82
+ data={},
83
+ files={
84
+ "tar_file": tar_file,
85
+ },
86
+ request_options=(
87
+ {**request_options, "timeout_in_seconds": 600}
88
+ if request_options
89
+ else {"timeout_in_seconds": 600}
90
+ ),
91
+ omit=OMIT,
92
+ )
93
+ try:
94
+ if 200 <= _response.status_code < 300:
95
+ return typing.cast(
96
+ Image,
97
+ parse_obj_as(
98
+ type_=Image, # type: ignore
99
+ object_=_response.json(),
100
+ ),
101
+ )
102
+ if _response.status_code == 422:
103
+ raise UnprocessableEntityError(
104
+ typing.cast(
105
+ HttpValidationError,
106
+ parse_obj_as(
107
+ type_=HttpValidationError, # type: ignore
108
+ object_=_response.json(),
109
+ ),
110
+ )
111
+ )
112
+ _response_json = _response.json()
113
+ except JSONDecodeError:
114
+ raise ApiError(status_code=_response.status_code, body=_response.text)
115
+ raise ApiError(status_code=_response.status_code, body=_response_json)
116
+
117
+ def restart_container(
118
+ self,
119
+ *,
120
+ variant_id: str,
121
+ request_options: typing.Optional[RequestOptions] = None,
122
+ ) -> typing.Dict[str, typing.Optional[typing.Any]]:
123
+ """
124
+ Restart docker container.
125
+
126
+ Args:
127
+ payload (RestartAppContainer) -- the required data (app_name and variant_name)
128
+
129
+ Parameters
130
+ ----------
131
+ variant_id : str
132
+
133
+ request_options : typing.Optional[RequestOptions]
134
+ Request-specific configuration.
135
+
136
+ Returns
137
+ -------
138
+ typing.Dict[str, typing.Optional[typing.Any]]
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.containers.restart_container(
150
+ variant_id="variant_id",
151
+ )
152
+ """
153
+ _response = self._client_wrapper.httpx_client.request(
154
+ "containers/restart_container",
155
+ method="POST",
156
+ json={
157
+ "variant_id": variant_id,
158
+ },
159
+ headers={
160
+ "content-type": "application/json",
161
+ },
162
+ request_options=request_options,
163
+ omit=OMIT,
164
+ )
165
+ try:
166
+ if 200 <= _response.status_code < 300:
167
+ return typing.cast(
168
+ typing.Dict[str, typing.Optional[typing.Any]],
169
+ parse_obj_as(
170
+ type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore
171
+ object_=_response.json(),
172
+ ),
173
+ )
174
+ if _response.status_code == 422:
175
+ raise UnprocessableEntityError(
176
+ typing.cast(
177
+ HttpValidationError,
178
+ parse_obj_as(
179
+ type_=HttpValidationError, # type: ignore
180
+ object_=_response.json(),
181
+ ),
182
+ )
183
+ )
184
+ _response_json = _response.json()
185
+ except JSONDecodeError:
186
+ raise ApiError(status_code=_response.status_code, body=_response.text)
187
+ raise ApiError(status_code=_response.status_code, body=_response_json)
188
+
189
+ def container_templates(
190
+ self, *, request_options: typing.Optional[RequestOptions] = None
191
+ ) -> ContainerTemplatesResponse:
192
+ """
193
+ Returns a list of templates available for creating new containers.
194
+
195
+ Parameters:
196
+ stoken_session (SessionContainer): The session container for the user.
197
+
198
+ Returns:
199
+
200
+ Union[List[Template], str]: A list of templates or an error message.
201
+
202
+ Parameters
203
+ ----------
204
+ request_options : typing.Optional[RequestOptions]
205
+ Request-specific configuration.
206
+
207
+ Returns
208
+ -------
209
+ ContainerTemplatesResponse
210
+ Successful Response
211
+
212
+ Examples
213
+ --------
214
+ from agenta import AgentaApi
215
+
216
+ client = AgentaApi(
217
+ api_key="YOUR_API_KEY",
218
+ base_url="https://yourhost.com/path/to/api",
219
+ )
220
+ client.containers.container_templates()
221
+ """
222
+ _response = self._client_wrapper.httpx_client.request(
223
+ "containers/templates",
224
+ method="GET",
225
+ request_options=request_options,
226
+ )
227
+ try:
228
+ if 200 <= _response.status_code < 300:
229
+ return typing.cast(
230
+ ContainerTemplatesResponse,
231
+ parse_obj_as(
232
+ type_=ContainerTemplatesResponse, # type: ignore
233
+ object_=_response.json(),
234
+ ),
235
+ )
236
+ _response_json = _response.json()
237
+ except JSONDecodeError:
238
+ raise ApiError(status_code=_response.status_code, body=_response.text)
239
+ raise ApiError(status_code=_response.status_code, body=_response_json)
240
+
241
+ def construct_app_container_url(
242
+ self,
243
+ *,
244
+ base_id: typing.Optional[str] = None,
245
+ variant_id: typing.Optional[str] = None,
246
+ request_options: typing.Optional[RequestOptions] = None,
247
+ ) -> Uri:
248
+ """
249
+ Constructs the URL for an app container based on the provided base_id or variant_id.
250
+
251
+ Args:
252
+ base_id (Optional[str]): The ID of the base to use for the app container.
253
+ variant_id (Optional[str]): The ID of the variant to use for the app container.
254
+ request (Request): The request object.
255
+
256
+ Returns:
257
+ URI: The URI for the app container.
258
+
259
+ Raises:
260
+ HTTPException: If the base or variant cannot be found or the user does not have access.
261
+
262
+ Parameters
263
+ ----------
264
+ base_id : typing.Optional[str]
265
+
266
+ variant_id : typing.Optional[str]
267
+
268
+ request_options : typing.Optional[RequestOptions]
269
+ Request-specific configuration.
270
+
271
+ Returns
272
+ -------
273
+ Uri
274
+ Successful Response
275
+
276
+ Examples
277
+ --------
278
+ from agenta import AgentaApi
279
+
280
+ client = AgentaApi(
281
+ api_key="YOUR_API_KEY",
282
+ base_url="https://yourhost.com/path/to/api",
283
+ )
284
+ client.containers.construct_app_container_url()
285
+ """
286
+ _response = self._client_wrapper.httpx_client.request(
287
+ "containers/container_url",
288
+ method="GET",
289
+ params={
290
+ "base_id": base_id,
291
+ "variant_id": variant_id,
292
+ },
293
+ request_options=request_options,
294
+ )
295
+ try:
296
+ if 200 <= _response.status_code < 300:
297
+ return typing.cast(
298
+ Uri,
299
+ parse_obj_as(
300
+ type_=Uri, # type: ignore
301
+ object_=_response.json(),
302
+ ),
303
+ )
304
+ if _response.status_code == 422:
305
+ raise UnprocessableEntityError(
306
+ typing.cast(
307
+ HttpValidationError,
308
+ parse_obj_as(
309
+ type_=HttpValidationError, # type: ignore
310
+ object_=_response.json(),
311
+ ),
312
+ )
313
+ )
314
+ _response_json = _response.json()
315
+ except JSONDecodeError:
316
+ raise ApiError(status_code=_response.status_code, body=_response.text)
317
+ raise ApiError(status_code=_response.status_code, body=_response_json)
318
+
319
+
320
+ class AsyncContainersClient:
321
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
322
+ self._client_wrapper = client_wrapper
323
+
324
+ async def build_image(
325
+ self,
326
+ *,
327
+ app_id: str,
328
+ base_name: str,
329
+ tar_file: core.File,
330
+ request_options: typing.Optional[RequestOptions] = None,
331
+ ) -> Image:
332
+ """
333
+ Builds a Docker image from a tar file containing the application code.
334
+
335
+ Args:
336
+ app_id (str): The ID of the application to build the image for.
337
+ base_name (str): The base name of the image to build.
338
+ tar_file (UploadFile): The tar file containing the application code.
339
+ stoken_session (SessionContainer): The session container for the user making the request.
340
+
341
+ Returns:
342
+ Image: The Docker image that was built.
343
+
344
+ Parameters
345
+ ----------
346
+ app_id : str
347
+
348
+ base_name : str
349
+
350
+ tar_file : core.File
351
+ See core.File for more documentation
352
+
353
+ request_options : typing.Optional[RequestOptions]
354
+ Request-specific configuration.
355
+
356
+ Returns
357
+ -------
358
+ Image
359
+ Successful Response
360
+
361
+ Examples
362
+ --------
363
+ import asyncio
364
+
365
+ from agenta import AsyncAgentaApi
366
+
367
+ client = AsyncAgentaApi(
368
+ api_key="YOUR_API_KEY",
369
+ base_url="https://yourhost.com/path/to/api",
370
+ )
371
+
372
+
373
+ async def main() -> None:
374
+ await client.containers.build_image(
375
+ app_id="app_id",
376
+ base_name="base_name",
377
+ )
378
+
379
+
380
+ asyncio.run(main())
381
+ """
382
+ _response = await self._client_wrapper.httpx_client.request(
383
+ "containers/build_image",
384
+ method="POST",
385
+ params={
386
+ "app_id": app_id,
387
+ "base_name": base_name,
388
+ },
389
+ data={},
390
+ files={
391
+ "tar_file": tar_file,
392
+ },
393
+ request_options=(
394
+ {**request_options, "timeout_in_seconds": 600}
395
+ if request_options
396
+ else {"timeout_in_seconds": 600}
397
+ ),
398
+ omit=OMIT,
399
+ )
400
+ try:
401
+ if 200 <= _response.status_code < 300:
402
+ return typing.cast(
403
+ Image,
404
+ parse_obj_as(
405
+ type_=Image, # type: ignore
406
+ object_=_response.json(),
407
+ ),
408
+ )
409
+ if _response.status_code == 422:
410
+ raise UnprocessableEntityError(
411
+ typing.cast(
412
+ HttpValidationError,
413
+ parse_obj_as(
414
+ type_=HttpValidationError, # type: ignore
415
+ object_=_response.json(),
416
+ ),
417
+ )
418
+ )
419
+ _response_json = _response.json()
420
+ except JSONDecodeError:
421
+ raise ApiError(status_code=_response.status_code, body=_response.text)
422
+ raise ApiError(status_code=_response.status_code, body=_response_json)
423
+
424
+ async def restart_container(
425
+ self,
426
+ *,
427
+ variant_id: str,
428
+ request_options: typing.Optional[RequestOptions] = None,
429
+ ) -> typing.Dict[str, typing.Optional[typing.Any]]:
430
+ """
431
+ Restart docker container.
432
+
433
+ Args:
434
+ payload (RestartAppContainer) -- the required data (app_name and variant_name)
435
+
436
+ Parameters
437
+ ----------
438
+ variant_id : str
439
+
440
+ request_options : typing.Optional[RequestOptions]
441
+ Request-specific configuration.
442
+
443
+ Returns
444
+ -------
445
+ typing.Dict[str, typing.Optional[typing.Any]]
446
+ Successful Response
447
+
448
+ Examples
449
+ --------
450
+ import asyncio
451
+
452
+ from agenta import AsyncAgentaApi
453
+
454
+ client = AsyncAgentaApi(
455
+ api_key="YOUR_API_KEY",
456
+ base_url="https://yourhost.com/path/to/api",
457
+ )
458
+
459
+
460
+ async def main() -> None:
461
+ await client.containers.restart_container(
462
+ variant_id="variant_id",
463
+ )
464
+
465
+
466
+ asyncio.run(main())
467
+ """
468
+ _response = await self._client_wrapper.httpx_client.request(
469
+ "containers/restart_container",
470
+ method="POST",
471
+ json={
472
+ "variant_id": variant_id,
473
+ },
474
+ headers={
475
+ "content-type": "application/json",
476
+ },
477
+ request_options=request_options,
478
+ omit=OMIT,
479
+ )
480
+ try:
481
+ if 200 <= _response.status_code < 300:
482
+ return typing.cast(
483
+ typing.Dict[str, typing.Optional[typing.Any]],
484
+ parse_obj_as(
485
+ type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore
486
+ object_=_response.json(),
487
+ ),
488
+ )
489
+ if _response.status_code == 422:
490
+ raise UnprocessableEntityError(
491
+ typing.cast(
492
+ HttpValidationError,
493
+ parse_obj_as(
494
+ type_=HttpValidationError, # type: ignore
495
+ object_=_response.json(),
496
+ ),
497
+ )
498
+ )
499
+ _response_json = _response.json()
500
+ except JSONDecodeError:
501
+ raise ApiError(status_code=_response.status_code, body=_response.text)
502
+ raise ApiError(status_code=_response.status_code, body=_response_json)
503
+
504
+ async def container_templates(
505
+ self, *, request_options: typing.Optional[RequestOptions] = None
506
+ ) -> ContainerTemplatesResponse:
507
+ """
508
+ Returns a list of templates available for creating new containers.
509
+
510
+ Parameters:
511
+ stoken_session (SessionContainer): The session container for the user.
512
+
513
+ Returns:
514
+
515
+ Union[List[Template], str]: A list of templates or an error message.
516
+
517
+ Parameters
518
+ ----------
519
+ request_options : typing.Optional[RequestOptions]
520
+ Request-specific configuration.
521
+
522
+ Returns
523
+ -------
524
+ ContainerTemplatesResponse
525
+ Successful Response
526
+
527
+ Examples
528
+ --------
529
+ import asyncio
530
+
531
+ from agenta import AsyncAgentaApi
532
+
533
+ client = AsyncAgentaApi(
534
+ api_key="YOUR_API_KEY",
535
+ base_url="https://yourhost.com/path/to/api",
536
+ )
537
+
538
+
539
+ async def main() -> None:
540
+ await client.containers.container_templates()
541
+
542
+
543
+ asyncio.run(main())
544
+ """
545
+ _response = await self._client_wrapper.httpx_client.request(
546
+ "containers/templates",
547
+ method="GET",
548
+ request_options=request_options,
549
+ )
550
+ try:
551
+ if 200 <= _response.status_code < 300:
552
+ return typing.cast(
553
+ ContainerTemplatesResponse,
554
+ parse_obj_as(
555
+ type_=ContainerTemplatesResponse, # type: ignore
556
+ object_=_response.json(),
557
+ ),
558
+ )
559
+ _response_json = _response.json()
560
+ except JSONDecodeError:
561
+ raise ApiError(status_code=_response.status_code, body=_response.text)
562
+ raise ApiError(status_code=_response.status_code, body=_response_json)
563
+
564
+ async def construct_app_container_url(
565
+ self,
566
+ *,
567
+ base_id: typing.Optional[str] = None,
568
+ variant_id: typing.Optional[str] = None,
569
+ request_options: typing.Optional[RequestOptions] = None,
570
+ ) -> Uri:
571
+ """
572
+ Constructs the URL for an app container based on the provided base_id or variant_id.
573
+
574
+ Args:
575
+ base_id (Optional[str]): The ID of the base to use for the app container.
576
+ variant_id (Optional[str]): The ID of the variant to use for the app container.
577
+ request (Request): The request object.
578
+
579
+ Returns:
580
+ URI: The URI for the app container.
581
+
582
+ Raises:
583
+ HTTPException: If the base or variant cannot be found or the user does not have access.
584
+
585
+ Parameters
586
+ ----------
587
+ base_id : typing.Optional[str]
588
+
589
+ variant_id : typing.Optional[str]
590
+
591
+ request_options : typing.Optional[RequestOptions]
592
+ Request-specific configuration.
593
+
594
+ Returns
595
+ -------
596
+ Uri
597
+ Successful Response
598
+
599
+ Examples
600
+ --------
601
+ import asyncio
602
+
603
+ from agenta import AsyncAgentaApi
604
+
605
+ client = AsyncAgentaApi(
606
+ api_key="YOUR_API_KEY",
607
+ base_url="https://yourhost.com/path/to/api",
608
+ )
609
+
610
+
611
+ async def main() -> None:
612
+ await client.containers.construct_app_container_url()
613
+
614
+
615
+ asyncio.run(main())
616
+ """
617
+ _response = await self._client_wrapper.httpx_client.request(
618
+ "containers/container_url",
619
+ method="GET",
620
+ params={
621
+ "base_id": base_id,
622
+ "variant_id": variant_id,
623
+ },
624
+ request_options=request_options,
625
+ )
626
+ try:
627
+ if 200 <= _response.status_code < 300:
628
+ return typing.cast(
629
+ Uri,
630
+ parse_obj_as(
631
+ type_=Uri, # type: ignore
632
+ object_=_response.json(),
633
+ ),
634
+ )
635
+ if _response.status_code == 422:
636
+ raise UnprocessableEntityError(
637
+ typing.cast(
638
+ HttpValidationError,
639
+ parse_obj_as(
640
+ type_=HttpValidationError, # type: ignore
641
+ object_=_response.json(),
642
+ ),
643
+ )
644
+ )
645
+ _response_json = _response.json()
646
+ except JSONDecodeError:
647
+ raise ApiError(status_code=_response.status_code, body=_response.text)
648
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .container_templates_response import ContainerTemplatesResponse
4
+
5
+ __all__ = ["ContainerTemplatesResponse"]
@@ -1,7 +1,6 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  import typing
4
-
5
- from .template import Template
4
+ from ...types.template import Template
6
5
 
7
6
  ContainerTemplatesResponse = typing.Union[typing.List[Template], str]
@@ -3,15 +3,45 @@
3
3
  from .api_error import ApiError
4
4
  from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
5
5
  from .datetime_utils import serialize_datetime
6
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
7
+ from .http_client import AsyncHttpClient, HttpClient
6
8
  from .jsonable_encoder import jsonable_encoder
9
+ from .pydantic_utilities import (
10
+ IS_PYDANTIC_V2,
11
+ UniversalBaseModel,
12
+ UniversalRootModel,
13
+ parse_obj_as,
14
+ universal_field_validator,
15
+ universal_root_validator,
16
+ update_forward_refs,
17
+ )
18
+ from .query_encoder import encode_query
7
19
  from .remove_none_from_dict import remove_none_from_dict
20
+ from .request_options import RequestOptions
21
+ from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
8
22
 
9
23
  __all__ = [
10
24
  "ApiError",
11
25
  "AsyncClientWrapper",
26
+ "AsyncHttpClient",
12
27
  "BaseClientWrapper",
28
+ "FieldMetadata",
29
+ "File",
30
+ "HttpClient",
31
+ "IS_PYDANTIC_V2",
32
+ "RequestOptions",
13
33
  "SyncClientWrapper",
34
+ "UniversalBaseModel",
35
+ "UniversalRootModel",
36
+ "convert_and_respect_annotation_metadata",
37
+ "convert_file_dict_to_httpx_tuples",
38
+ "encode_query",
14
39
  "jsonable_encoder",
40
+ "parse_obj_as",
15
41
  "remove_none_from_dict",
16
42
  "serialize_datetime",
43
+ "universal_field_validator",
44
+ "universal_root_validator",
45
+ "update_forward_refs",
46
+ "with_content_type",
17
47
  ]