agenta 0.27.0__py3-none-any.whl → 0.27.0a1__py3-none-any.whl

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

Potentially problematic release.


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

Files changed (68) hide show
  1. agenta/__init__.py +3 -22
  2. agenta/cli/helper.py +1 -5
  3. agenta/client/backend/__init__.py +0 -14
  4. agenta/client/backend/apps/client.py +20 -28
  5. agenta/client/backend/client.py +2 -25
  6. agenta/client/backend/containers/client.py +1 -5
  7. agenta/client/backend/core/__init__.py +1 -2
  8. agenta/client/backend/core/client_wrapper.py +6 -6
  9. agenta/client/backend/core/file.py +11 -33
  10. agenta/client/backend/core/http_client.py +18 -24
  11. agenta/client/backend/core/pydantic_utilities.py +29 -144
  12. agenta/client/backend/core/request_options.py +0 -3
  13. agenta/client/backend/core/serialization.py +42 -139
  14. agenta/client/backend/evaluations/client.py +2 -7
  15. agenta/client/backend/evaluators/client.py +1 -349
  16. agenta/client/backend/observability/client.py +2 -11
  17. agenta/client/backend/testsets/client.py +10 -10
  18. agenta/client/backend/types/__init__.py +0 -14
  19. agenta/client/backend/types/app.py +0 -1
  20. agenta/client/backend/types/app_variant_response.py +1 -3
  21. agenta/client/backend/types/create_span.py +2 -3
  22. agenta/client/backend/types/environment_output.py +0 -1
  23. agenta/client/backend/types/environment_output_extended.py +0 -1
  24. agenta/client/backend/types/evaluation.py +2 -1
  25. agenta/client/backend/types/evaluator.py +0 -2
  26. agenta/client/backend/types/evaluator_config.py +0 -1
  27. agenta/client/backend/types/human_evaluation.py +2 -1
  28. agenta/client/backend/types/llm_tokens.py +2 -2
  29. agenta/client/backend/types/span.py +0 -1
  30. agenta/client/backend/types/span_detail.py +1 -7
  31. agenta/client/backend/types/test_set_output_response.py +2 -5
  32. agenta/client/backend/types/trace_detail.py +1 -7
  33. agenta/client/backend/types/with_pagination.py +2 -4
  34. agenta/client/backend/variants/client.py +273 -1566
  35. agenta/docker/docker-assets/Dockerfile.cloud.template +1 -1
  36. agenta/sdk/__init__.py +5 -20
  37. agenta/sdk/agenta_init.py +26 -30
  38. agenta/sdk/config_manager.py +205 -0
  39. agenta/sdk/context/routing.py +5 -6
  40. agenta/sdk/decorators/routing.py +135 -142
  41. agenta/sdk/decorators/tracing.py +245 -206
  42. agenta/sdk/litellm/litellm.py +36 -47
  43. agenta/sdk/tracing/attributes.py +2 -7
  44. agenta/sdk/tracing/context.py +2 -5
  45. agenta/sdk/tracing/conventions.py +8 -10
  46. agenta/sdk/tracing/exporters.py +6 -15
  47. agenta/sdk/tracing/inline.py +98 -70
  48. agenta/sdk/tracing/processors.py +14 -55
  49. agenta/sdk/tracing/spans.py +4 -16
  50. agenta/sdk/tracing/tracing.py +50 -54
  51. agenta/sdk/types.py +2 -61
  52. agenta/sdk/utils/exceptions.py +1 -31
  53. {agenta-0.27.0.dist-info → agenta-0.27.0a1.dist-info}/METADATA +1 -1
  54. {agenta-0.27.0.dist-info → agenta-0.27.0a1.dist-info}/RECORD +56 -67
  55. agenta/client/backend/types/config_dto.py +0 -32
  56. agenta/client/backend/types/config_response_model.py +0 -32
  57. agenta/client/backend/types/evaluator_mapping_output_interface.py +0 -21
  58. agenta/client/backend/types/evaluator_output_interface.py +0 -21
  59. agenta/client/backend/types/lifecycle_dto.py +0 -24
  60. agenta/client/backend/types/reference_dto.py +0 -23
  61. agenta/client/backend/types/reference_request_model.py +0 -23
  62. agenta/sdk/managers/__init__.py +0 -6
  63. agenta/sdk/managers/config.py +0 -318
  64. agenta/sdk/managers/deployment.py +0 -45
  65. agenta/sdk/managers/shared.py +0 -639
  66. agenta/sdk/managers/variant.py +0 -182
  67. {agenta-0.27.0.dist-info → agenta-0.27.0a1.dist-info}/WHEEL +0 -0
  68. {agenta-0.27.0.dist-info → agenta-0.27.0a1.dist-info}/entry_points.txt +0 -0
@@ -1,32 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- from ..core.pydantic_utilities import UniversalBaseModel
4
- import typing
5
- from .reference_dto import ReferenceDto
6
- from .lifecycle_dto import LifecycleDto
7
- from ..core.pydantic_utilities import IS_PYDANTIC_V2
8
- import pydantic
9
-
10
-
11
- class ConfigResponseModel(UniversalBaseModel):
12
- params: typing.Dict[str, typing.Optional[typing.Any]]
13
- url: typing.Optional[str] = None
14
- application_ref: typing.Optional[ReferenceDto] = None
15
- service_ref: typing.Optional[ReferenceDto] = None
16
- variant_ref: typing.Optional[ReferenceDto] = None
17
- environment_ref: typing.Optional[ReferenceDto] = None
18
- application_lifecycle: typing.Optional[LifecycleDto] = None
19
- service_lifecycle: typing.Optional[LifecycleDto] = None
20
- variant_lifecycle: typing.Optional[LifecycleDto] = None
21
- environment_lifecycle: typing.Optional[LifecycleDto] = None
22
-
23
- if IS_PYDANTIC_V2:
24
- model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
25
- extra="allow", frozen=True
26
- ) # type: ignore # Pydantic v2
27
- else:
28
-
29
- class Config:
30
- frozen = True
31
- smart_union = True
32
- extra = pydantic.Extra.allow
@@ -1,21 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- from ..core.pydantic_utilities import UniversalBaseModel
4
- import typing
5
- from ..core.pydantic_utilities import IS_PYDANTIC_V2
6
- import pydantic
7
-
8
-
9
- class EvaluatorMappingOutputInterface(UniversalBaseModel):
10
- outputs: typing.Dict[str, typing.Optional[typing.Any]]
11
-
12
- if IS_PYDANTIC_V2:
13
- model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
14
- extra="allow", frozen=True
15
- ) # type: ignore # Pydantic v2
16
- else:
17
-
18
- class Config:
19
- frozen = True
20
- smart_union = True
21
- extra = pydantic.Extra.allow
@@ -1,21 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- from ..core.pydantic_utilities import UniversalBaseModel
4
- import typing
5
- from ..core.pydantic_utilities import IS_PYDANTIC_V2
6
- import pydantic
7
-
8
-
9
- class EvaluatorOutputInterface(UniversalBaseModel):
10
- outputs: typing.Dict[str, typing.Optional[typing.Any]]
11
-
12
- if IS_PYDANTIC_V2:
13
- model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
14
- extra="allow", frozen=True
15
- ) # type: ignore # Pydantic v2
16
- else:
17
-
18
- class Config:
19
- frozen = True
20
- smart_union = True
21
- extra = pydantic.Extra.allow
@@ -1,24 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- from ..core.pydantic_utilities import UniversalBaseModel
4
- import typing
5
- from ..core.pydantic_utilities import IS_PYDANTIC_V2
6
- import pydantic
7
-
8
-
9
- class LifecycleDto(UniversalBaseModel):
10
- created_at: typing.Optional[str] = None
11
- updated_at: typing.Optional[str] = None
12
- updated_by_id: typing.Optional[str] = None
13
- updated_by: typing.Optional[str] = None
14
-
15
- if IS_PYDANTIC_V2:
16
- model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
17
- extra="allow", frozen=True
18
- ) # type: ignore # Pydantic v2
19
- else:
20
-
21
- class Config:
22
- frozen = True
23
- smart_union = True
24
- extra = pydantic.Extra.allow
@@ -1,23 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- from ..core.pydantic_utilities import UniversalBaseModel
4
- import typing
5
- from ..core.pydantic_utilities import IS_PYDANTIC_V2
6
- import pydantic
7
-
8
-
9
- class ReferenceDto(UniversalBaseModel):
10
- slug: typing.Optional[str] = None
11
- version: typing.Optional[int] = None
12
- id: typing.Optional[str] = None
13
-
14
- if IS_PYDANTIC_V2:
15
- model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
16
- extra="allow", frozen=True
17
- ) # type: ignore # Pydantic v2
18
- else:
19
-
20
- class Config:
21
- frozen = True
22
- smart_union = True
23
- extra = pydantic.Extra.allow
@@ -1,23 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- from ..core.pydantic_utilities import UniversalBaseModel
4
- import typing
5
- from ..core.pydantic_utilities import IS_PYDANTIC_V2
6
- import pydantic
7
-
8
-
9
- class ReferenceRequestModel(UniversalBaseModel):
10
- slug: typing.Optional[str] = None
11
- version: typing.Optional[int] = None
12
- id: typing.Optional[str] = None
13
-
14
- if IS_PYDANTIC_V2:
15
- model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
16
- extra="allow", frozen=True
17
- ) # type: ignore # Pydantic v2
18
- else:
19
-
20
- class Config:
21
- frozen = True
22
- smart_union = True
23
- extra = pydantic.Extra.allow
@@ -1,6 +0,0 @@
1
- from agenta.sdk.managers.config import ConfigManager
2
- from agenta.sdk.managers.variant import VariantManager
3
- from agenta.sdk.managers.deployment import DeploymentManager
4
-
5
-
6
- __all__ = ["ConfigManager", "VariantManager", "DeploymentManager"]
@@ -1,318 +0,0 @@
1
- import json
2
- import logging
3
- from pathlib import Path
4
- from typing import Optional, Type, TypeVar, Dict, Any, Union
5
-
6
- import yaml
7
- from pydantic import BaseModel
8
-
9
- from agenta.sdk.managers.shared import SharedManager
10
- from agenta.sdk.decorators.routing import routing_context
11
-
12
- T = TypeVar("T", bound=BaseModel)
13
-
14
- logger = logging.getLogger(__name__)
15
-
16
- AVAILABLE_ENVIRONMENTS = ["development", "production", "staging"]
17
-
18
-
19
- class ConfigManager:
20
- @staticmethod
21
- def get_from_route(
22
- schema: Optional[Type[T]] = None,
23
- ) -> Union[Dict[str, Any], T]:
24
- """
25
- Retrieves the configuration from the route context and returns a config object.
26
-
27
- This method checks the route context for configuration information and returns
28
- an instance of the specified schema based on the available context data.
29
-
30
- Args:
31
- schema (Type[T]): A Pydantic model class that defines the structure of the configuration.
32
-
33
- Returns:
34
- T: An instance of the specified schema populated with the configuration data.
35
-
36
- Raises:
37
- ValueError: If conflicting configuration sources are provided or if no valid
38
- configuration source is found in the context.
39
-
40
- Note:
41
- The method prioritizes the inputs in the following way:
42
- 1. 'config' (i.e. when called explicitly from the playground)
43
- 2. 'environment'
44
- 3. 'variant'
45
- Only one of these should be provided.
46
- """
47
-
48
- context = routing_context.get()
49
-
50
- parameters = None
51
-
52
- if "config" in context and context["config"]:
53
- parameters = context["config"]
54
-
55
- else:
56
- app_id: Optional[str] = None
57
- app_slug: Optional[str] = None
58
- variant_id: Optional[str] = None
59
- variant_slug: Optional[str] = None
60
- variant_version: Optional[int] = None
61
- environment_id: Optional[str] = None
62
- environment_slug: Optional[str] = None
63
- environment_version: Optional[int] = None
64
-
65
- if "application" in context:
66
- app_id = context["application"].get("id")
67
- app_slug = context["application"].get("slug")
68
-
69
- if "variant" in context:
70
- variant_id = context["variant"].get("id")
71
- variant_slug = context["variant"].get("slug")
72
- variant_version = context["variant"].get("version")
73
-
74
- if "environment" in context:
75
- environment_id = context["environment"].get("id")
76
- environment_slug = context["environment"].get("slug")
77
- environment_version = context["environment"].get("version")
78
-
79
- parameters = ConfigManager.get_from_registry(
80
- app_id=app_id,
81
- app_slug=app_slug,
82
- variant_id=variant_id,
83
- variant_slug=variant_slug,
84
- variant_version=variant_version,
85
- environment_id=environment_id,
86
- environment_slug=environment_slug,
87
- environment_version=environment_version,
88
- )
89
-
90
- if schema:
91
- return schema(**parameters)
92
-
93
- return parameters
94
-
95
- @staticmethod
96
- async def async_get_from_route(
97
- schema: Optional[Type[T]] = None,
98
- ) -> Union[Dict[str, Any], T]:
99
- """
100
- Asynchronously retrieves the configuration from the route context and returns a config object.
101
-
102
- This method checks the route context for configuration information and returns
103
- an instance of the specified schema based on the available context data.
104
-
105
- Args:
106
- schema (Type[T]): A Pydantic model class that defines the structure of the configuration.
107
-
108
- Returns:
109
- T: An instance of the specified schema populated with the configuration data.
110
-
111
- Raises:
112
- ValueError: If conflicting configuration sources are provided or if no valid
113
- configuration source is found in the context.
114
-
115
- Note:
116
- The method prioritizes the inputs in the following way:
117
- 1. 'config' (i.e. when called explicitly from the playground)
118
- 2. 'environment'
119
- 3. 'variant'
120
- Only one of these should be provided.
121
- """
122
-
123
- context = routing_context.get()
124
-
125
- parameters = None
126
-
127
- if "config" in context and context["config"]:
128
- parameters = context["config"]
129
-
130
- else:
131
- app_id: Optional[str] = None
132
- app_slug: Optional[str] = None
133
- variant_id: Optional[str] = None
134
- variant_slug: Optional[str] = None
135
- variant_version: Optional[int] = None
136
- environment_id: Optional[str] = None
137
- environment_slug: Optional[str] = None
138
- environment_version: Optional[int] = None
139
-
140
- if "application" in context:
141
- app_id = context["application"].get("id")
142
- app_slug = context["application"].get("slug")
143
-
144
- if "variant" in context:
145
- variant_id = context["variant"].get("id")
146
- variant_slug = context["variant"].get("slug")
147
- variant_version = context["variant"].get("version")
148
-
149
- if "environment" in context:
150
- environment_id = context["environment"].get("id")
151
- environment_slug = context["environment"].get("slug")
152
- environment_version = context["environment"].get("version")
153
-
154
- parameters = await ConfigManager.async_get_from_registry(
155
- app_id=app_id,
156
- app_slug=app_slug,
157
- variant_id=variant_id,
158
- variant_slug=variant_slug,
159
- variant_version=variant_version,
160
- environment_id=environment_id,
161
- environment_slug=environment_slug,
162
- environment_version=environment_version,
163
- )
164
-
165
- if schema:
166
- return schema(**parameters)
167
-
168
- return parameters
169
-
170
- @staticmethod
171
- def get_from_registry(
172
- schema: Optional[Type[T]] = None,
173
- #
174
- app_id: Optional[str] = None,
175
- app_slug: Optional[str] = None,
176
- variant_id: Optional[str] = None,
177
- variant_slug: Optional[str] = None,
178
- variant_version: Optional[int] = None,
179
- environment_id: Optional[str] = None,
180
- environment_slug: Optional[str] = None,
181
- environment_version: Optional[int] = None,
182
- ) -> Union[Dict[str, Any], T]:
183
- """
184
- Pulls the parameters for the app variant from the server and returns a config object.
185
-
186
- This method retrieves the configuration from the backend server based on the provided
187
- environment or variant. It then validates and returns the configuration as an instance
188
- of the specified schema.
189
-
190
- Args:
191
- app_slug (str): The unique identifier for the application whose configuration is to be fetched.
192
- variant_slug (Optional[str]): The variant name to fetch the configuration for. Defaults to None.
193
- variant_version (Optional[int]): The version number of the variant to fetch. Defaults to None.
194
- environment_slug (Optional[str]): The environment name to fetch the configuration for.
195
- Must be one of "development", "production", or "staging". Defaults to None.
196
-
197
- Raises:
198
- Exception: For any other errors during the process (e.g., API communication issues).
199
- """
200
- config = SharedManager.fetch(
201
- app_id=app_id,
202
- app_slug=app_slug,
203
- variant_id=variant_id,
204
- variant_slug=variant_slug,
205
- variant_version=variant_version,
206
- environment_id=environment_id,
207
- environment_slug=environment_slug,
208
- environment_version=environment_version,
209
- )
210
-
211
- if schema:
212
- return schema(**config.params)
213
-
214
- return config.params
215
-
216
- @staticmethod
217
- async def async_get_from_registry(
218
- schema: Optional[Type[T]] = None,
219
- #
220
- app_id: Optional[str] = None,
221
- app_slug: Optional[str] = None,
222
- variant_id: Optional[str] = None,
223
- variant_slug: Optional[str] = None,
224
- variant_version: Optional[int] = None,
225
- environment_id: Optional[str] = None,
226
- environment_slug: Optional[str] = None,
227
- environment_version: Optional[int] = None,
228
- ) -> Union[Dict[str, Any], T]:
229
- """
230
- Pulls the parameters for the app variant from the server and returns a config object.
231
-
232
- This method retrieves the configuration from the backend server based on the provided
233
- environment or variant. It then validates and returns the configuration as an instance
234
- of the specified schema.
235
-
236
- Args:
237
- app_slug (str): The unique identifier for the application whose configuration is to be fetched.
238
- variant_slug (Optional[str]): The variant name to fetch the configuration for. Defaults to None.
239
- variant_version (Optional[int]): The version number of the variant to fetch. Defaults to None.
240
- environment_slug (Optional[str]): The environment name to fetch the configuration for.
241
- Must be one of "development", "production", or "staging". Defaults to None.
242
-
243
- Raises:
244
- Exception: For any other errors during the process (e.g., API communication issues).
245
- """
246
- config = await SharedManager.afetch(
247
- app_id=app_id,
248
- app_slug=app_slug,
249
- variant_id=variant_id,
250
- variant_slug=variant_slug,
251
- variant_version=variant_version,
252
- environment_id=environment_id,
253
- environment_slug=environment_slug,
254
- environment_version=environment_version,
255
- )
256
-
257
- if schema:
258
- return schema(**config.params)
259
-
260
- return config.params
261
-
262
- @staticmethod
263
- def get_from_yaml(
264
- filename: str,
265
- schema: Optional[Type[T]] = None,
266
- ) -> T:
267
- """
268
- Loads configuration from a YAML file and returns a config object.
269
-
270
- Args:
271
- filename (str): The name of the YAML file to load.
272
- schema (Type[T]): A Pydantic model class that defines the structure of the configuration.
273
-
274
- Returns:
275
- T: An instance of the specified schema populated with the configuration data.
276
-
277
- Raises:
278
- FileNotFoundError: If the specified file doesn't exist.
279
- ValidationError: If the loaded configuration data doesn't match the schema.
280
- """
281
- file_path = Path(filename)
282
-
283
- with open(file_path, "r", encoding="utf-8") as file:
284
- parameters = yaml.safe_load(file)
285
-
286
- if schema:
287
- return schema(**parameters)
288
-
289
- return parameters
290
-
291
- @staticmethod
292
- def get_from_json(
293
- filename: str,
294
- schema: Optional[Type[T]] = None,
295
- ) -> T:
296
- """
297
- Loads configuration from a JSON file and returns a config object.
298
-
299
- Args:
300
- filename (str): The name of the JSON file to load.
301
- schema (Type[T]): A Pydantic model class that defines the structure of the configuration.
302
-
303
- Returns:
304
- T: An instance of the specified schema populated with the configuration data.
305
-
306
- Raises:
307
- FileNotFoundError: If the specified file doesn't exist.
308
- ValidationError: If the loaded configuration data doesn't match the schema.
309
- """
310
- file_path = Path(filename)
311
-
312
- with open(file_path, "r", encoding="utf-8") as file:
313
- parameters = json.load(file)
314
-
315
- if schema:
316
- return schema(**parameters)
317
-
318
- return parameters
@@ -1,45 +0,0 @@
1
- from typing import Optional
2
-
3
- from agenta.sdk.managers.shared import SharedManager
4
-
5
-
6
- class DeploymentManager:
7
- @classmethod
8
- def deploy(
9
- cls,
10
- *,
11
- variant_slug: str,
12
- environment_slug: str,
13
- #
14
- app_id: Optional[str] = None,
15
- app_slug: Optional[str] = None,
16
- variant_version: Optional[int] = None,
17
- ):
18
- deployment = SharedManager.deploy(
19
- app_id=app_id,
20
- app_slug=app_slug,
21
- variant_slug=variant_slug,
22
- variant_version=variant_version,
23
- environment_slug=environment_slug,
24
- )
25
- return deployment
26
-
27
- @classmethod
28
- async def adeploy(
29
- cls,
30
- *,
31
- variant_slug: str,
32
- environment_slug: str,
33
- #
34
- app_id: Optional[str] = None,
35
- app_slug: Optional[str] = None,
36
- variant_version: Optional[int] = None,
37
- ):
38
- deployment = await SharedManager.adeploy(
39
- app_id=app_id,
40
- app_slug=app_slug,
41
- variant_slug=variant_slug,
42
- variant_version=variant_version,
43
- environment_slug=environment_slug,
44
- )
45
- return deployment