agenta 0.30.0a2__py3-none-any.whl → 0.30.0a4__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/__init__.py +1 -0
- agenta/client/backend/__init__.py +32 -3
- agenta/client/backend/access_control/__init__.py +1 -0
- agenta/client/backend/access_control/client.py +167 -0
- agenta/client/backend/apps/client.py +70 -10
- agenta/client/backend/client.py +61 -45
- agenta/client/backend/configs/client.py +6 -0
- agenta/client/backend/containers/client.py +6 -0
- agenta/client/backend/core/file.py +13 -8
- agenta/client/backend/environments/client.py +6 -0
- agenta/client/backend/evaluations/client.py +14 -1
- agenta/client/backend/evaluators/client.py +24 -0
- agenta/client/backend/observability/client.py +22 -16
- agenta/client/backend/observability_v_1/__init__.py +2 -2
- agenta/client/backend/observability_v_1/client.py +203 -0
- agenta/client/backend/observability_v_1/types/__init__.py +2 -1
- agenta/client/backend/observability_v_1/types/format.py +1 -1
- agenta/client/backend/observability_v_1/types/query_analytics_response.py +7 -0
- agenta/client/backend/scopes/__init__.py +1 -0
- agenta/client/backend/scopes/client.py +114 -0
- agenta/client/backend/testsets/client.py +305 -121
- agenta/client/backend/types/__init__.py +24 -2
- agenta/client/backend/types/analytics_response.py +24 -0
- agenta/client/backend/types/app.py +2 -1
- agenta/client/backend/types/body_import_testset.py +0 -1
- agenta/client/backend/types/bucket_dto.py +26 -0
- agenta/client/backend/types/header_dto.py +22 -0
- agenta/client/backend/types/legacy_analytics_response.py +29 -0
- agenta/client/backend/types/legacy_data_point.py +27 -0
- agenta/client/backend/types/metrics_dto.py +24 -0
- agenta/client/backend/types/permission.py +1 -0
- agenta/client/backend/types/projects_response.py +28 -0
- agenta/client/backend/types/provider_key_dto.py +23 -0
- agenta/client/backend/types/provider_kind.py +21 -0
- agenta/client/backend/types/secret_dto.py +24 -0
- agenta/client/backend/types/secret_kind.py +5 -0
- agenta/client/backend/types/secret_response_dto.py +27 -0
- agenta/client/backend/variants/client.py +66 -0
- agenta/client/backend/vault/__init__.py +1 -0
- agenta/client/backend/vault/client.py +685 -0
- agenta/client/client.py +1 -1
- agenta/sdk/__init__.py +1 -0
- agenta/sdk/agenta_init.py +47 -118
- agenta/sdk/assets.py +57 -46
- agenta/sdk/context/exporting.py +25 -0
- agenta/sdk/context/routing.py +12 -12
- agenta/sdk/context/tracing.py +26 -1
- agenta/sdk/decorators/routing.py +279 -243
- agenta/sdk/decorators/tracing.py +53 -31
- agenta/sdk/managers/config.py +8 -118
- agenta/sdk/managers/secrets.py +38 -0
- agenta/sdk/middleware/auth.py +128 -93
- agenta/sdk/middleware/cache.py +4 -0
- agenta/sdk/middleware/config.py +254 -0
- agenta/sdk/middleware/cors.py +28 -0
- agenta/sdk/middleware/otel.py +40 -0
- agenta/sdk/middleware/vault.py +158 -0
- agenta/sdk/tracing/exporters.py +40 -2
- agenta/sdk/tracing/inline.py +2 -2
- agenta/sdk/tracing/processors.py +11 -3
- agenta/sdk/tracing/tracing.py +14 -12
- agenta/sdk/utils/constants.py +1 -0
- agenta/sdk/utils/exceptions.py +20 -19
- agenta/sdk/utils/globals.py +4 -8
- agenta/sdk/utils/timing.py +58 -0
- {agenta-0.30.0a2.dist-info → agenta-0.30.0a4.dist-info}/METADATA +3 -2
- {agenta-0.30.0a2.dist-info → agenta-0.30.0a4.dist-info}/RECORD +69 -44
- {agenta-0.30.0a2.dist-info → agenta-0.30.0a4.dist-info}/WHEEL +1 -1
- agenta/client/backend/types/lm_providers_enum.py +0 -21
- agenta/sdk/tracing/context.py +0 -24
- {agenta-0.30.0a2.dist-info → agenta-0.30.0a4.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,685 @@
|
|
|
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.secret_response_dto import SecretResponseDto
|
|
7
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
8
|
+
from json.decoder import JSONDecodeError
|
|
9
|
+
from ..core.api_error import ApiError
|
|
10
|
+
from ..types.secret_dto import SecretDto
|
|
11
|
+
from ..types.header_dto import HeaderDto
|
|
12
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
13
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
14
|
+
from ..types.http_validation_error import HttpValidationError
|
|
15
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
16
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
17
|
+
|
|
18
|
+
# this is used as the default value for optional parameters
|
|
19
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class VaultClient:
|
|
23
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
24
|
+
self._client_wrapper = client_wrapper
|
|
25
|
+
|
|
26
|
+
def list_secrets(
|
|
27
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
28
|
+
) -> typing.List[SecretResponseDto]:
|
|
29
|
+
"""
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
request_options : typing.Optional[RequestOptions]
|
|
33
|
+
Request-specific configuration.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
typing.List[SecretResponseDto]
|
|
38
|
+
Successful Response
|
|
39
|
+
|
|
40
|
+
Examples
|
|
41
|
+
--------
|
|
42
|
+
from agenta import AgentaApi
|
|
43
|
+
|
|
44
|
+
client = AgentaApi(
|
|
45
|
+
api_key="YOUR_API_KEY",
|
|
46
|
+
base_url="https://yourhost.com/path/to/api",
|
|
47
|
+
)
|
|
48
|
+
client.vault.list_secrets()
|
|
49
|
+
"""
|
|
50
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
51
|
+
"vault/v1/secrets",
|
|
52
|
+
method="GET",
|
|
53
|
+
request_options=request_options,
|
|
54
|
+
)
|
|
55
|
+
try:
|
|
56
|
+
if 200 <= _response.status_code < 300:
|
|
57
|
+
return typing.cast(
|
|
58
|
+
typing.List[SecretResponseDto],
|
|
59
|
+
parse_obj_as(
|
|
60
|
+
type_=typing.List[SecretResponseDto], # type: ignore
|
|
61
|
+
object_=_response.json(),
|
|
62
|
+
),
|
|
63
|
+
)
|
|
64
|
+
_response_json = _response.json()
|
|
65
|
+
except JSONDecodeError:
|
|
66
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
67
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
68
|
+
|
|
69
|
+
def create_secret(
|
|
70
|
+
self,
|
|
71
|
+
*,
|
|
72
|
+
secret: SecretDto,
|
|
73
|
+
header: typing.Optional[HeaderDto] = OMIT,
|
|
74
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
75
|
+
) -> SecretResponseDto:
|
|
76
|
+
"""
|
|
77
|
+
Parameters
|
|
78
|
+
----------
|
|
79
|
+
secret : SecretDto
|
|
80
|
+
|
|
81
|
+
header : typing.Optional[HeaderDto]
|
|
82
|
+
|
|
83
|
+
request_options : typing.Optional[RequestOptions]
|
|
84
|
+
Request-specific configuration.
|
|
85
|
+
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
88
|
+
SecretResponseDto
|
|
89
|
+
Successful Response
|
|
90
|
+
|
|
91
|
+
Examples
|
|
92
|
+
--------
|
|
93
|
+
from agenta import AgentaApi, ProviderKeyDto, SecretDto
|
|
94
|
+
|
|
95
|
+
client = AgentaApi(
|
|
96
|
+
api_key="YOUR_API_KEY",
|
|
97
|
+
base_url="https://yourhost.com/path/to/api",
|
|
98
|
+
)
|
|
99
|
+
client.vault.create_secret(
|
|
100
|
+
secret=SecretDto(
|
|
101
|
+
data=ProviderKeyDto(
|
|
102
|
+
provider="openai",
|
|
103
|
+
key="key",
|
|
104
|
+
),
|
|
105
|
+
),
|
|
106
|
+
)
|
|
107
|
+
"""
|
|
108
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
109
|
+
"vault/v1/secrets",
|
|
110
|
+
method="POST",
|
|
111
|
+
json={
|
|
112
|
+
"header": convert_and_respect_annotation_metadata(
|
|
113
|
+
object_=header, annotation=HeaderDto, direction="write"
|
|
114
|
+
),
|
|
115
|
+
"secret": convert_and_respect_annotation_metadata(
|
|
116
|
+
object_=secret, annotation=SecretDto, direction="write"
|
|
117
|
+
),
|
|
118
|
+
},
|
|
119
|
+
headers={
|
|
120
|
+
"content-type": "application/json",
|
|
121
|
+
},
|
|
122
|
+
request_options=request_options,
|
|
123
|
+
omit=OMIT,
|
|
124
|
+
)
|
|
125
|
+
try:
|
|
126
|
+
if 200 <= _response.status_code < 300:
|
|
127
|
+
return typing.cast(
|
|
128
|
+
SecretResponseDto,
|
|
129
|
+
parse_obj_as(
|
|
130
|
+
type_=SecretResponseDto, # type: ignore
|
|
131
|
+
object_=_response.json(),
|
|
132
|
+
),
|
|
133
|
+
)
|
|
134
|
+
if _response.status_code == 422:
|
|
135
|
+
raise UnprocessableEntityError(
|
|
136
|
+
typing.cast(
|
|
137
|
+
HttpValidationError,
|
|
138
|
+
parse_obj_as(
|
|
139
|
+
type_=HttpValidationError, # type: ignore
|
|
140
|
+
object_=_response.json(),
|
|
141
|
+
),
|
|
142
|
+
)
|
|
143
|
+
)
|
|
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 read_secret(
|
|
150
|
+
self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
151
|
+
) -> SecretResponseDto:
|
|
152
|
+
"""
|
|
153
|
+
Parameters
|
|
154
|
+
----------
|
|
155
|
+
secret_id : str
|
|
156
|
+
|
|
157
|
+
request_options : typing.Optional[RequestOptions]
|
|
158
|
+
Request-specific configuration.
|
|
159
|
+
|
|
160
|
+
Returns
|
|
161
|
+
-------
|
|
162
|
+
SecretResponseDto
|
|
163
|
+
Successful Response
|
|
164
|
+
|
|
165
|
+
Examples
|
|
166
|
+
--------
|
|
167
|
+
from agenta import AgentaApi
|
|
168
|
+
|
|
169
|
+
client = AgentaApi(
|
|
170
|
+
api_key="YOUR_API_KEY",
|
|
171
|
+
base_url="https://yourhost.com/path/to/api",
|
|
172
|
+
)
|
|
173
|
+
client.vault.read_secret(
|
|
174
|
+
secret_id="secret_id",
|
|
175
|
+
)
|
|
176
|
+
"""
|
|
177
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
178
|
+
f"vault/v1/secrets/{jsonable_encoder(secret_id)}",
|
|
179
|
+
method="GET",
|
|
180
|
+
request_options=request_options,
|
|
181
|
+
)
|
|
182
|
+
try:
|
|
183
|
+
if 200 <= _response.status_code < 300:
|
|
184
|
+
return typing.cast(
|
|
185
|
+
SecretResponseDto,
|
|
186
|
+
parse_obj_as(
|
|
187
|
+
type_=SecretResponseDto, # type: ignore
|
|
188
|
+
object_=_response.json(),
|
|
189
|
+
),
|
|
190
|
+
)
|
|
191
|
+
if _response.status_code == 422:
|
|
192
|
+
raise UnprocessableEntityError(
|
|
193
|
+
typing.cast(
|
|
194
|
+
HttpValidationError,
|
|
195
|
+
parse_obj_as(
|
|
196
|
+
type_=HttpValidationError, # type: ignore
|
|
197
|
+
object_=_response.json(),
|
|
198
|
+
),
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
_response_json = _response.json()
|
|
202
|
+
except JSONDecodeError:
|
|
203
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
204
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
205
|
+
|
|
206
|
+
def update_secret(
|
|
207
|
+
self,
|
|
208
|
+
secret_id: str,
|
|
209
|
+
*,
|
|
210
|
+
header: typing.Optional[HeaderDto] = OMIT,
|
|
211
|
+
secret: typing.Optional[SecretDto] = OMIT,
|
|
212
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
213
|
+
) -> SecretResponseDto:
|
|
214
|
+
"""
|
|
215
|
+
Parameters
|
|
216
|
+
----------
|
|
217
|
+
secret_id : str
|
|
218
|
+
|
|
219
|
+
header : typing.Optional[HeaderDto]
|
|
220
|
+
|
|
221
|
+
secret : typing.Optional[SecretDto]
|
|
222
|
+
|
|
223
|
+
request_options : typing.Optional[RequestOptions]
|
|
224
|
+
Request-specific configuration.
|
|
225
|
+
|
|
226
|
+
Returns
|
|
227
|
+
-------
|
|
228
|
+
SecretResponseDto
|
|
229
|
+
Successful Response
|
|
230
|
+
|
|
231
|
+
Examples
|
|
232
|
+
--------
|
|
233
|
+
from agenta import AgentaApi
|
|
234
|
+
|
|
235
|
+
client = AgentaApi(
|
|
236
|
+
api_key="YOUR_API_KEY",
|
|
237
|
+
base_url="https://yourhost.com/path/to/api",
|
|
238
|
+
)
|
|
239
|
+
client.vault.update_secret(
|
|
240
|
+
secret_id="secret_id",
|
|
241
|
+
)
|
|
242
|
+
"""
|
|
243
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
244
|
+
f"vault/v1/secrets/{jsonable_encoder(secret_id)}",
|
|
245
|
+
method="PUT",
|
|
246
|
+
json={
|
|
247
|
+
"header": convert_and_respect_annotation_metadata(
|
|
248
|
+
object_=header, annotation=HeaderDto, direction="write"
|
|
249
|
+
),
|
|
250
|
+
"secret": convert_and_respect_annotation_metadata(
|
|
251
|
+
object_=secret, annotation=SecretDto, direction="write"
|
|
252
|
+
),
|
|
253
|
+
},
|
|
254
|
+
headers={
|
|
255
|
+
"content-type": "application/json",
|
|
256
|
+
},
|
|
257
|
+
request_options=request_options,
|
|
258
|
+
omit=OMIT,
|
|
259
|
+
)
|
|
260
|
+
try:
|
|
261
|
+
if 200 <= _response.status_code < 300:
|
|
262
|
+
return typing.cast(
|
|
263
|
+
SecretResponseDto,
|
|
264
|
+
parse_obj_as(
|
|
265
|
+
type_=SecretResponseDto, # type: ignore
|
|
266
|
+
object_=_response.json(),
|
|
267
|
+
),
|
|
268
|
+
)
|
|
269
|
+
if _response.status_code == 422:
|
|
270
|
+
raise UnprocessableEntityError(
|
|
271
|
+
typing.cast(
|
|
272
|
+
HttpValidationError,
|
|
273
|
+
parse_obj_as(
|
|
274
|
+
type_=HttpValidationError, # type: ignore
|
|
275
|
+
object_=_response.json(),
|
|
276
|
+
),
|
|
277
|
+
)
|
|
278
|
+
)
|
|
279
|
+
_response_json = _response.json()
|
|
280
|
+
except JSONDecodeError:
|
|
281
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
282
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
283
|
+
|
|
284
|
+
def delete_secret(
|
|
285
|
+
self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
286
|
+
) -> None:
|
|
287
|
+
"""
|
|
288
|
+
Parameters
|
|
289
|
+
----------
|
|
290
|
+
secret_id : str
|
|
291
|
+
|
|
292
|
+
request_options : typing.Optional[RequestOptions]
|
|
293
|
+
Request-specific configuration.
|
|
294
|
+
|
|
295
|
+
Returns
|
|
296
|
+
-------
|
|
297
|
+
None
|
|
298
|
+
|
|
299
|
+
Examples
|
|
300
|
+
--------
|
|
301
|
+
from agenta import AgentaApi
|
|
302
|
+
|
|
303
|
+
client = AgentaApi(
|
|
304
|
+
api_key="YOUR_API_KEY",
|
|
305
|
+
base_url="https://yourhost.com/path/to/api",
|
|
306
|
+
)
|
|
307
|
+
client.vault.delete_secret(
|
|
308
|
+
secret_id="secret_id",
|
|
309
|
+
)
|
|
310
|
+
"""
|
|
311
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
312
|
+
f"vault/v1/secrets/{jsonable_encoder(secret_id)}",
|
|
313
|
+
method="DELETE",
|
|
314
|
+
request_options=request_options,
|
|
315
|
+
)
|
|
316
|
+
try:
|
|
317
|
+
if 200 <= _response.status_code < 300:
|
|
318
|
+
return
|
|
319
|
+
if _response.status_code == 422:
|
|
320
|
+
raise UnprocessableEntityError(
|
|
321
|
+
typing.cast(
|
|
322
|
+
HttpValidationError,
|
|
323
|
+
parse_obj_as(
|
|
324
|
+
type_=HttpValidationError, # type: ignore
|
|
325
|
+
object_=_response.json(),
|
|
326
|
+
),
|
|
327
|
+
)
|
|
328
|
+
)
|
|
329
|
+
_response_json = _response.json()
|
|
330
|
+
except JSONDecodeError:
|
|
331
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
332
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
class AsyncVaultClient:
|
|
336
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
337
|
+
self._client_wrapper = client_wrapper
|
|
338
|
+
|
|
339
|
+
async def list_secrets(
|
|
340
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
341
|
+
) -> typing.List[SecretResponseDto]:
|
|
342
|
+
"""
|
|
343
|
+
Parameters
|
|
344
|
+
----------
|
|
345
|
+
request_options : typing.Optional[RequestOptions]
|
|
346
|
+
Request-specific configuration.
|
|
347
|
+
|
|
348
|
+
Returns
|
|
349
|
+
-------
|
|
350
|
+
typing.List[SecretResponseDto]
|
|
351
|
+
Successful Response
|
|
352
|
+
|
|
353
|
+
Examples
|
|
354
|
+
--------
|
|
355
|
+
import asyncio
|
|
356
|
+
|
|
357
|
+
from agenta import AsyncAgentaApi
|
|
358
|
+
|
|
359
|
+
client = AsyncAgentaApi(
|
|
360
|
+
api_key="YOUR_API_KEY",
|
|
361
|
+
base_url="https://yourhost.com/path/to/api",
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
async def main() -> None:
|
|
366
|
+
await client.vault.list_secrets()
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
asyncio.run(main())
|
|
370
|
+
"""
|
|
371
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
372
|
+
"vault/v1/secrets",
|
|
373
|
+
method="GET",
|
|
374
|
+
request_options=request_options,
|
|
375
|
+
)
|
|
376
|
+
try:
|
|
377
|
+
if 200 <= _response.status_code < 300:
|
|
378
|
+
return typing.cast(
|
|
379
|
+
typing.List[SecretResponseDto],
|
|
380
|
+
parse_obj_as(
|
|
381
|
+
type_=typing.List[SecretResponseDto], # type: ignore
|
|
382
|
+
object_=_response.json(),
|
|
383
|
+
),
|
|
384
|
+
)
|
|
385
|
+
_response_json = _response.json()
|
|
386
|
+
except JSONDecodeError:
|
|
387
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
388
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
389
|
+
|
|
390
|
+
async def create_secret(
|
|
391
|
+
self,
|
|
392
|
+
*,
|
|
393
|
+
secret: SecretDto,
|
|
394
|
+
header: typing.Optional[HeaderDto] = OMIT,
|
|
395
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
396
|
+
) -> SecretResponseDto:
|
|
397
|
+
"""
|
|
398
|
+
Parameters
|
|
399
|
+
----------
|
|
400
|
+
secret : SecretDto
|
|
401
|
+
|
|
402
|
+
header : typing.Optional[HeaderDto]
|
|
403
|
+
|
|
404
|
+
request_options : typing.Optional[RequestOptions]
|
|
405
|
+
Request-specific configuration.
|
|
406
|
+
|
|
407
|
+
Returns
|
|
408
|
+
-------
|
|
409
|
+
SecretResponseDto
|
|
410
|
+
Successful Response
|
|
411
|
+
|
|
412
|
+
Examples
|
|
413
|
+
--------
|
|
414
|
+
import asyncio
|
|
415
|
+
|
|
416
|
+
from agenta import AsyncAgentaApi, ProviderKeyDto, SecretDto
|
|
417
|
+
|
|
418
|
+
client = AsyncAgentaApi(
|
|
419
|
+
api_key="YOUR_API_KEY",
|
|
420
|
+
base_url="https://yourhost.com/path/to/api",
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
async def main() -> None:
|
|
425
|
+
await client.vault.create_secret(
|
|
426
|
+
secret=SecretDto(
|
|
427
|
+
data=ProviderKeyDto(
|
|
428
|
+
provider="openai",
|
|
429
|
+
key="key",
|
|
430
|
+
),
|
|
431
|
+
),
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
asyncio.run(main())
|
|
436
|
+
"""
|
|
437
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
438
|
+
"vault/v1/secrets",
|
|
439
|
+
method="POST",
|
|
440
|
+
json={
|
|
441
|
+
"header": convert_and_respect_annotation_metadata(
|
|
442
|
+
object_=header, annotation=HeaderDto, direction="write"
|
|
443
|
+
),
|
|
444
|
+
"secret": convert_and_respect_annotation_metadata(
|
|
445
|
+
object_=secret, annotation=SecretDto, direction="write"
|
|
446
|
+
),
|
|
447
|
+
},
|
|
448
|
+
headers={
|
|
449
|
+
"content-type": "application/json",
|
|
450
|
+
},
|
|
451
|
+
request_options=request_options,
|
|
452
|
+
omit=OMIT,
|
|
453
|
+
)
|
|
454
|
+
try:
|
|
455
|
+
if 200 <= _response.status_code < 300:
|
|
456
|
+
return typing.cast(
|
|
457
|
+
SecretResponseDto,
|
|
458
|
+
parse_obj_as(
|
|
459
|
+
type_=SecretResponseDto, # type: ignore
|
|
460
|
+
object_=_response.json(),
|
|
461
|
+
),
|
|
462
|
+
)
|
|
463
|
+
if _response.status_code == 422:
|
|
464
|
+
raise UnprocessableEntityError(
|
|
465
|
+
typing.cast(
|
|
466
|
+
HttpValidationError,
|
|
467
|
+
parse_obj_as(
|
|
468
|
+
type_=HttpValidationError, # type: ignore
|
|
469
|
+
object_=_response.json(),
|
|
470
|
+
),
|
|
471
|
+
)
|
|
472
|
+
)
|
|
473
|
+
_response_json = _response.json()
|
|
474
|
+
except JSONDecodeError:
|
|
475
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
476
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
477
|
+
|
|
478
|
+
async def read_secret(
|
|
479
|
+
self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
480
|
+
) -> SecretResponseDto:
|
|
481
|
+
"""
|
|
482
|
+
Parameters
|
|
483
|
+
----------
|
|
484
|
+
secret_id : str
|
|
485
|
+
|
|
486
|
+
request_options : typing.Optional[RequestOptions]
|
|
487
|
+
Request-specific configuration.
|
|
488
|
+
|
|
489
|
+
Returns
|
|
490
|
+
-------
|
|
491
|
+
SecretResponseDto
|
|
492
|
+
Successful Response
|
|
493
|
+
|
|
494
|
+
Examples
|
|
495
|
+
--------
|
|
496
|
+
import asyncio
|
|
497
|
+
|
|
498
|
+
from agenta import AsyncAgentaApi
|
|
499
|
+
|
|
500
|
+
client = AsyncAgentaApi(
|
|
501
|
+
api_key="YOUR_API_KEY",
|
|
502
|
+
base_url="https://yourhost.com/path/to/api",
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
async def main() -> None:
|
|
507
|
+
await client.vault.read_secret(
|
|
508
|
+
secret_id="secret_id",
|
|
509
|
+
)
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
asyncio.run(main())
|
|
513
|
+
"""
|
|
514
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
515
|
+
f"vault/v1/secrets/{jsonable_encoder(secret_id)}",
|
|
516
|
+
method="GET",
|
|
517
|
+
request_options=request_options,
|
|
518
|
+
)
|
|
519
|
+
try:
|
|
520
|
+
if 200 <= _response.status_code < 300:
|
|
521
|
+
return typing.cast(
|
|
522
|
+
SecretResponseDto,
|
|
523
|
+
parse_obj_as(
|
|
524
|
+
type_=SecretResponseDto, # type: ignore
|
|
525
|
+
object_=_response.json(),
|
|
526
|
+
),
|
|
527
|
+
)
|
|
528
|
+
if _response.status_code == 422:
|
|
529
|
+
raise UnprocessableEntityError(
|
|
530
|
+
typing.cast(
|
|
531
|
+
HttpValidationError,
|
|
532
|
+
parse_obj_as(
|
|
533
|
+
type_=HttpValidationError, # type: ignore
|
|
534
|
+
object_=_response.json(),
|
|
535
|
+
),
|
|
536
|
+
)
|
|
537
|
+
)
|
|
538
|
+
_response_json = _response.json()
|
|
539
|
+
except JSONDecodeError:
|
|
540
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
541
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
542
|
+
|
|
543
|
+
async def update_secret(
|
|
544
|
+
self,
|
|
545
|
+
secret_id: str,
|
|
546
|
+
*,
|
|
547
|
+
header: typing.Optional[HeaderDto] = OMIT,
|
|
548
|
+
secret: typing.Optional[SecretDto] = OMIT,
|
|
549
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
550
|
+
) -> SecretResponseDto:
|
|
551
|
+
"""
|
|
552
|
+
Parameters
|
|
553
|
+
----------
|
|
554
|
+
secret_id : str
|
|
555
|
+
|
|
556
|
+
header : typing.Optional[HeaderDto]
|
|
557
|
+
|
|
558
|
+
secret : typing.Optional[SecretDto]
|
|
559
|
+
|
|
560
|
+
request_options : typing.Optional[RequestOptions]
|
|
561
|
+
Request-specific configuration.
|
|
562
|
+
|
|
563
|
+
Returns
|
|
564
|
+
-------
|
|
565
|
+
SecretResponseDto
|
|
566
|
+
Successful Response
|
|
567
|
+
|
|
568
|
+
Examples
|
|
569
|
+
--------
|
|
570
|
+
import asyncio
|
|
571
|
+
|
|
572
|
+
from agenta import AsyncAgentaApi
|
|
573
|
+
|
|
574
|
+
client = AsyncAgentaApi(
|
|
575
|
+
api_key="YOUR_API_KEY",
|
|
576
|
+
base_url="https://yourhost.com/path/to/api",
|
|
577
|
+
)
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
async def main() -> None:
|
|
581
|
+
await client.vault.update_secret(
|
|
582
|
+
secret_id="secret_id",
|
|
583
|
+
)
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
asyncio.run(main())
|
|
587
|
+
"""
|
|
588
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
589
|
+
f"vault/v1/secrets/{jsonable_encoder(secret_id)}",
|
|
590
|
+
method="PUT",
|
|
591
|
+
json={
|
|
592
|
+
"header": convert_and_respect_annotation_metadata(
|
|
593
|
+
object_=header, annotation=HeaderDto, direction="write"
|
|
594
|
+
),
|
|
595
|
+
"secret": convert_and_respect_annotation_metadata(
|
|
596
|
+
object_=secret, annotation=SecretDto, direction="write"
|
|
597
|
+
),
|
|
598
|
+
},
|
|
599
|
+
headers={
|
|
600
|
+
"content-type": "application/json",
|
|
601
|
+
},
|
|
602
|
+
request_options=request_options,
|
|
603
|
+
omit=OMIT,
|
|
604
|
+
)
|
|
605
|
+
try:
|
|
606
|
+
if 200 <= _response.status_code < 300:
|
|
607
|
+
return typing.cast(
|
|
608
|
+
SecretResponseDto,
|
|
609
|
+
parse_obj_as(
|
|
610
|
+
type_=SecretResponseDto, # type: ignore
|
|
611
|
+
object_=_response.json(),
|
|
612
|
+
),
|
|
613
|
+
)
|
|
614
|
+
if _response.status_code == 422:
|
|
615
|
+
raise UnprocessableEntityError(
|
|
616
|
+
typing.cast(
|
|
617
|
+
HttpValidationError,
|
|
618
|
+
parse_obj_as(
|
|
619
|
+
type_=HttpValidationError, # type: ignore
|
|
620
|
+
object_=_response.json(),
|
|
621
|
+
),
|
|
622
|
+
)
|
|
623
|
+
)
|
|
624
|
+
_response_json = _response.json()
|
|
625
|
+
except JSONDecodeError:
|
|
626
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
627
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
628
|
+
|
|
629
|
+
async def delete_secret(
|
|
630
|
+
self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
631
|
+
) -> None:
|
|
632
|
+
"""
|
|
633
|
+
Parameters
|
|
634
|
+
----------
|
|
635
|
+
secret_id : str
|
|
636
|
+
|
|
637
|
+
request_options : typing.Optional[RequestOptions]
|
|
638
|
+
Request-specific configuration.
|
|
639
|
+
|
|
640
|
+
Returns
|
|
641
|
+
-------
|
|
642
|
+
None
|
|
643
|
+
|
|
644
|
+
Examples
|
|
645
|
+
--------
|
|
646
|
+
import asyncio
|
|
647
|
+
|
|
648
|
+
from agenta import AsyncAgentaApi
|
|
649
|
+
|
|
650
|
+
client = AsyncAgentaApi(
|
|
651
|
+
api_key="YOUR_API_KEY",
|
|
652
|
+
base_url="https://yourhost.com/path/to/api",
|
|
653
|
+
)
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
async def main() -> None:
|
|
657
|
+
await client.vault.delete_secret(
|
|
658
|
+
secret_id="secret_id",
|
|
659
|
+
)
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
asyncio.run(main())
|
|
663
|
+
"""
|
|
664
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
665
|
+
f"vault/v1/secrets/{jsonable_encoder(secret_id)}",
|
|
666
|
+
method="DELETE",
|
|
667
|
+
request_options=request_options,
|
|
668
|
+
)
|
|
669
|
+
try:
|
|
670
|
+
if 200 <= _response.status_code < 300:
|
|
671
|
+
return
|
|
672
|
+
if _response.status_code == 422:
|
|
673
|
+
raise UnprocessableEntityError(
|
|
674
|
+
typing.cast(
|
|
675
|
+
HttpValidationError,
|
|
676
|
+
parse_obj_as(
|
|
677
|
+
type_=HttpValidationError, # type: ignore
|
|
678
|
+
object_=_response.json(),
|
|
679
|
+
),
|
|
680
|
+
)
|
|
681
|
+
)
|
|
682
|
+
_response_json = _response.json()
|
|
683
|
+
except JSONDecodeError:
|
|
684
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
685
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
agenta/client/client.py
CHANGED
|
@@ -559,5 +559,5 @@ def run_evaluation(app_name: str, host: str, api_key: str = None) -> str:
|
|
|
559
559
|
raise APIRequestError(
|
|
560
560
|
f"Request to run evaluations failed with status code {response.status_code} and error message: {error_message}."
|
|
561
561
|
)
|
|
562
|
-
|
|
562
|
+
|
|
563
563
|
return response.json()
|
agenta/sdk/__init__.py
CHANGED
|
@@ -27,6 +27,7 @@ from .tracing.conventions import Reference
|
|
|
27
27
|
from .decorators.routing import entrypoint, app, route
|
|
28
28
|
from .agenta_init import Config, AgentaSingleton, init as _init
|
|
29
29
|
from .utils.costs import calculate_token_usage
|
|
30
|
+
from .managers.secrets import SecretsManager
|
|
30
31
|
from .managers.config import ConfigManager
|
|
31
32
|
from .managers.variant import VariantManager
|
|
32
33
|
from .managers.deployment import DeploymentManager
|