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.
- agenta/cli/variant_commands.py +15 -10
- agenta/client/Readme.md +72 -64
- agenta/client/api.py +1 -1
- agenta/client/backend/__init__.py +14 -9
- agenta/client/backend/apps/client.py +1669 -0
- agenta/client/backend/bases/client.py +190 -0
- agenta/client/backend/client.py +2102 -868
- agenta/client/backend/configs/client.py +598 -0
- agenta/client/backend/containers/client.py +638 -0
- agenta/client/backend/{resources/containers → containers}/types/container_templates_response.py +1 -2
- agenta/client/backend/core/__init__.py +29 -0
- agenta/client/backend/core/client_wrapper.py +42 -9
- agenta/client/backend/core/datetime_utils.py +1 -1
- agenta/client/backend/core/file.py +43 -0
- agenta/client/backend/core/http_client.py +553 -0
- agenta/client/backend/core/jsonable_encoder.py +33 -39
- agenta/client/backend/core/pydantic_utilities.py +212 -0
- agenta/client/backend/core/query_encoder.py +60 -0
- agenta/client/backend/core/remove_none_from_dict.py +2 -2
- agenta/client/backend/core/request_options.py +32 -0
- agenta/client/backend/core/serialization.py +179 -0
- agenta/client/backend/environments/client.py +190 -0
- agenta/client/backend/evaluations/client.py +1462 -0
- agenta/client/backend/evaluators/client.py +911 -0
- agenta/client/backend/observability/client.py +1271 -0
- agenta/client/backend/testsets/client.py +1132 -0
- agenta/client/backend/types/__init__.py +8 -6
- agenta/client/backend/types/aggregated_result.py +14 -29
- agenta/client/backend/types/aggregated_result_evaluator_config.py +1 -2
- agenta/client/backend/types/app.py +13 -28
- agenta/client/backend/types/app_variant_response.py +21 -37
- agenta/client/backend/types/app_variant_revision.py +17 -32
- agenta/client/backend/types/base_output.py +13 -28
- agenta/client/backend/types/body_import_testset.py +16 -31
- agenta/client/backend/types/config_db.py +16 -31
- agenta/client/backend/types/correct_answer.py +22 -0
- agenta/client/backend/types/create_app_output.py +13 -28
- agenta/client/backend/types/create_span.py +33 -50
- agenta/client/backend/types/create_trace_response.py +16 -31
- agenta/client/backend/types/docker_env_vars.py +13 -28
- agenta/client/backend/types/environment_output.py +21 -36
- agenta/client/backend/types/environment_output_extended.py +21 -36
- agenta/client/backend/types/environment_revision.py +18 -33
- agenta/client/backend/types/error.py +16 -31
- agenta/client/backend/types/evaluation.py +20 -34
- agenta/client/backend/types/evaluation_scenario.py +18 -33
- agenta/client/backend/types/evaluation_scenario_input.py +16 -31
- agenta/client/backend/types/evaluation_scenario_output.py +18 -33
- agenta/client/backend/types/evaluation_scenario_result.py +14 -29
- agenta/client/backend/types/evaluation_scenario_score_update.py +13 -28
- agenta/client/backend/types/evaluation_status_enum.py +11 -33
- agenta/client/backend/types/evaluation_type.py +3 -21
- agenta/client/backend/types/evaluator.py +18 -32
- agenta/client/backend/types/evaluator_config.py +20 -33
- agenta/client/backend/types/get_config_response.py +16 -31
- agenta/client/backend/types/http_validation_error.py +14 -29
- agenta/client/backend/types/human_evaluation.py +17 -32
- agenta/client/backend/types/human_evaluation_scenario.py +21 -37
- agenta/client/backend/types/human_evaluation_scenario_input.py +13 -28
- agenta/client/backend/types/human_evaluation_scenario_output.py +13 -28
- agenta/client/backend/types/human_evaluation_scenario_update.py +26 -41
- agenta/client/backend/types/human_evaluation_update.py +14 -29
- agenta/client/backend/types/image.py +18 -33
- agenta/client/backend/types/invite_request.py +13 -28
- agenta/client/backend/types/list_api_keys_response.py +18 -33
- agenta/client/backend/types/llm_run_rate_limit.py +13 -28
- agenta/client/backend/types/llm_tokens.py +16 -31
- agenta/client/backend/types/lm_providers_enum.py +21 -0
- agenta/client/backend/types/new_human_evaluation.py +13 -28
- agenta/client/backend/types/new_testset.py +16 -31
- agenta/client/backend/types/organization.py +22 -36
- agenta/client/backend/types/organization_output.py +13 -28
- agenta/client/backend/types/outputs.py +5 -0
- agenta/client/backend/types/permission.py +36 -137
- agenta/client/backend/types/result.py +17 -32
- agenta/client/backend/types/simple_evaluation_output.py +13 -28
- agenta/client/backend/types/span.py +23 -38
- agenta/client/backend/types/span_detail.py +26 -40
- agenta/client/backend/types/span_status_code.py +1 -25
- agenta/client/backend/types/span_variant.py +16 -31
- agenta/client/backend/types/template.py +14 -29
- agenta/client/backend/types/template_image_info.py +21 -35
- agenta/client/backend/types/test_set_output_response.py +16 -32
- agenta/client/backend/types/test_set_simple_response.py +13 -28
- agenta/client/backend/types/trace_detail.py +26 -40
- agenta/client/backend/types/update_app_output.py +22 -0
- agenta/client/backend/types/uri.py +13 -28
- agenta/client/backend/types/validation_error.py +13 -28
- agenta/client/backend/types/variant_action.py +14 -29
- agenta/client/backend/types/variant_action_enum.py +1 -19
- agenta/client/backend/types/with_pagination.py +14 -30
- agenta/client/backend/types/workspace_member_response.py +14 -29
- agenta/client/backend/types/workspace_permission.py +18 -33
- agenta/client/backend/types/workspace_response.py +20 -35
- agenta/client/backend/types/workspace_role.py +11 -37
- agenta/client/backend/types/workspace_role_response.py +17 -32
- agenta/client/backend/variants/client.py +1447 -0
- agenta/client/backend/variants/types/add_variant_from_base_and_config_response.py +8 -0
- agenta/sdk/tracing/llm_tracing.py +10 -12
- {agenta-0.24.1.dist-info → agenta-0.24.2.dist-info}/METADATA +1 -1
- agenta-0.24.2.dist-info/RECORD +175 -0
- agenta/client/backend/resources/__init__.py +0 -31
- agenta/client/backend/resources/apps/client.py +0 -977
- agenta/client/backend/resources/bases/client.py +0 -127
- agenta/client/backend/resources/configs/client.py +0 -377
- agenta/client/backend/resources/containers/client.py +0 -383
- agenta/client/backend/resources/environments/client.py +0 -131
- agenta/client/backend/resources/evaluations/client.py +0 -1008
- agenta/client/backend/resources/evaluators/client.py +0 -594
- agenta/client/backend/resources/observability/client.py +0 -1187
- agenta/client/backend/resources/testsets/client.py +0 -689
- agenta/client/backend/resources/variants/client.py +0 -796
- agenta/client/backend/resources/variants/types/add_variant_from_base_and_config_response.py +0 -7
- agenta/client/backend/types/evaluation_webhook.py +0 -36
- agenta/client/backend/types/feedback.py +0 -40
- agenta/client/backend/types/span_kind.py +0 -49
- agenta-0.24.1.dist-info/RECORD +0 -169
- /agenta/client/backend/{resources/apps → apps}/__init__.py +0 -0
- /agenta/client/backend/{resources/bases → bases}/__init__.py +0 -0
- /agenta/client/backend/{resources/configs → configs}/__init__.py +0 -0
- /agenta/client/backend/{resources/containers → containers}/__init__.py +0 -0
- /agenta/client/backend/{resources/containers → containers}/types/__init__.py +0 -0
- /agenta/client/backend/{resources/environments → environments}/__init__.py +0 -0
- /agenta/client/backend/{resources/evaluations → evaluations}/__init__.py +0 -0
- /agenta/client/backend/{resources/evaluators → evaluators}/__init__.py +0 -0
- /agenta/client/backend/{resources/observability → observability}/__init__.py +0 -0
- /agenta/client/backend/{resources/testsets → testsets}/__init__.py +0 -0
- /agenta/client/backend/{resources/variants → variants}/__init__.py +0 -0
- /agenta/client/backend/{resources/variants → variants}/types/__init__.py +0 -0
- {agenta-0.24.1.dist-info → agenta-0.24.2.dist-info}/WHEEL +0 -0
- {agenta-0.24.1.dist-info → agenta-0.24.2.dist-info}/entry_points.txt +0 -0
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
-
|
|
3
|
-
import typing
|
|
4
|
-
import urllib.parse
|
|
5
|
-
from json.decoder import JSONDecodeError
|
|
6
|
-
|
|
7
|
-
from ...core.api_error import ApiError
|
|
8
|
-
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
-
from ...core.jsonable_encoder import jsonable_encoder
|
|
10
|
-
from ...core.remove_none_from_dict import remove_none_from_dict
|
|
11
|
-
from ...errors.unprocessable_entity_error import UnprocessableEntityError
|
|
12
|
-
from ...types.http_validation_error import HttpValidationError
|
|
13
|
-
from ...types.image import Image
|
|
14
|
-
from ...types.uri import Uri
|
|
15
|
-
from .types.container_templates_response import ContainerTemplatesResponse
|
|
16
|
-
|
|
17
|
-
try:
|
|
18
|
-
import pydantic.v1 as pydantic # type: ignore
|
|
19
|
-
except ImportError:
|
|
20
|
-
import pydantic # type: ignore
|
|
21
|
-
|
|
22
|
-
# this is used as the default value for optional parameters
|
|
23
|
-
OMIT = typing.cast(typing.Any, ...)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class ContainersClient:
|
|
27
|
-
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
28
|
-
self._client_wrapper = client_wrapper
|
|
29
|
-
|
|
30
|
-
def build_image(self, *, app_id: str, base_name: str, tar_file: typing.IO) -> Image:
|
|
31
|
-
"""
|
|
32
|
-
Builds a Docker image from a tar file containing the application code.
|
|
33
|
-
|
|
34
|
-
Args:
|
|
35
|
-
app_id (str): The ID of the application to build the image for.
|
|
36
|
-
base_name (str): The base name of the image to build.
|
|
37
|
-
tar_file (UploadFile): The tar file containing the application code.
|
|
38
|
-
stoken_session (SessionContainer): The session container for the user making the request.
|
|
39
|
-
|
|
40
|
-
Returns:
|
|
41
|
-
Image: The Docker image that was built.
|
|
42
|
-
|
|
43
|
-
Parameters:
|
|
44
|
-
- app_id: str.
|
|
45
|
-
|
|
46
|
-
- base_name: str.
|
|
47
|
-
|
|
48
|
-
- tar_file: typing.IO.
|
|
49
|
-
---
|
|
50
|
-
from agenta.client import AgentaApi
|
|
51
|
-
|
|
52
|
-
client = AgentaApi(
|
|
53
|
-
api_key="YOUR_API_KEY",
|
|
54
|
-
base_url="https://yourhost.com/path/to/api",
|
|
55
|
-
)
|
|
56
|
-
client.containers.build_image(
|
|
57
|
-
app_id="app_id",
|
|
58
|
-
base_name="base_name",
|
|
59
|
-
)
|
|
60
|
-
"""
|
|
61
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
62
|
-
"POST",
|
|
63
|
-
urllib.parse.urljoin(
|
|
64
|
-
f"{self._client_wrapper.get_base_url()}/", "containers/build_image"
|
|
65
|
-
),
|
|
66
|
-
params=remove_none_from_dict({"app_id": app_id, "base_name": base_name}),
|
|
67
|
-
data=jsonable_encoder({}),
|
|
68
|
-
files={"tar_file": tar_file},
|
|
69
|
-
headers=self._client_wrapper.get_headers(),
|
|
70
|
-
timeout=600,
|
|
71
|
-
)
|
|
72
|
-
if 200 <= _response.status_code < 300:
|
|
73
|
-
return pydantic.parse_obj_as(Image, _response.json()) # type: ignore
|
|
74
|
-
if _response.status_code == 422:
|
|
75
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
76
|
-
try:
|
|
77
|
-
_response_json = _response.json()
|
|
78
|
-
except JSONDecodeError:
|
|
79
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
80
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
81
|
-
|
|
82
|
-
def restart_container(self, *, variant_id: str) -> typing.Dict[str, typing.Any]:
|
|
83
|
-
"""
|
|
84
|
-
Restart docker container.
|
|
85
|
-
|
|
86
|
-
Args:
|
|
87
|
-
payload (RestartAppContainer) -- the required data (app_name and variant_name)
|
|
88
|
-
|
|
89
|
-
Parameters:
|
|
90
|
-
- variant_id: str.
|
|
91
|
-
---
|
|
92
|
-
from agenta.client import AgentaApi
|
|
93
|
-
|
|
94
|
-
client = AgentaApi(
|
|
95
|
-
api_key="YOUR_API_KEY",
|
|
96
|
-
base_url="https://yourhost.com/path/to/api",
|
|
97
|
-
)
|
|
98
|
-
client.containers.restart_container(
|
|
99
|
-
variant_id="variant_id",
|
|
100
|
-
)
|
|
101
|
-
"""
|
|
102
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
103
|
-
"POST",
|
|
104
|
-
urllib.parse.urljoin(
|
|
105
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
106
|
-
"containers/restart_container",
|
|
107
|
-
),
|
|
108
|
-
json=jsonable_encoder({"variant_id": variant_id}),
|
|
109
|
-
headers=self._client_wrapper.get_headers(),
|
|
110
|
-
timeout=60,
|
|
111
|
-
)
|
|
112
|
-
if 200 <= _response.status_code < 300:
|
|
113
|
-
return pydantic.parse_obj_as(typing.Dict[str, typing.Any], _response.json()) # type: ignore
|
|
114
|
-
if _response.status_code == 422:
|
|
115
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
116
|
-
try:
|
|
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 container_templates(self) -> ContainerTemplatesResponse:
|
|
123
|
-
"""
|
|
124
|
-
Returns a list of templates available for creating new containers.
|
|
125
|
-
|
|
126
|
-
Parameters:
|
|
127
|
-
stoken_session (SessionContainer): The session container for the user.
|
|
128
|
-
|
|
129
|
-
Returns:
|
|
130
|
-
|
|
131
|
-
Union[List[Template], str]: A list of templates or an error message.
|
|
132
|
-
"""
|
|
133
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
134
|
-
"GET",
|
|
135
|
-
urllib.parse.urljoin(
|
|
136
|
-
f"{self._client_wrapper.get_base_url()}/", "containers/templates"
|
|
137
|
-
),
|
|
138
|
-
headers=self._client_wrapper.get_headers(),
|
|
139
|
-
timeout=60,
|
|
140
|
-
)
|
|
141
|
-
if 200 <= _response.status_code < 300:
|
|
142
|
-
return pydantic.parse_obj_as(ContainerTemplatesResponse, _response.json()) # type: ignore
|
|
143
|
-
try:
|
|
144
|
-
_response_json = _response.json()
|
|
145
|
-
except JSONDecodeError:
|
|
146
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
147
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
148
|
-
|
|
149
|
-
def construct_app_container_url(
|
|
150
|
-
self,
|
|
151
|
-
*,
|
|
152
|
-
base_id: typing.Optional[str] = None,
|
|
153
|
-
variant_id: typing.Optional[str] = None,
|
|
154
|
-
) -> Uri:
|
|
155
|
-
"""
|
|
156
|
-
Constructs the URL for an app container based on the provided base_id or variant_id.
|
|
157
|
-
|
|
158
|
-
Args:
|
|
159
|
-
base_id (Optional[str]): The ID of the base to use for the app container.
|
|
160
|
-
variant_id (Optional[str]): The ID of the variant to use for the app container.
|
|
161
|
-
request (Request): The request object.
|
|
162
|
-
|
|
163
|
-
Returns:
|
|
164
|
-
URI: The URI for the app container.
|
|
165
|
-
|
|
166
|
-
Raises:
|
|
167
|
-
HTTPException: If the base or variant cannot be found or the user does not have access.
|
|
168
|
-
|
|
169
|
-
Parameters:
|
|
170
|
-
- base_id: typing.Optional[str].
|
|
171
|
-
|
|
172
|
-
- variant_id: typing.Optional[str].
|
|
173
|
-
---
|
|
174
|
-
from agenta.client import AgentaApi
|
|
175
|
-
|
|
176
|
-
client = AgentaApi(
|
|
177
|
-
api_key="YOUR_API_KEY",
|
|
178
|
-
base_url="https://yourhost.com/path/to/api",
|
|
179
|
-
)
|
|
180
|
-
client.containers.construct_app_container_url()
|
|
181
|
-
"""
|
|
182
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
183
|
-
"GET",
|
|
184
|
-
urllib.parse.urljoin(
|
|
185
|
-
f"{self._client_wrapper.get_base_url()}/", "containers/container_url"
|
|
186
|
-
),
|
|
187
|
-
params=remove_none_from_dict(
|
|
188
|
-
{"base_id": base_id, "variant_id": variant_id}
|
|
189
|
-
),
|
|
190
|
-
headers=self._client_wrapper.get_headers(),
|
|
191
|
-
timeout=60,
|
|
192
|
-
)
|
|
193
|
-
if 200 <= _response.status_code < 300:
|
|
194
|
-
return pydantic.parse_obj_as(Uri, _response.json()) # type: ignore
|
|
195
|
-
if _response.status_code == 422:
|
|
196
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
197
|
-
try:
|
|
198
|
-
_response_json = _response.json()
|
|
199
|
-
except JSONDecodeError:
|
|
200
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
201
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
class AsyncContainersClient:
|
|
205
|
-
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
206
|
-
self._client_wrapper = client_wrapper
|
|
207
|
-
|
|
208
|
-
async def build_image(
|
|
209
|
-
self, *, app_id: str, base_name: str, tar_file: typing.IO
|
|
210
|
-
) -> Image:
|
|
211
|
-
"""
|
|
212
|
-
Builds a Docker image from a tar file containing the application code.
|
|
213
|
-
|
|
214
|
-
Args:
|
|
215
|
-
app_id (str): The ID of the application to build the image for.
|
|
216
|
-
base_name (str): The base name of the image to build.
|
|
217
|
-
tar_file (UploadFile): The tar file containing the application code.
|
|
218
|
-
stoken_session (SessionContainer): The session container for the user making the request.
|
|
219
|
-
|
|
220
|
-
Returns:
|
|
221
|
-
Image: The Docker image that was built.
|
|
222
|
-
|
|
223
|
-
Parameters:
|
|
224
|
-
- app_id: str.
|
|
225
|
-
|
|
226
|
-
- base_name: str.
|
|
227
|
-
|
|
228
|
-
- tar_file: typing.IO.
|
|
229
|
-
---
|
|
230
|
-
from agenta.client import AsyncAgentaApi
|
|
231
|
-
|
|
232
|
-
client = AsyncAgentaApi(
|
|
233
|
-
api_key="YOUR_API_KEY",
|
|
234
|
-
base_url="https://yourhost.com/path/to/api",
|
|
235
|
-
)
|
|
236
|
-
await client.containers.build_image(
|
|
237
|
-
app_id="app_id",
|
|
238
|
-
base_name="base_name",
|
|
239
|
-
)
|
|
240
|
-
"""
|
|
241
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
242
|
-
"POST",
|
|
243
|
-
urllib.parse.urljoin(
|
|
244
|
-
f"{self._client_wrapper.get_base_url()}/", "containers/build_image"
|
|
245
|
-
),
|
|
246
|
-
params=remove_none_from_dict({"app_id": app_id, "base_name": base_name}),
|
|
247
|
-
data=jsonable_encoder({}),
|
|
248
|
-
files={"tar_file": tar_file},
|
|
249
|
-
headers=self._client_wrapper.get_headers(),
|
|
250
|
-
timeout=600,
|
|
251
|
-
)
|
|
252
|
-
if 200 <= _response.status_code < 300:
|
|
253
|
-
return pydantic.parse_obj_as(Image, _response.json()) # type: ignore
|
|
254
|
-
if _response.status_code == 422:
|
|
255
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
256
|
-
try:
|
|
257
|
-
_response_json = _response.json()
|
|
258
|
-
except JSONDecodeError:
|
|
259
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
260
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
261
|
-
|
|
262
|
-
async def restart_container(
|
|
263
|
-
self, *, variant_id: str
|
|
264
|
-
) -> typing.Dict[str, typing.Any]:
|
|
265
|
-
"""
|
|
266
|
-
Restart docker container.
|
|
267
|
-
|
|
268
|
-
Args:
|
|
269
|
-
payload (RestartAppContainer) -- the required data (app_name and variant_name)
|
|
270
|
-
|
|
271
|
-
Parameters:
|
|
272
|
-
- variant_id: str.
|
|
273
|
-
---
|
|
274
|
-
from agenta.client import AsyncAgentaApi
|
|
275
|
-
|
|
276
|
-
client = AsyncAgentaApi(
|
|
277
|
-
api_key="YOUR_API_KEY",
|
|
278
|
-
base_url="https://yourhost.com/path/to/api",
|
|
279
|
-
)
|
|
280
|
-
await client.containers.restart_container(
|
|
281
|
-
variant_id="variant_id",
|
|
282
|
-
)
|
|
283
|
-
"""
|
|
284
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
285
|
-
"POST",
|
|
286
|
-
urllib.parse.urljoin(
|
|
287
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
288
|
-
"containers/restart_container",
|
|
289
|
-
),
|
|
290
|
-
json=jsonable_encoder({"variant_id": variant_id}),
|
|
291
|
-
headers=self._client_wrapper.get_headers(),
|
|
292
|
-
timeout=60,
|
|
293
|
-
)
|
|
294
|
-
if 200 <= _response.status_code < 300:
|
|
295
|
-
return pydantic.parse_obj_as(typing.Dict[str, typing.Any], _response.json()) # type: ignore
|
|
296
|
-
if _response.status_code == 422:
|
|
297
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
298
|
-
try:
|
|
299
|
-
_response_json = _response.json()
|
|
300
|
-
except JSONDecodeError:
|
|
301
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
302
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
303
|
-
|
|
304
|
-
async def container_templates(self) -> ContainerTemplatesResponse:
|
|
305
|
-
"""
|
|
306
|
-
Returns a list of templates available for creating new containers.
|
|
307
|
-
|
|
308
|
-
Parameters:
|
|
309
|
-
stoken_session (SessionContainer): The session container for the user.
|
|
310
|
-
|
|
311
|
-
Returns:
|
|
312
|
-
|
|
313
|
-
Union[List[Template], str]: A list of templates or an error message.
|
|
314
|
-
"""
|
|
315
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
316
|
-
"GET",
|
|
317
|
-
urllib.parse.urljoin(
|
|
318
|
-
f"{self._client_wrapper.get_base_url()}/", "containers/templates"
|
|
319
|
-
),
|
|
320
|
-
headers=self._client_wrapper.get_headers(),
|
|
321
|
-
timeout=60,
|
|
322
|
-
)
|
|
323
|
-
if 200 <= _response.status_code < 300:
|
|
324
|
-
return pydantic.parse_obj_as(ContainerTemplatesResponse, _response.json()) # type: ignore
|
|
325
|
-
try:
|
|
326
|
-
_response_json = _response.json()
|
|
327
|
-
except JSONDecodeError:
|
|
328
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
329
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
330
|
-
|
|
331
|
-
async def construct_app_container_url(
|
|
332
|
-
self,
|
|
333
|
-
*,
|
|
334
|
-
base_id: typing.Optional[str] = None,
|
|
335
|
-
variant_id: typing.Optional[str] = None,
|
|
336
|
-
) -> Uri:
|
|
337
|
-
"""
|
|
338
|
-
Constructs the URL for an app container based on the provided base_id or variant_id.
|
|
339
|
-
|
|
340
|
-
Args:
|
|
341
|
-
base_id (Optional[str]): The ID of the base to use for the app container.
|
|
342
|
-
variant_id (Optional[str]): The ID of the variant to use for the app container.
|
|
343
|
-
request (Request): The request object.
|
|
344
|
-
|
|
345
|
-
Returns:
|
|
346
|
-
URI: The URI for the app container.
|
|
347
|
-
|
|
348
|
-
Raises:
|
|
349
|
-
HTTPException: If the base or variant cannot be found or the user does not have access.
|
|
350
|
-
|
|
351
|
-
Parameters:
|
|
352
|
-
- base_id: typing.Optional[str].
|
|
353
|
-
|
|
354
|
-
- variant_id: typing.Optional[str].
|
|
355
|
-
---
|
|
356
|
-
from agenta.client import AsyncAgentaApi
|
|
357
|
-
|
|
358
|
-
client = AsyncAgentaApi(
|
|
359
|
-
api_key="YOUR_API_KEY",
|
|
360
|
-
base_url="https://yourhost.com/path/to/api",
|
|
361
|
-
)
|
|
362
|
-
await client.containers.construct_app_container_url()
|
|
363
|
-
"""
|
|
364
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
365
|
-
"GET",
|
|
366
|
-
urllib.parse.urljoin(
|
|
367
|
-
f"{self._client_wrapper.get_base_url()}/", "containers/container_url"
|
|
368
|
-
),
|
|
369
|
-
params=remove_none_from_dict(
|
|
370
|
-
{"base_id": base_id, "variant_id": variant_id}
|
|
371
|
-
),
|
|
372
|
-
headers=self._client_wrapper.get_headers(),
|
|
373
|
-
timeout=60,
|
|
374
|
-
)
|
|
375
|
-
if 200 <= _response.status_code < 300:
|
|
376
|
-
return pydantic.parse_obj_as(Uri, _response.json()) # type: ignore
|
|
377
|
-
if _response.status_code == 422:
|
|
378
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
379
|
-
try:
|
|
380
|
-
_response_json = _response.json()
|
|
381
|
-
except JSONDecodeError:
|
|
382
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
383
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
-
|
|
3
|
-
import typing
|
|
4
|
-
import urllib.parse
|
|
5
|
-
from json.decoder import JSONDecodeError
|
|
6
|
-
|
|
7
|
-
from ...core.api_error import ApiError
|
|
8
|
-
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
-
from ...core.jsonable_encoder import jsonable_encoder
|
|
10
|
-
from ...errors.unprocessable_entity_error import UnprocessableEntityError
|
|
11
|
-
from ...types.http_validation_error import HttpValidationError
|
|
12
|
-
|
|
13
|
-
try:
|
|
14
|
-
import pydantic.v1 as pydantic # type: ignore
|
|
15
|
-
except ImportError:
|
|
16
|
-
import pydantic # type: ignore
|
|
17
|
-
|
|
18
|
-
# this is used as the default value for optional parameters
|
|
19
|
-
OMIT = typing.cast(typing.Any, ...)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class EnvironmentsClient:
|
|
23
|
-
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
24
|
-
self._client_wrapper = client_wrapper
|
|
25
|
-
|
|
26
|
-
def deploy_to_environment(
|
|
27
|
-
self, *, environment_name: str, variant_id: str
|
|
28
|
-
) -> typing.Any:
|
|
29
|
-
"""
|
|
30
|
-
Deploys a given variant to an environment
|
|
31
|
-
|
|
32
|
-
Args:
|
|
33
|
-
environment_name: Name of the environment to deploy to.
|
|
34
|
-
variant_id: variant id to deploy.
|
|
35
|
-
stoken_session: . Defaults to Depends(verify_session()).
|
|
36
|
-
|
|
37
|
-
Raises:
|
|
38
|
-
HTTPException: If the deployment fails.
|
|
39
|
-
|
|
40
|
-
Parameters:
|
|
41
|
-
- environment_name: str.
|
|
42
|
-
|
|
43
|
-
- variant_id: str.
|
|
44
|
-
---
|
|
45
|
-
from agenta.client import AgentaApi
|
|
46
|
-
|
|
47
|
-
client = AgentaApi(
|
|
48
|
-
api_key="YOUR_API_KEY",
|
|
49
|
-
base_url="https://yourhost.com/path/to/api",
|
|
50
|
-
)
|
|
51
|
-
client.environments.deploy_to_environment(
|
|
52
|
-
environment_name="environment_name",
|
|
53
|
-
variant_id="variant_id",
|
|
54
|
-
)
|
|
55
|
-
"""
|
|
56
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
57
|
-
"POST",
|
|
58
|
-
urllib.parse.urljoin(
|
|
59
|
-
f"{self._client_wrapper.get_base_url()}/", "environments/deploy"
|
|
60
|
-
),
|
|
61
|
-
json=jsonable_encoder(
|
|
62
|
-
{"environment_name": environment_name, "variant_id": variant_id}
|
|
63
|
-
),
|
|
64
|
-
headers=self._client_wrapper.get_headers(),
|
|
65
|
-
timeout=60,
|
|
66
|
-
)
|
|
67
|
-
if 200 <= _response.status_code < 300:
|
|
68
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
69
|
-
if _response.status_code == 422:
|
|
70
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
71
|
-
try:
|
|
72
|
-
_response_json = _response.json()
|
|
73
|
-
except JSONDecodeError:
|
|
74
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
75
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
class AsyncEnvironmentsClient:
|
|
79
|
-
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
80
|
-
self._client_wrapper = client_wrapper
|
|
81
|
-
|
|
82
|
-
async def deploy_to_environment(
|
|
83
|
-
self, *, environment_name: str, variant_id: str
|
|
84
|
-
) -> typing.Any:
|
|
85
|
-
"""
|
|
86
|
-
Deploys a given variant to an environment
|
|
87
|
-
|
|
88
|
-
Args:
|
|
89
|
-
environment_name: Name of the environment to deploy to.
|
|
90
|
-
variant_id: variant id to deploy.
|
|
91
|
-
stoken_session: . Defaults to Depends(verify_session()).
|
|
92
|
-
|
|
93
|
-
Raises:
|
|
94
|
-
HTTPException: If the deployment fails.
|
|
95
|
-
|
|
96
|
-
Parameters:
|
|
97
|
-
- environment_name: str.
|
|
98
|
-
|
|
99
|
-
- variant_id: str.
|
|
100
|
-
---
|
|
101
|
-
from agenta.client import AsyncAgentaApi
|
|
102
|
-
|
|
103
|
-
client = AsyncAgentaApi(
|
|
104
|
-
api_key="YOUR_API_KEY",
|
|
105
|
-
base_url="https://yourhost.com/path/to/api",
|
|
106
|
-
)
|
|
107
|
-
await client.environments.deploy_to_environment(
|
|
108
|
-
environment_name="environment_name",
|
|
109
|
-
variant_id="variant_id",
|
|
110
|
-
)
|
|
111
|
-
"""
|
|
112
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
113
|
-
"POST",
|
|
114
|
-
urllib.parse.urljoin(
|
|
115
|
-
f"{self._client_wrapper.get_base_url()}/", "environments/deploy"
|
|
116
|
-
),
|
|
117
|
-
json=jsonable_encoder(
|
|
118
|
-
{"environment_name": environment_name, "variant_id": variant_id}
|
|
119
|
-
),
|
|
120
|
-
headers=self._client_wrapper.get_headers(),
|
|
121
|
-
timeout=60,
|
|
122
|
-
)
|
|
123
|
-
if 200 <= _response.status_code < 300:
|
|
124
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
125
|
-
if _response.status_code == 422:
|
|
126
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
127
|
-
try:
|
|
128
|
-
_response_json = _response.json()
|
|
129
|
-
except JSONDecodeError:
|
|
130
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
131
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|