agenta 0.36.5__py3-none-any.whl → 0.37.0__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 (209) hide show
  1. agenta/__init__.py +1 -2
  2. agenta/client/__init__.py +6 -10
  3. agenta/client/{admin → backend/admin}/client.py +2 -0
  4. agenta/client/backend/api_keys/client.py +531 -0
  5. agenta/client/{apps → backend/apps}/client.py +0 -222
  6. agenta/client/{containers → backend/containers}/client.py +10 -70
  7. agenta/client/{core → backend/core}/http_client.py +6 -6
  8. agenta/client/{core → backend/core}/pydantic_utilities.py +2 -2
  9. agenta/client/{environments → backend/environments}/client.py +0 -2
  10. agenta/client/{human_evaluations → backend/human_evaluations}/client.py +0 -2
  11. agenta/client/{observability → backend/observability}/client.py +98 -0
  12. agenta/client/backend/organization/client.py +839 -0
  13. agenta/client/backend/testsets/__init__.py +1 -0
  14. agenta/client/{types → backend/types}/__init__.py +22 -6
  15. agenta/client/{types → backend/types}/agenta_nodes_response.py +0 -5
  16. agenta/client/{types → backend/types}/agenta_root_dto.py +0 -5
  17. agenta/client/{types → backend/types}/agenta_roots_response.py +0 -5
  18. agenta/client/{types → backend/types}/agenta_tree_dto.py +0 -5
  19. agenta/client/{types → backend/types}/agenta_trees_response.py +0 -5
  20. agenta/client/backend/types/custom_model_settings_dto.py +22 -0
  21. agenta/client/backend/types/custom_provider_dto.py +29 -0
  22. agenta/client/backend/types/custom_provider_kind.py +26 -0
  23. agenta/client/backend/types/custom_provider_settings_dto.py +24 -0
  24. agenta/client/backend/types/data.py +7 -0
  25. agenta/client/{types → backend/types}/organization.py +1 -4
  26. agenta/client/backend/types/organization_details.py +29 -0
  27. agenta/client/{types → backend/types}/organization_membership_request.py +3 -2
  28. agenta/client/{types → backend/types}/permission.py +1 -0
  29. agenta/client/backend/types/provider_key_dto.py +21 -0
  30. agenta/client/backend/types/provider_kind.py +21 -0
  31. agenta/client/backend/types/score.py +3 -0
  32. agenta/client/{types → backend/types}/secret_dto.py +3 -3
  33. agenta/client/backend/types/secret_kind.py +5 -0
  34. agenta/client/backend/types/standard_provider_dto.py +24 -0
  35. agenta/client/backend/types/standard_provider_kind.py +21 -0
  36. agenta/client/backend/types/standard_provider_settings_dto.py +21 -0
  37. agenta/client/backend/types/workspace.py +24 -0
  38. agenta/client/{variants → backend/variants}/client.py +18 -24
  39. agenta/client/backend/vault/__init__.py +1 -0
  40. agenta/client/{vault → backend/vault}/client.py +26 -8
  41. agenta/client/backend/workspace/__init__.py +1 -0
  42. agenta/client/backend/workspace/client.py +405 -0
  43. agenta/client/client.py +46 -46
  44. agenta/client/types/provider_key_dto.py~feat_model-registry +21 -0
  45. agenta/client/types/provider_kind.py~feat_model-registry +21 -0
  46. agenta/sdk/__init__.py +1 -1
  47. agenta/sdk/managers/secrets.py +175 -11
  48. agenta/sdk/managers/shared.py +3 -3
  49. agenta/sdk/middleware/vault.py +29 -37
  50. agenta/sdk/types.py +4 -7
  51. {agenta-0.36.5.dist-info → agenta-0.37.0.dist-info}/METADATA +2 -6
  52. agenta-0.37.0.dist-info/RECORD +255 -0
  53. agenta/client/types/score.py +0 -5
  54. agenta/client/types/secret_kind.py +0 -5
  55. agenta/sdk/client.py +0 -56
  56. agenta-0.36.5.dist-info/RECORD +0 -236
  57. /agenta/client/{access_control → backend/access_control}/__init__.py +0 -0
  58. /agenta/client/{access_control → backend/access_control}/client.py +0 -0
  59. /agenta/client/{admin → backend/admin}/__init__.py +0 -0
  60. /agenta/client/{apps → backend/api_keys}/__init__.py +0 -0
  61. /agenta/client/{bases → backend/apps}/__init__.py +0 -0
  62. /agenta/client/{configs → backend/bases}/__init__.py +0 -0
  63. /agenta/client/{bases → backend/bases}/client.py +0 -0
  64. /agenta/client/{environments → backend/configs}/__init__.py +0 -0
  65. /agenta/client/{configs → backend/configs}/client.py +0 -0
  66. /agenta/client/{containers → backend/containers}/__init__.py +0 -0
  67. /agenta/client/{containers → backend/containers}/types/__init__.py +0 -0
  68. /agenta/client/{containers → backend/containers}/types/container_templates_response.py +0 -0
  69. /agenta/client/{core → backend/core}/__init__.py +0 -0
  70. /agenta/client/{core → backend/core}/api_error.py +0 -0
  71. /agenta/client/{core → backend/core}/client_wrapper.py +0 -0
  72. /agenta/client/{core → backend/core}/datetime_utils.py +0 -0
  73. /agenta/client/{core → backend/core}/file.py +0 -0
  74. /agenta/client/{core → backend/core}/jsonable_encoder.py +0 -0
  75. /agenta/client/{core → backend/core}/query_encoder.py +0 -0
  76. /agenta/client/{core → backend/core}/remove_none_from_dict.py +0 -0
  77. /agenta/client/{core → backend/core}/request_options.py +0 -0
  78. /agenta/client/{core → backend/core}/serialization.py +0 -0
  79. /agenta/client/{evaluations → backend/environments}/__init__.py +0 -0
  80. /agenta/client/{errors → backend/errors}/__init__.py +0 -0
  81. /agenta/client/{errors → backend/errors}/unprocessable_entity_error.py +0 -0
  82. /agenta/client/{evaluators → backend/evaluations}/__init__.py +0 -0
  83. /agenta/client/{evaluations → backend/evaluations}/client.py +0 -0
  84. /agenta/client/{human_evaluations → backend/evaluators}/__init__.py +0 -0
  85. /agenta/client/{evaluators → backend/evaluators}/client.py +0 -0
  86. /agenta/client/{scopes → backend/human_evaluations}/__init__.py +0 -0
  87. /agenta/client/{observability → backend/observability}/__init__.py +0 -0
  88. /agenta/client/{observability → backend/observability}/types/__init__.py +0 -0
  89. /agenta/client/{observability → backend/observability}/types/format.py +0 -0
  90. /agenta/client/{observability → backend/observability}/types/query_analytics_response.py +0 -0
  91. /agenta/client/{observability → backend/observability}/types/query_traces_response.py +0 -0
  92. /agenta/client/{testsets → backend/organization}/__init__.py +0 -0
  93. /agenta/client/{vault → backend/scopes}/__init__.py +0 -0
  94. /agenta/client/{scopes → backend/scopes}/client.py +0 -0
  95. /agenta/client/{testsets → backend/testsets}/client.py +0 -0
  96. /agenta/client/{types → backend/types}/account_response.py +0 -0
  97. /agenta/client/{types → backend/types}/agenta_node_dto.py +0 -0
  98. /agenta/client/{types → backend/types}/agenta_node_dto_nodes_value.py +0 -0
  99. /agenta/client/{types → backend/types}/aggregated_result.py +0 -0
  100. /agenta/client/{types → backend/types}/aggregated_result_evaluator_config.py +0 -0
  101. /agenta/client/{types → backend/types}/analytics_response.py +0 -0
  102. /agenta/client/{types → backend/types}/app.py +0 -0
  103. /agenta/client/{types → backend/types}/app_variant_response.py +0 -0
  104. /agenta/client/{types → backend/types}/app_variant_revision.py +0 -0
  105. /agenta/client/{types → backend/types}/base_output.py +0 -0
  106. /agenta/client/{types → backend/types}/body_import_testset.py +0 -0
  107. /agenta/client/{types → backend/types}/bucket_dto.py +0 -0
  108. /agenta/client/{types → backend/types}/collect_status_response.py +0 -0
  109. /agenta/client/{types → backend/types}/config_db.py +0 -0
  110. /agenta/client/{types → backend/types}/config_dto.py +0 -0
  111. /agenta/client/{types → backend/types}/config_response_model.py +0 -0
  112. /agenta/client/{types → backend/types}/correct_answer.py +0 -0
  113. /agenta/client/{types → backend/types}/create_app_output.py +0 -0
  114. /agenta/client/{types → backend/types}/delete_evaluation.py +0 -0
  115. /agenta/client/{types → backend/types}/docker_env_vars.py +0 -0
  116. /agenta/client/{types → backend/types}/environment_output.py +0 -0
  117. /agenta/client/{types → backend/types}/environment_output_extended.py +0 -0
  118. /agenta/client/{types → backend/types}/environment_revision.py +0 -0
  119. /agenta/client/{types → backend/types}/error.py +0 -0
  120. /agenta/client/{types → backend/types}/evaluation.py +0 -0
  121. /agenta/client/{types → backend/types}/evaluation_scenario.py +0 -0
  122. /agenta/client/{types → backend/types}/evaluation_scenario_input.py +0 -0
  123. /agenta/client/{types → backend/types}/evaluation_scenario_output.py +0 -0
  124. /agenta/client/{types → backend/types}/evaluation_scenario_result.py +0 -0
  125. /agenta/client/{types → backend/types}/evaluation_status_enum.py +0 -0
  126. /agenta/client/{types → backend/types}/evaluation_type.py +0 -0
  127. /agenta/client/{types → backend/types}/evaluator.py +0 -0
  128. /agenta/client/{types → backend/types}/evaluator_config.py +0 -0
  129. /agenta/client/{types → backend/types}/evaluator_mapping_output_interface.py +0 -0
  130. /agenta/client/{types → backend/types}/evaluator_output_interface.py +0 -0
  131. /agenta/client/{types → backend/types}/exception_dto.py +0 -0
  132. /agenta/client/{types → backend/types}/get_config_response.py +0 -0
  133. /agenta/client/{types → backend/types}/header_dto.py +0 -0
  134. /agenta/client/{types → backend/types}/http_validation_error.py +0 -0
  135. /agenta/client/{types → backend/types}/human_evaluation.py +0 -0
  136. /agenta/client/{types → backend/types}/human_evaluation_scenario.py +0 -0
  137. /agenta/client/{types → backend/types}/human_evaluation_scenario_input.py +0 -0
  138. /agenta/client/{types → backend/types}/human_evaluation_scenario_output.py +0 -0
  139. /agenta/client/{types → backend/types}/image.py +0 -0
  140. /agenta/client/{types → backend/types}/invite_request.py +0 -0
  141. /agenta/client/{types → backend/types}/legacy_analytics_response.py +0 -0
  142. /agenta/client/{types → backend/types}/legacy_data_point.py +0 -0
  143. /agenta/client/{types → backend/types}/legacy_scope_request.py +0 -0
  144. /agenta/client/{types → backend/types}/legacy_scopes_response.py +0 -0
  145. /agenta/client/{types → backend/types}/legacy_user_request.py +0 -0
  146. /agenta/client/{types → backend/types}/legacy_user_response.py +0 -0
  147. /agenta/client/{types → backend/types}/lifecycle_dto.py +0 -0
  148. /agenta/client/{types → backend/types}/link_dto.py +0 -0
  149. /agenta/client/{types → backend/types}/list_api_keys_response.py +0 -0
  150. /agenta/client/{types → backend/types}/llm_run_rate_limit.py +0 -0
  151. /agenta/client/{types → backend/types}/metrics_dto.py +0 -0
  152. /agenta/client/{types → backend/types}/new_testset.py +0 -0
  153. /agenta/client/{types → backend/types}/node_dto.py +0 -0
  154. /agenta/client/{types → backend/types}/node_type.py +0 -0
  155. /agenta/client/{types → backend/types}/o_tel_context_dto.py +0 -0
  156. /agenta/client/{types → backend/types}/o_tel_event_dto.py +0 -0
  157. /agenta/client/{types → backend/types}/o_tel_extra_dto.py +0 -0
  158. /agenta/client/{types → backend/types}/o_tel_link_dto.py +0 -0
  159. /agenta/client/{types → backend/types}/o_tel_span_dto.py +0 -0
  160. /agenta/client/{types → backend/types}/o_tel_span_kind.py +0 -0
  161. /agenta/client/{types → backend/types}/o_tel_spans_response.py +0 -0
  162. /agenta/client/{types → backend/types}/o_tel_status_code.py +0 -0
  163. /agenta/client/{types → backend/types}/organization_output.py +0 -0
  164. /agenta/client/{types → backend/types}/organization_request.py +0 -0
  165. /agenta/client/{types → backend/types}/parent_dto.py +0 -0
  166. /agenta/client/{types → backend/types}/project_membership_request.py +0 -0
  167. /agenta/client/{types → backend/types}/project_request.py +0 -0
  168. /agenta/client/{types → backend/types}/project_scope.py +0 -0
  169. /agenta/client/{types → backend/types}/projects_response.py +0 -0
  170. /agenta/client/{types → backend/types}/reference.py +0 -0
  171. /agenta/client/{types → backend/types}/reference_dto.py +0 -0
  172. /agenta/client/{types → backend/types}/reference_request_model.py +0 -0
  173. /agenta/client/{types → backend/types}/result.py +0 -0
  174. /agenta/client/{types → backend/types}/role.py +0 -0
  175. /agenta/client/{types → backend/types}/root_dto.py +0 -0
  176. /agenta/client/{types → backend/types}/scopes_response_model.py +0 -0
  177. /agenta/client/{types → backend/types}/secret_response_dto.py +0 -0
  178. /agenta/client/{types → backend/types}/simple_evaluation_output.py +0 -0
  179. /agenta/client/{types → backend/types}/span_dto.py +0 -0
  180. /agenta/client/{types → backend/types}/span_dto_nodes_value.py +0 -0
  181. /agenta/client/{types → backend/types}/status_code.py +0 -0
  182. /agenta/client/{types → backend/types}/status_dto.py +0 -0
  183. /agenta/client/{types → backend/types}/template.py +0 -0
  184. /agenta/client/{types → backend/types}/template_image_info.py +0 -0
  185. /agenta/client/{types → backend/types}/test_set_output_response.py +0 -0
  186. /agenta/client/{types → backend/types}/test_set_simple_response.py +0 -0
  187. /agenta/client/{types → backend/types}/time_dto.py +0 -0
  188. /agenta/client/{types → backend/types}/tree_dto.py +0 -0
  189. /agenta/client/{types → backend/types}/tree_type.py +0 -0
  190. /agenta/client/{types → backend/types}/update_app_output.py +0 -0
  191. /agenta/client/{types → backend/types}/uri.py +0 -0
  192. /agenta/client/{types → backend/types}/user_request.py +0 -0
  193. /agenta/client/{types → backend/types}/validation_error.py +0 -0
  194. /agenta/client/{types → backend/types}/validation_error_loc_item.py +0 -0
  195. /agenta/client/{types → backend/types}/variant_action.py +0 -0
  196. /agenta/client/{types → backend/types}/variant_action_enum.py +0 -0
  197. /agenta/client/{types → backend/types}/workspace_member_response.py +0 -0
  198. /agenta/client/{types → backend/types}/workspace_membership_request.py +0 -0
  199. /agenta/client/{types → backend/types}/workspace_permission.py +0 -0
  200. /agenta/client/{types → backend/types}/workspace_request.py +0 -0
  201. /agenta/client/{types → backend/types}/workspace_response.py +0 -0
  202. /agenta/client/{types → backend/types}/workspace_role.py +0 -0
  203. /agenta/client/{types → backend/types}/workspace_role_response.py +0 -0
  204. /agenta/client/{variants → backend/variants}/__init__.py +0 -0
  205. /agenta/client/{variants → backend/variants}/types/__init__.py +0 -0
  206. /agenta/client/{variants → backend/variants}/types/add_variant_from_base_and_config_response.py +0 -0
  207. /agenta/client/types/{provider_key_dto.py → provider_key_dto.py~HEAD} +0 -0
  208. /agenta/client/types/{provider_kind.py → provider_kind.py~HEAD} +0 -0
  209. {agenta-0.36.5.dist-info → agenta-0.37.0.dist-info}/WHEEL +0 -0
@@ -1,13 +1,13 @@
1
- from typing import Optional, Dict, Any
1
+ import re
2
+ from typing import Optional, Dict, Any, List
2
3
 
3
4
  from agenta.sdk.context.routing import routing_context
4
-
5
- from agenta.sdk.assets import model_to_provider_mapping
5
+ from agenta.sdk.assets import model_to_provider_mapping as _standard_providers
6
6
 
7
7
 
8
8
  class SecretsManager:
9
9
  @staticmethod
10
- def get_from_route() -> Optional[Dict[str, Any]]:
10
+ def get_from_route() -> Optional[List[Dict[str, Any]]]:
11
11
  context = routing_context.get()
12
12
 
13
13
  secrets = context.secrets
@@ -18,21 +18,185 @@ class SecretsManager:
18
18
  return secrets
19
19
 
20
20
  @staticmethod
21
- def get_api_key_for_model(model: str) -> str:
22
- secrets = SecretsManager.get_from_route()
21
+ def _parse_standard_secrets(
22
+ secret: Dict[str, Any], standard_secrets: List[Dict[str, Any]]
23
+ ):
24
+ standard_secrets.append(
25
+ {
26
+ "kind": secret.get("kind", ""),
27
+ "data": secret.get("data", {}),
28
+ }
29
+ )
30
+
31
+ @staticmethod
32
+ def _parse_custom_secrets(
33
+ secret: Dict[str, Any],
34
+ custom_secrets: List[Dict[str, Any]],
35
+ ):
36
+ data = secret.get("data", {})
37
+ custom_secrets.append(
38
+ {
39
+ "kind": secret.get("kind", ""),
40
+ "data": {
41
+ "provider_slug": data.get("provider_slug"),
42
+ "provider": {
43
+ "kind": data.get("kind", ""),
44
+ "extras": (
45
+ {
46
+ **data["provider"]["extras"],
47
+ "api_base": data["provider"]["url"],
48
+ "api_version": data["provider"].get("version"),
49
+ }
50
+ if all(
51
+ k in data.get("provider", {}) for k in ["extras", "url"]
52
+ )
53
+ else data.get("provider", {}).get("extras", {})
54
+ ),
55
+ },
56
+ "models": data.get("model_keys", []),
57
+ },
58
+ }
59
+ )
60
+
61
+ @staticmethod
62
+ def _parse_secrets(secrets: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
63
+ standard_secrets: List[dict] = []
64
+ custom_secrets: List[dict] = []
65
+
66
+ for secret in secrets:
67
+ if secret.get("kind") == "provider_key":
68
+ SecretsManager._parse_standard_secrets(
69
+ secret=secret,
70
+ standard_secrets=standard_secrets,
71
+ ) # append secret to standard_secrets
72
+ elif secret.get("kind") == "custom_provider":
73
+ SecretsManager._parse_custom_secrets(
74
+ secret=secret,
75
+ custom_secrets=custom_secrets,
76
+ ) # append secret to custom_secrets
77
+
78
+ secrets = standard_secrets + custom_secrets
79
+
80
+ return secrets
81
+
82
+ @staticmethod
83
+ def _custom_provider_get_value(
84
+ *, model: str, secrets: list[dict], key: str, from_provider: bool = True
85
+ ):
86
+ for secret in secrets:
87
+ models = secret.get("data", {}).get("models", [])
88
+ if model in models:
89
+ if from_provider:
90
+ return secret.get("data", {}).get("provider", {}).get(key)
91
+ return secret.get("data", {}).get(key)
92
+ return None
93
+
94
+ @staticmethod
95
+ def _custom_providers_get(*, model: str, secrets: list[dict]):
96
+ return SecretsManager._custom_provider_get_value(
97
+ model=model, secrets=secrets, key="kind", from_provider=True
98
+ )
99
+
100
+ @staticmethod
101
+ def _custom_provider_slug_get(*, model: str, secrets: list[dict]):
102
+ return SecretsManager._custom_provider_get_value(
103
+ model=model, secrets=secrets, key="provider_slug", from_provider=False
104
+ )
23
105
 
106
+ @staticmethod
107
+ def _get_compatible_model(*, model: str, provider_slug: str):
108
+ """Return the model string used by litellm.
109
+
110
+ Args:
111
+ model (str): The complete model string (e.g. `mybedrock/bedrock/model_name`).
112
+ In the format provider_slug/kind/model_name (See SecretResponseDTO)
113
+ provider_slug (str): The provider slug (e.g. `mybedrock`)
114
+
115
+ Returns:
116
+ str: The model string used by litellm
117
+ """
118
+ # First replace provider_slug/custom with openai.
119
+ # The reason is that custom providers are in fact openai compatible providers
120
+ # They need to be passed in litellm as openai/modelname
121
+
122
+ if "custom" in model:
123
+ modified_model = model.replace(f"{provider_slug}/custom/", "openai/")
124
+ return modified_model.replace(f"{provider_slug}/", "")
125
+
126
+ return model.replace(f"{provider_slug}/", "")
127
+
128
+ @staticmethod
129
+ def get_provider_settings(model: str) -> Optional[Dict]:
130
+ """
131
+ Builds the LLM request with appropriate kwargs based on the custom provider/model
132
+
133
+ Args:
134
+ model (str): The name of the model
135
+
136
+ Returns:
137
+ Dict: A dictionary containing all parameters needed for litellm.completion
138
+ """
139
+
140
+ # STEP 1: get vault secrets from route context and transform it
141
+ secrets = SecretsManager.get_from_route()
24
142
  if not secrets:
25
143
  return None
26
144
 
27
- provider = model_to_provider_mapping.get(model)
145
+ # STEP 1b: Parse secrets into usable format
146
+ secrets = SecretsManager._parse_secrets(secrets=secrets)
147
+
148
+ # STEP 2: check model exists in supported standard models
149
+ provider = _standard_providers.get(model)
150
+ if not provider:
151
+ # check and get provider kind if model exists in custom provider models
152
+ provider = SecretsManager._custom_providers_get(
153
+ model=model,
154
+ secrets=secrets,
155
+ )
28
156
 
157
+ # STEP 2b: return None in the case provider is None
29
158
  if not provider:
30
159
  return None
31
160
 
32
- provider = provider.lower().replace(" ", "")
161
+ # STEP 2c: get litellm compatible model
162
+ provider_slug = SecretsManager._custom_provider_slug_get(
163
+ model=model, secrets=secrets
164
+ )
165
+ model = SecretsManager._get_compatible_model(
166
+ model=model, provider_slug=provider_slug
167
+ )
33
168
 
169
+ # STEP 3: initialize provider settings and simplify provider name
170
+ provider_settings = {"model": model}
171
+ provider_name = re.sub(
172
+ r"[\s-]+", "", provider.lower()
173
+ ) # normalizing other special characters too (azure-openai)
174
+
175
+ # STEP 4: get credentials for model
34
176
  for secret in secrets:
35
- if secret["data"]["provider"] == provider:
36
- return secret["data"]["key"]
177
+ secret_data = secret.get("data", {})
178
+ provider_info = secret_data.get("provider", {})
37
179
 
38
- return None
180
+ # i). Extract API key if present
181
+ # (for standard models -- openai/anthropic/gemini, etc)
182
+ if secret.get("kind") == "provider_key":
183
+ provider_kind = secret_data.get("kind", "")
184
+
185
+ if provider_kind == provider_name:
186
+ if "key" in provider_info:
187
+ provider_settings["api_key"] = provider_info["key"]
188
+ continue
189
+
190
+ # ii). Extract Credentials if present
191
+ # (for custom providers -- aws bedrock/sagemaker, vertexai, etc)
192
+ elif secret.get("kind") == "custom_provider":
193
+ provider_kind = provider_info.get("kind", "").lower().replace(" ", "")
194
+ provider_slug = secret_data.get("provider_slug", "")
195
+ provider_extras = provider_info.get("extras", {})
196
+
197
+ if provider_kind == provider_name or provider_slug == provider_name:
198
+ if provider_extras:
199
+ provider_settings.update(provider_extras)
200
+ continue
201
+
202
+ return provider_settings
@@ -7,9 +7,9 @@ from agenta.sdk.types import (
7
7
  ConfigurationResponse,
8
8
  DeploymentResponse,
9
9
  )
10
- from agenta.client.types.config_dto import ConfigDto as ConfigRequest
11
- from agenta.client.types.config_response_model import ConfigResponseModel
12
- from agenta.client.types.reference_request_model import ReferenceRequestModel
10
+ from agenta.client.backend.types.config_dto import ConfigDto as ConfigRequest
11
+ from agenta.client.backend.types.config_response_model import ConfigResponseModel
12
+ from agenta.client.backend.types.reference_request_model import ReferenceRequestModel
13
13
 
14
14
  import agenta as ag
15
15
 
@@ -7,22 +7,23 @@ from fastapi import FastAPI, Request
7
7
  from starlette.middleware.base import BaseHTTPMiddleware
8
8
 
9
9
  from agenta.sdk.utils.constants import TRUTHY
10
- from agenta.client.types.provider_kind import ProviderKind
10
+ from agenta.sdk.utils.cache import TTLLRUCache
11
11
  from agenta.sdk.utils.exceptions import suppress, display_exception
12
- from agenta.client.types.secret_dto import SecretDto as SecretDTO
13
- from agenta.client.types.provider_key_dto import (
14
- ProviderKeyDto as ProviderKeyDTO,
12
+ from agenta.client.backend.types import SecretDto as SecretDTO
13
+ from agenta.client.backend.types import (
14
+ StandardProviderKind,
15
+ StandardProviderDto as StandardProviderDTO,
16
+ StandardProviderSettingsDto as StandardProviderSettingsDTO,
15
17
  )
16
- from agenta.sdk.utils.cache import TTLLRUCache
17
18
 
18
19
  import agenta as ag
19
20
 
20
21
 
21
22
  _PROVIDER_KINDS = []
22
23
 
23
- for arg in ProviderKind.__args__: # type: ignore
24
- if hasattr(arg, "__args__"):
25
- _PROVIDER_KINDS.extend(arg.__args__)
24
+ for provider_kind in StandardProviderKind.__args__[0].__args__: # type: ignore
25
+ if hasattr(provider_kind, "__args__"):
26
+ _PROVIDER_KINDS.extend(provider_kind.__args__)
26
27
 
27
28
  _CACHE_ENABLED = getenv("AGENTA_MIDDLEWARE_CACHE_ENABLED", "false").lower() in TRUTHY
28
29
 
@@ -35,18 +36,6 @@ class VaultMiddleware(BaseHTTPMiddleware):
35
36
 
36
37
  self.host = ag.DEFAULT_AGENTA_SINGLETON_INSTANCE.host
37
38
 
38
- def _transform_secrets_response_to_secret_dto(
39
- self, secrets_list: List[Dict[str, Any]]
40
- ) -> List[Dict[str, Any]]:
41
- secrets_dto_dict = [
42
- {
43
- "kind": secret.get("secret", {}).get("kind"),
44
- "data": secret.get("secret", {}).get("data", {}),
45
- }
46
- for secret in secrets_list
47
- ]
48
- return secrets_dto_dict
49
-
50
39
  async def dispatch(
51
40
  self,
52
41
  request: Request,
@@ -83,7 +72,7 @@ class VaultMiddleware(BaseHTTPMiddleware):
83
72
 
84
73
  return secrets
85
74
 
86
- local_secrets: List[SecretDTO] = []
75
+ local_secrets: List[Dict[str, Any]] = []
87
76
 
88
77
  try:
89
78
  for provider_kind in _PROVIDER_KINDS:
@@ -95,18 +84,18 @@ class VaultMiddleware(BaseHTTPMiddleware):
95
84
  continue
96
85
 
97
86
  secret = SecretDTO(
98
- # kind=... # defaults to 'provider_kind'
99
- data=ProviderKeyDTO(
100
- provider=provider,
101
- key=key,
87
+ kind="provider_kind", # type: ignore
88
+ data=StandardProviderDTO(
89
+ kind=provider,
90
+ provider=StandardProviderSettingsDTO(key=key),
102
91
  ),
103
92
  )
104
93
 
105
- local_secrets.append(secret.model_dump()) # type: ignore
94
+ local_secrets.append(secret.model_dump())
106
95
  except: # pylint: disable=bare-except
107
96
  display_exception("Vault: Local Secrets Exception")
108
97
 
109
- vault_secrets: List[SecretDTO] = []
98
+ vault_secrets: List[Dict[str, Any]] = []
110
99
 
111
100
  try:
112
101
  async with httpx.AsyncClient() as client:
@@ -119,26 +108,29 @@ class VaultMiddleware(BaseHTTPMiddleware):
119
108
  vault_secrets = []
120
109
 
121
110
  else:
122
- secrets = response.json()
123
- vault_secrets = self._transform_secrets_response_to_secret_dto(
124
- secrets_list=secrets # type: ignore
125
- )
111
+ vault_secrets = response.json()
126
112
  except: # pylint: disable=bare-except
127
113
  display_exception("Vault: Vault Secrets Exception")
128
114
 
129
- merged_secrets = {}
115
+ secrets = local_secrets + vault_secrets
116
+
117
+ standard_secrets = {}
118
+ custom_secrets = []
130
119
 
131
120
  if local_secrets:
132
121
  for secret in local_secrets:
133
- provider = secret["data"]["provider"] # type: ignore
134
- merged_secrets[provider] = secret
122
+ standard_secrets[secret["data"]["kind"]] = secret # type: ignore
135
123
 
136
124
  if vault_secrets:
137
125
  for secret in vault_secrets:
138
- provider = secret["data"]["provider"] # type: ignore
139
- merged_secrets[provider] = secret
126
+ if secret["kind"] == "provider_key": # type: ignore
127
+ standard_secrets[secret["data"]["kind"]] = secret # type: ignore
128
+ elif secret["kind"] == "custom_provider": # type: ignore
129
+ custom_secrets.append(secret)
130
+
131
+ standard_secrets = list(standard_secrets.values())
140
132
 
141
- secrets = list(merged_secrets.values())
133
+ secrets = standard_secrets + custom_secrets
142
134
 
143
135
  _cache.put(_hash, {"secrets": secrets})
144
136
 
agenta/sdk/types.py CHANGED
@@ -1,14 +1,12 @@
1
1
  import json
2
2
  from dataclasses import dataclass
3
- from typing import Dict, List, Optional, Any, Union
3
+ from typing import List, Union, Optional, Dict, Literal, Any
4
4
 
5
5
  from pydantic import ConfigDict, BaseModel, HttpUrl
6
-
7
- from agenta.client.types.agenta_node_dto import AgentaNodeDto
8
- from agenta.client.types.agenta_nodes_response import AgentaNodesResponse
9
- from typing import Annotated, List, Union, Optional, Dict, Literal, Any
10
6
  from pydantic import BaseModel, Field, model_validator
7
+
11
8
  from agenta.sdk.assets import supported_llm_models
9
+ from agenta.client.backend.types import AgentaNodesResponse, AgentaNodeDto
12
10
 
13
11
 
14
12
  @dataclass
@@ -543,8 +541,7 @@ class PromptTemplate(BaseModel):
543
541
  def to_openai_kwargs(self) -> dict:
544
542
  """Convert the prompt template to kwargs compatible with litellm/openai"""
545
543
  kwargs = {
546
- "model": self.llm_config.model,
547
- "messages": [msg.dict(exclude_none=True) for msg in self.messages],
544
+ "messages": [msg.model_dump(exclude_none=True) for msg in self.messages],
548
545
  }
549
546
 
550
547
  # Add optional parameters only if they are set
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: agenta
3
- Version: 0.36.5
3
+ Version: 0.37.0
4
4
  Summary: The SDK for agenta is an open-source LLMOps platform.
5
5
  Keywords: LLMOps,LLM,evaluation,prompt engineering
6
6
  Author: Mahmoud Mabrouk
@@ -15,20 +15,16 @@ Classifier: Programming Language :: Python :: 3.11
15
15
  Classifier: Programming Language :: Python :: 3.12
16
16
  Classifier: Programming Language :: Python :: 3.13
17
17
  Classifier: Topic :: Software Development :: Libraries
18
- Requires-Dist: cachetools (>=5.3.3,<6.0.0)
19
- Requires-Dist: docker (>=6.1.1,<8.0.0)
20
18
  Requires-Dist: fastapi (>=0.100.0)
21
19
  Requires-Dist: httpx (>=0.24,<0.28)
22
20
  Requires-Dist: importlib-metadata (>=8.0.0,<9.0)
23
21
  Requires-Dist: litellm (>=1.48.0,<2.0.0)
24
22
  Requires-Dist: opentelemetry-api (==1.27.0)
25
- Requires-Dist: opentelemetry-exporter-otlp (==1.27.0)
23
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http (==1.27.0)
26
24
  Requires-Dist: opentelemetry-sdk (==1.27.0)
27
- Requires-Dist: posthog (>=3.1.0,<4.0.0)
28
25
  Requires-Dist: pydantic (>=2)
29
26
  Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
30
27
  Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
31
- Requires-Dist: questionary (>=1.10,<3.0)
32
28
  Requires-Dist: toml (>=0.10.2,<0.11.0)
33
29
  Project-URL: Documentation, https://docs.agenta.ai
34
30
  Project-URL: Homepage, https://agenta.ai