agenta 0.12.3__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.
- agenta/__init__.py +64 -7
- agenta/cli/helper.py +7 -3
- agenta/cli/main.py +15 -50
- agenta/cli/variant_commands.py +50 -29
- agenta/client/Readme.md +72 -64
- agenta/client/api.py +2 -2
- agenta/client/backend/__init__.py +193 -22
- agenta/client/backend/access_control/__init__.py +1 -0
- agenta/client/backend/access_control/client.py +167 -0
- agenta/client/backend/apps/__init__.py +1 -0
- agenta/client/backend/apps/client.py +1691 -0
- agenta/client/backend/bases/__init__.py +1 -0
- agenta/client/backend/bases/client.py +190 -0
- agenta/client/backend/client.py +2508 -5712
- agenta/client/backend/configs/__init__.py +1 -0
- agenta/client/backend/configs/client.py +604 -0
- agenta/client/backend/containers/__init__.py +5 -0
- agenta/client/backend/containers/client.py +648 -0
- agenta/client/backend/containers/types/__init__.py +5 -0
- agenta/client/backend/{types → containers/types}/container_templates_response.py +1 -2
- agenta/client/backend/core/__init__.py +30 -0
- agenta/client/backend/core/client_wrapper.py +42 -9
- agenta/client/backend/core/file.py +70 -0
- agenta/client/backend/core/http_client.py +575 -0
- agenta/client/backend/core/jsonable_encoder.py +33 -39
- agenta/client/backend/core/pydantic_utilities.py +325 -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 +35 -0
- agenta/client/backend/core/serialization.py +276 -0
- agenta/client/backend/environments/__init__.py +1 -0
- agenta/client/backend/environments/client.py +196 -0
- agenta/client/backend/evaluations/__init__.py +1 -0
- agenta/client/backend/evaluations/client.py +1469 -0
- agenta/client/backend/evaluators/__init__.py +1 -0
- agenta/client/backend/evaluators/client.py +1283 -0
- agenta/client/backend/observability/__init__.py +1 -0
- agenta/client/backend/observability/client.py +1286 -0
- agenta/client/backend/observability_v_1/__init__.py +5 -0
- agenta/client/backend/observability_v_1/client.py +763 -0
- agenta/client/backend/observability_v_1/types/__init__.py +7 -0
- agenta/client/backend/observability_v_1/types/format.py +5 -0
- agenta/client/backend/observability_v_1/types/query_analytics_response.py +7 -0
- agenta/client/backend/observability_v_1/types/query_traces_response.py +11 -0
- agenta/client/backend/scopes/__init__.py +1 -0
- agenta/client/backend/scopes/client.py +114 -0
- agenta/client/backend/testsets/__init__.py +1 -0
- agenta/client/backend/testsets/client.py +1284 -0
- agenta/client/backend/types/__init__.py +154 -26
- agenta/client/backend/types/agenta_node_dto.py +48 -0
- agenta/client/backend/types/agenta_node_dto_nodes_value.py +6 -0
- agenta/client/backend/types/agenta_nodes_response.py +30 -0
- agenta/client/backend/types/agenta_root_dto.py +30 -0
- agenta/client/backend/types/agenta_roots_response.py +30 -0
- agenta/client/backend/types/agenta_tree_dto.py +30 -0
- agenta/client/backend/types/agenta_trees_response.py +30 -0
- agenta/client/backend/types/aggregated_result.py +16 -31
- agenta/client/backend/types/aggregated_result_evaluator_config.py +8 -0
- agenta/client/backend/types/analytics_response.py +24 -0
- agenta/client/backend/types/app.py +17 -30
- agenta/client/backend/types/app_variant_response.py +36 -0
- 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 +15 -31
- agenta/client/backend/types/bucket_dto.py +26 -0
- agenta/client/backend/types/collect_status_response.py +22 -0
- agenta/client/backend/types/config_db.py +16 -31
- agenta/client/backend/types/config_dto.py +32 -0
- agenta/client/backend/types/config_response_model.py +32 -0
- 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 +45 -0
- agenta/client/backend/types/create_trace_response.py +22 -0
- agenta/client/backend/types/docker_env_vars.py +13 -28
- agenta/client/backend/types/environment_output.py +22 -34
- agenta/client/backend/types/environment_output_extended.py +31 -0
- agenta/client/backend/types/environment_revision.py +26 -0
- agenta/client/backend/types/error.py +22 -0
- agenta/client/backend/types/evaluation.py +22 -33
- 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 +17 -30
- agenta/client/backend/types/evaluation_scenario_result.py +14 -29
- agenta/client/backend/types/evaluation_scenario_score_update.py +21 -0
- agenta/client/backend/types/evaluation_status_enum.py +11 -29
- agenta/client/backend/types/evaluation_type.py +3 -21
- agenta/client/backend/types/evaluator.py +20 -31
- agenta/client/backend/types/evaluator_config.py +21 -33
- agenta/client/backend/types/evaluator_mapping_output_interface.py +21 -0
- agenta/client/backend/types/evaluator_output_interface.py +21 -0
- agenta/client/backend/types/exception_dto.py +26 -0
- agenta/client/backend/types/get_config_response.py +23 -0
- agenta/client/backend/types/header_dto.py +22 -0
- agenta/client/backend/types/http_validation_error.py +14 -29
- agenta/client/backend/types/human_evaluation.py +18 -34
- agenta/client/backend/types/human_evaluation_scenario.py +22 -38
- 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 +30 -0
- agenta/client/backend/types/human_evaluation_update.py +22 -0
- agenta/client/backend/types/image.py +18 -32
- agenta/client/backend/types/invite_request.py +16 -30
- agenta/client/backend/types/legacy_analytics_response.py +29 -0
- agenta/client/backend/types/legacy_data_point.py +27 -0
- agenta/client/backend/types/lifecycle_dto.py +24 -0
- agenta/client/backend/types/link_dto.py +24 -0
- agenta/client/backend/types/list_api_keys_response.py +24 -0
- agenta/client/backend/types/llm_run_rate_limit.py +13 -28
- agenta/client/backend/types/llm_tokens.py +23 -0
- agenta/client/backend/types/metrics_dto.py +24 -0
- agenta/client/backend/types/new_human_evaluation.py +27 -0
- agenta/client/backend/types/new_testset.py +16 -31
- agenta/client/backend/types/node_dto.py +24 -0
- agenta/client/backend/types/node_type.py +19 -0
- agenta/client/backend/types/o_tel_context_dto.py +22 -0
- agenta/client/backend/types/o_tel_event_dto.py +23 -0
- agenta/client/backend/types/o_tel_extra_dto.py +26 -0
- agenta/client/backend/types/o_tel_link_dto.py +23 -0
- agenta/client/backend/types/o_tel_span_dto.py +37 -0
- agenta/client/backend/types/o_tel_span_kind.py +15 -0
- agenta/client/backend/types/o_tel_spans_response.py +24 -0
- agenta/client/backend/types/o_tel_status_code.py +8 -0
- agenta/client/backend/types/organization.py +22 -35
- agenta/client/backend/types/organization_output.py +13 -28
- agenta/client/backend/types/outputs.py +5 -0
- agenta/client/backend/types/parent_dto.py +21 -0
- agenta/client/backend/types/permission.py +41 -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/reference_dto.py +23 -0
- agenta/client/backend/types/reference_request_model.py +23 -0
- agenta/client/backend/types/result.py +18 -31
- agenta/client/backend/types/root_dto.py +21 -0
- agenta/client/backend/types/{human_evaluation_scenario_score.py → score.py} +1 -1
- agenta/client/backend/types/secret_dto.py +24 -0
- agenta/client/backend/types/{human_evaluation_scenario_update_score.py → secret_kind.py} +1 -1
- agenta/client/backend/types/secret_response_dto.py +27 -0
- agenta/client/backend/types/simple_evaluation_output.py +13 -28
- agenta/client/backend/types/span.py +39 -49
- agenta/client/backend/types/span_detail.py +44 -0
- agenta/client/backend/types/span_dto.py +54 -0
- agenta/client/backend/types/span_dto_nodes_value.py +9 -0
- agenta/client/backend/types/span_status_code.py +5 -0
- agenta/client/backend/types/span_variant.py +23 -0
- agenta/client/backend/types/status_code.py +5 -0
- agenta/client/backend/types/status_dto.py +23 -0
- 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 +20 -33
- agenta/client/backend/types/test_set_simple_response.py +13 -28
- agenta/client/backend/types/time_dto.py +23 -0
- agenta/client/backend/types/trace_detail.py +44 -0
- agenta/client/backend/types/tree_dto.py +23 -0
- agenta/client/backend/types/tree_type.py +5 -0
- 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 +26 -0
- agenta/client/backend/types/workspace_member_response.py +23 -0
- agenta/client/backend/types/workspace_permission.py +25 -0
- agenta/client/backend/types/workspace_response.py +29 -0
- agenta/client/backend/types/workspace_role.py +15 -0
- agenta/client/backend/types/workspace_role_response.py +23 -0
- agenta/client/backend/variants/__init__.py +5 -0
- agenta/client/backend/variants/client.py +2814 -0
- agenta/client/backend/variants/types/__init__.py +7 -0
- agenta/client/backend/variants/types/add_variant_from_base_and_config_response.py +8 -0
- agenta/client/backend/vault/__init__.py +1 -0
- agenta/client/backend/vault/client.py +685 -0
- agenta/client/client.py +1 -1
- agenta/config.py +0 -2
- agenta/config.toml +0 -1
- agenta/docker/docker-assets/Dockerfile.cloud.template +2 -1
- agenta/docker/docker-assets/Dockerfile.template +2 -1
- agenta/docker/docker_utils.py +11 -12
- agenta/sdk/__init__.py +58 -7
- agenta/sdk/agenta_init.py +182 -164
- agenta/sdk/assets.py +95 -0
- agenta/sdk/client.py +56 -0
- agenta/sdk/context/__init__.py +0 -0
- agenta/sdk/context/exporting.py +25 -0
- agenta/sdk/context/routing.py +27 -0
- agenta/sdk/context/tracing.py +28 -0
- agenta/sdk/decorators/__init__.py +0 -0
- agenta/sdk/decorators/routing.py +576 -0
- agenta/sdk/decorators/tracing.py +296 -0
- agenta/sdk/litellm/__init__.py +1 -0
- agenta/sdk/litellm/litellm.py +314 -0
- agenta/sdk/litellm/mockllm.py +27 -0
- agenta/sdk/litellm/mocks/__init__.py +26 -0
- agenta/sdk/managers/__init__.py +6 -0
- agenta/sdk/managers/config.py +208 -0
- agenta/sdk/managers/deployment.py +45 -0
- agenta/sdk/managers/secrets.py +38 -0
- agenta/sdk/managers/shared.py +639 -0
- agenta/sdk/managers/variant.py +182 -0
- agenta/sdk/managers/vault.py +16 -0
- agenta/sdk/middleware/__init__.py +0 -0
- agenta/sdk/middleware/auth.py +180 -0
- agenta/sdk/middleware/cache.py +47 -0
- agenta/sdk/middleware/config.py +255 -0
- agenta/sdk/middleware/cors.py +29 -0
- agenta/sdk/middleware/inline.py +38 -0
- agenta/sdk/middleware/mock.py +33 -0
- agenta/sdk/middleware/otel.py +40 -0
- agenta/sdk/middleware/vault.py +145 -0
- agenta/sdk/router.py +0 -7
- agenta/sdk/tracing/__init__.py +1 -0
- agenta/sdk/tracing/attributes.py +141 -0
- agenta/sdk/tracing/conventions.py +49 -0
- agenta/sdk/tracing/exporters.py +103 -0
- agenta/sdk/tracing/inline.py +1146 -0
- agenta/sdk/tracing/processors.py +121 -0
- agenta/sdk/tracing/spans.py +136 -0
- agenta/sdk/tracing/tracing.py +237 -0
- agenta/sdk/types.py +478 -74
- agenta/sdk/utils/__init__.py +0 -0
- agenta/sdk/utils/constants.py +1 -0
- agenta/sdk/utils/{helper/openai_cost.py → costs.py} +3 -0
- agenta/sdk/utils/exceptions.py +59 -0
- agenta/sdk/utils/globals.py +6 -10
- agenta/sdk/utils/helpers.py +8 -0
- agenta/sdk/utils/logging.py +21 -0
- agenta/sdk/utils/singleton.py +13 -0
- agenta/sdk/utils/timing.py +58 -0
- {agenta-0.12.3.dist-info → agenta-0.32.0a1.dist-info}/METADATA +98 -151
- agenta-0.32.0a1.dist-info/RECORD +263 -0
- {agenta-0.12.3.dist-info → agenta-0.32.0a1.dist-info}/WHEEL +1 -1
- agenta/client/backend/types/add_variant_from_base_and_config_response.py +0 -7
- agenta/client/backend/types/app_variant_output.py +0 -47
- agenta/client/backend/types/app_variant_output_extended.py +0 -50
- agenta/client/backend/types/delete_evaluation.py +0 -36
- agenta/client/backend/types/evaluation_webhook.py +0 -36
- agenta/client/backend/types/feedback.py +0 -40
- agenta/client/backend/types/get_config_reponse.py +0 -39
- agenta/client/backend/types/list_api_keys_output.py +0 -39
- agenta/client/backend/types/trace.py +0 -48
- agenta/sdk/agenta_decorator.py +0 -443
- agenta/sdk/context.py +0 -41
- agenta-0.12.3.dist-info/RECORD +0 -114
- {agenta-0.12.3.dist-info → agenta-0.32.0a1.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
@@ -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()
|