agenta 0.57.0__py3-none-any.whl → 0.65.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.
Files changed (267) hide show
  1. agenta/__init__.py +12 -3
  2. agenta/client/__init__.py +4 -4
  3. agenta/client/backend/__init__.py +4 -4
  4. agenta/client/backend/api_keys/client.py +2 -2
  5. agenta/client/backend/billing/client.py +2 -2
  6. agenta/client/backend/billing/raw_client.py +2 -2
  7. agenta/client/backend/client.py +56 -48
  8. agenta/client/backend/core/client_wrapper.py +2 -2
  9. agenta/client/backend/core/file.py +3 -1
  10. agenta/client/backend/core/http_client.py +3 -3
  11. agenta/client/backend/core/pydantic_utilities.py +13 -3
  12. agenta/client/backend/human_evaluations/client.py +2 -2
  13. agenta/client/backend/human_evaluations/raw_client.py +2 -2
  14. agenta/client/backend/organization/client.py +46 -34
  15. agenta/client/backend/organization/raw_client.py +32 -26
  16. agenta/client/backend/raw_client.py +26 -26
  17. agenta/client/backend/testsets/client.py +18 -18
  18. agenta/client/backend/testsets/raw_client.py +30 -30
  19. agenta/client/backend/types/__init__.py +4 -4
  20. agenta/client/backend/types/account_request.py +3 -1
  21. agenta/client/backend/types/account_response.py +3 -1
  22. agenta/client/backend/types/agenta_node_dto.py +3 -1
  23. agenta/client/backend/types/agenta_nodes_response.py +3 -1
  24. agenta/client/backend/types/agenta_root_dto.py +3 -1
  25. agenta/client/backend/types/agenta_roots_response.py +3 -1
  26. agenta/client/backend/types/agenta_tree_dto.py +3 -1
  27. agenta/client/backend/types/agenta_trees_response.py +3 -1
  28. agenta/client/backend/types/aggregated_result.py +3 -1
  29. agenta/client/backend/types/analytics_response.py +3 -1
  30. agenta/client/backend/types/annotation.py +6 -4
  31. agenta/client/backend/types/annotation_create.py +3 -1
  32. agenta/client/backend/types/annotation_edit.py +3 -1
  33. agenta/client/backend/types/annotation_link.py +3 -1
  34. agenta/client/backend/types/annotation_link_response.py +3 -1
  35. agenta/client/backend/types/annotation_query.py +3 -1
  36. agenta/client/backend/types/annotation_query_request.py +3 -1
  37. agenta/client/backend/types/annotation_reference.py +3 -1
  38. agenta/client/backend/types/annotation_references.py +3 -1
  39. agenta/client/backend/types/annotation_response.py +3 -1
  40. agenta/client/backend/types/annotations_response.py +3 -1
  41. agenta/client/backend/types/app.py +3 -1
  42. agenta/client/backend/types/app_variant_response.py +3 -1
  43. agenta/client/backend/types/app_variant_revision.py +3 -1
  44. agenta/client/backend/types/artifact.py +6 -4
  45. agenta/client/backend/types/base_output.py +3 -1
  46. agenta/client/backend/types/body_fetch_workflow_revision.py +3 -1
  47. agenta/client/backend/types/body_import_testset.py +3 -1
  48. agenta/client/backend/types/bucket_dto.py +3 -1
  49. agenta/client/backend/types/collect_status_response.py +3 -1
  50. agenta/client/backend/types/config_db.py +3 -1
  51. agenta/client/backend/types/config_dto.py +3 -1
  52. agenta/client/backend/types/config_response_model.py +3 -1
  53. agenta/client/backend/types/correct_answer.py +3 -1
  54. agenta/client/backend/types/create_app_output.py +3 -1
  55. agenta/client/backend/types/custom_model_settings_dto.py +3 -1
  56. agenta/client/backend/types/custom_provider_dto.py +3 -1
  57. agenta/client/backend/types/custom_provider_kind.py +1 -1
  58. agenta/client/backend/types/custom_provider_settings_dto.py +3 -1
  59. agenta/client/backend/types/delete_evaluation.py +3 -1
  60. agenta/client/backend/types/environment_output.py +3 -1
  61. agenta/client/backend/types/environment_output_extended.py +3 -1
  62. agenta/client/backend/types/environment_revision.py +3 -1
  63. agenta/client/backend/types/error.py +3 -1
  64. agenta/client/backend/types/evaluation.py +3 -1
  65. agenta/client/backend/types/evaluation_scenario.py +3 -1
  66. agenta/client/backend/types/evaluation_scenario_input.py +3 -1
  67. agenta/client/backend/types/evaluation_scenario_output.py +3 -1
  68. agenta/client/backend/types/evaluation_scenario_result.py +3 -1
  69. agenta/client/backend/types/evaluator.py +6 -4
  70. agenta/client/backend/types/evaluator_config.py +6 -4
  71. agenta/client/backend/types/evaluator_flags.py +3 -1
  72. agenta/client/backend/types/evaluator_mapping_output_interface.py +3 -1
  73. agenta/client/backend/types/evaluator_output_interface.py +3 -1
  74. agenta/client/backend/types/evaluator_query.py +3 -1
  75. agenta/client/backend/types/evaluator_query_request.py +3 -1
  76. agenta/client/backend/types/evaluator_request.py +3 -1
  77. agenta/client/backend/types/evaluator_response.py +3 -1
  78. agenta/client/backend/types/evaluators_response.py +3 -1
  79. agenta/client/backend/types/exception_dto.py +3 -1
  80. agenta/client/backend/types/extended_o_tel_tracing_response.py +3 -1
  81. agenta/client/backend/types/get_config_response.py +3 -1
  82. agenta/client/backend/types/header.py +3 -1
  83. agenta/client/backend/types/http_validation_error.py +3 -1
  84. agenta/client/backend/types/human_evaluation.py +3 -1
  85. agenta/client/backend/types/human_evaluation_scenario.py +3 -1
  86. agenta/client/backend/types/human_evaluation_scenario_input.py +3 -1
  87. agenta/client/backend/types/human_evaluation_scenario_output.py +3 -1
  88. agenta/client/backend/types/invite_request.py +3 -1
  89. agenta/client/backend/types/legacy_analytics_response.py +3 -1
  90. agenta/client/backend/types/legacy_data_point.py +3 -1
  91. agenta/client/backend/types/legacy_evaluator.py +3 -1
  92. agenta/client/backend/types/legacy_scope_request.py +3 -1
  93. agenta/client/backend/types/legacy_scopes_response.py +3 -1
  94. agenta/client/backend/types/legacy_subscription_request.py +3 -1
  95. agenta/client/backend/types/legacy_user_request.py +3 -1
  96. agenta/client/backend/types/legacy_user_response.py +3 -1
  97. agenta/client/backend/types/lifecycle_dto.py +3 -1
  98. agenta/client/backend/types/link_dto.py +3 -1
  99. agenta/client/backend/types/list_api_keys_response.py +3 -1
  100. agenta/client/backend/types/llm_run_rate_limit.py +3 -1
  101. agenta/client/backend/types/meta_request.py +3 -1
  102. agenta/client/backend/types/metrics_dto.py +3 -1
  103. agenta/client/backend/types/new_testset.py +3 -1
  104. agenta/client/backend/types/node_dto.py +3 -1
  105. agenta/client/backend/types/o_tel_context_dto.py +3 -1
  106. agenta/client/backend/types/o_tel_event.py +6 -4
  107. agenta/client/backend/types/o_tel_event_dto.py +3 -1
  108. agenta/client/backend/types/o_tel_extra_dto.py +3 -1
  109. agenta/client/backend/types/o_tel_flat_span.py +6 -4
  110. agenta/client/backend/types/o_tel_link.py +6 -4
  111. agenta/client/backend/types/o_tel_link_dto.py +3 -1
  112. agenta/client/backend/types/o_tel_links_response.py +3 -1
  113. agenta/client/backend/types/o_tel_span.py +1 -1
  114. agenta/client/backend/types/o_tel_span_dto.py +3 -1
  115. agenta/client/backend/types/o_tel_spans_tree.py +3 -1
  116. agenta/client/backend/types/o_tel_tracing_data_response.py +3 -1
  117. agenta/client/backend/types/o_tel_tracing_request.py +3 -1
  118. agenta/client/backend/types/o_tel_tracing_response.py +3 -1
  119. agenta/client/backend/types/organization.py +3 -1
  120. agenta/client/backend/types/organization_details.py +3 -1
  121. agenta/client/backend/types/organization_membership_request.py +3 -1
  122. agenta/client/backend/types/organization_output.py +3 -1
  123. agenta/client/backend/types/organization_request.py +3 -1
  124. agenta/client/backend/types/parent_dto.py +3 -1
  125. agenta/client/backend/types/project_membership_request.py +3 -1
  126. agenta/client/backend/types/project_request.py +3 -1
  127. agenta/client/backend/types/project_scope.py +3 -1
  128. agenta/client/backend/types/projects_response.py +4 -1
  129. agenta/client/backend/types/reference.py +6 -4
  130. agenta/client/backend/types/reference_dto.py +3 -1
  131. agenta/client/backend/types/reference_request_model.py +3 -1
  132. agenta/client/backend/types/result.py +3 -1
  133. agenta/client/backend/types/root_dto.py +3 -1
  134. agenta/client/backend/types/scopes_response_model.py +3 -1
  135. agenta/client/backend/types/secret_dto.py +3 -1
  136. agenta/client/backend/types/secret_response_dto.py +3 -1
  137. agenta/client/backend/types/simple_evaluation_output.py +3 -1
  138. agenta/client/backend/types/span_dto.py +6 -4
  139. agenta/client/backend/types/standard_provider_dto.py +3 -1
  140. agenta/client/backend/types/standard_provider_settings_dto.py +3 -1
  141. agenta/client/backend/types/status_dto.py +3 -1
  142. agenta/client/backend/types/tags_request.py +3 -1
  143. agenta/client/backend/types/testcase_response.py +6 -4
  144. agenta/client/backend/types/testset.py +6 -4
  145. agenta/client/backend/types/{test_set_output_response.py → testset_output_response.py} +4 -2
  146. agenta/client/backend/types/testset_request.py +3 -1
  147. agenta/client/backend/types/testset_response.py +3 -1
  148. agenta/client/backend/types/{test_set_simple_response.py → testset_simple_response.py} +4 -2
  149. agenta/client/backend/types/testsets_response.py +3 -1
  150. agenta/client/backend/types/time_dto.py +3 -1
  151. agenta/client/backend/types/tree_dto.py +3 -1
  152. agenta/client/backend/types/update_app_output.py +3 -1
  153. agenta/client/backend/types/user_request.py +3 -1
  154. agenta/client/backend/types/validation_error.py +3 -1
  155. agenta/client/backend/types/workflow_artifact.py +6 -4
  156. agenta/client/backend/types/workflow_data.py +3 -1
  157. agenta/client/backend/types/workflow_flags.py +3 -1
  158. agenta/client/backend/types/workflow_request.py +3 -1
  159. agenta/client/backend/types/workflow_response.py +3 -1
  160. agenta/client/backend/types/workflow_revision.py +6 -4
  161. agenta/client/backend/types/workflow_revision_request.py +3 -1
  162. agenta/client/backend/types/workflow_revision_response.py +3 -1
  163. agenta/client/backend/types/workflow_revisions_response.py +3 -1
  164. agenta/client/backend/types/workflow_variant.py +6 -4
  165. agenta/client/backend/types/workflow_variant_request.py +3 -1
  166. agenta/client/backend/types/workflow_variant_response.py +3 -1
  167. agenta/client/backend/types/workflow_variants_response.py +3 -1
  168. agenta/client/backend/types/workflows_response.py +3 -1
  169. agenta/client/backend/types/workspace.py +3 -1
  170. agenta/client/backend/types/workspace_member_response.py +3 -1
  171. agenta/client/backend/types/workspace_membership_request.py +3 -1
  172. agenta/client/backend/types/workspace_permission.py +3 -1
  173. agenta/client/backend/types/workspace_request.py +3 -1
  174. agenta/client/backend/types/workspace_response.py +3 -1
  175. agenta/client/backend/workspace/client.py +2 -2
  176. agenta/client/client.py +102 -88
  177. agenta/sdk/__init__.py +52 -3
  178. agenta/sdk/agenta_init.py +43 -16
  179. agenta/sdk/assets.py +22 -15
  180. agenta/sdk/context/serving.py +20 -8
  181. agenta/sdk/context/tracing.py +40 -22
  182. agenta/sdk/contexts/__init__.py +0 -0
  183. agenta/sdk/contexts/routing.py +38 -0
  184. agenta/sdk/contexts/running.py +57 -0
  185. agenta/sdk/contexts/tracing.py +86 -0
  186. agenta/sdk/decorators/__init__.py +1 -0
  187. agenta/sdk/decorators/routing.py +284 -0
  188. agenta/sdk/decorators/running.py +692 -98
  189. agenta/sdk/decorators/serving.py +20 -21
  190. agenta/sdk/decorators/tracing.py +176 -131
  191. agenta/sdk/engines/__init__.py +0 -0
  192. agenta/sdk/engines/running/__init__.py +0 -0
  193. agenta/sdk/engines/running/utils.py +17 -0
  194. agenta/sdk/engines/tracing/__init__.py +1 -0
  195. agenta/sdk/engines/tracing/attributes.py +185 -0
  196. agenta/sdk/engines/tracing/conventions.py +49 -0
  197. agenta/sdk/engines/tracing/exporters.py +130 -0
  198. agenta/sdk/engines/tracing/inline.py +1154 -0
  199. agenta/sdk/engines/tracing/processors.py +190 -0
  200. agenta/sdk/engines/tracing/propagation.py +102 -0
  201. agenta/sdk/engines/tracing/spans.py +136 -0
  202. agenta/sdk/engines/tracing/tracing.py +324 -0
  203. agenta/sdk/evaluations/__init__.py +2 -0
  204. agenta/sdk/evaluations/metrics.py +37 -0
  205. agenta/sdk/evaluations/preview/__init__.py +0 -0
  206. agenta/sdk/evaluations/preview/evaluate.py +765 -0
  207. agenta/sdk/evaluations/preview/utils.py +861 -0
  208. agenta/sdk/evaluations/results.py +66 -0
  209. agenta/sdk/evaluations/runs.py +152 -0
  210. agenta/sdk/evaluations/scenarios.py +48 -0
  211. agenta/sdk/litellm/litellm.py +12 -0
  212. agenta/sdk/litellm/mockllm.py +6 -8
  213. agenta/sdk/litellm/mocks/__init__.py +5 -5
  214. agenta/sdk/managers/applications.py +304 -0
  215. agenta/sdk/managers/config.py +2 -2
  216. agenta/sdk/managers/evaluations.py +0 -0
  217. agenta/sdk/managers/evaluators.py +303 -0
  218. agenta/sdk/managers/secrets.py +161 -24
  219. agenta/sdk/managers/shared.py +3 -1
  220. agenta/sdk/managers/testsets.py +441 -0
  221. agenta/sdk/managers/vault.py +3 -3
  222. agenta/sdk/middleware/auth.py +0 -176
  223. agenta/sdk/middleware/vault.py +203 -8
  224. agenta/sdk/middlewares/__init__.py +0 -0
  225. agenta/sdk/middlewares/routing/__init__.py +0 -0
  226. agenta/sdk/middlewares/routing/auth.py +263 -0
  227. agenta/sdk/middlewares/routing/cors.py +30 -0
  228. agenta/sdk/middlewares/routing/otel.py +29 -0
  229. agenta/sdk/middlewares/running/__init__.py +0 -0
  230. agenta/sdk/middlewares/running/normalizer.py +321 -0
  231. agenta/sdk/middlewares/running/resolver.py +161 -0
  232. agenta/sdk/middlewares/running/vault.py +140 -0
  233. agenta/sdk/models/__init__.py +0 -0
  234. agenta/sdk/models/blobs.py +33 -0
  235. agenta/sdk/models/evaluations.py +119 -0
  236. agenta/sdk/models/git.py +126 -0
  237. agenta/sdk/models/shared.py +167 -0
  238. agenta/sdk/models/testsets.py +163 -0
  239. agenta/sdk/models/tracing.py +202 -0
  240. agenta/sdk/models/workflows.py +753 -0
  241. agenta/sdk/tracing/exporters.py +67 -17
  242. agenta/sdk/tracing/processors.py +97 -0
  243. agenta/sdk/tracing/propagation.py +3 -1
  244. agenta/sdk/tracing/spans.py +4 -0
  245. agenta/sdk/tracing/tracing.py +13 -13
  246. agenta/sdk/types.py +211 -17
  247. agenta/sdk/utils/cache.py +1 -1
  248. agenta/sdk/utils/client.py +38 -0
  249. agenta/sdk/utils/helpers.py +13 -12
  250. agenta/sdk/utils/logging.py +18 -78
  251. agenta/sdk/utils/references.py +23 -0
  252. agenta/sdk/workflows/builtin.py +600 -0
  253. agenta/sdk/workflows/configurations.py +22 -0
  254. agenta/sdk/workflows/errors.py +292 -0
  255. agenta/sdk/workflows/handlers.py +1791 -0
  256. agenta/sdk/workflows/interfaces.py +948 -0
  257. agenta/sdk/workflows/sandbox.py +118 -0
  258. agenta/sdk/workflows/utils.py +303 -6
  259. {agenta-0.57.0.dist-info → agenta-0.65.0.dist-info}/METADATA +44 -47
  260. agenta-0.65.0.dist-info/RECORD +421 -0
  261. agenta/sdk/middleware/adapt.py +0 -253
  262. agenta/sdk/middleware/base.py +0 -40
  263. agenta/sdk/middleware/flags.py +0 -40
  264. agenta/sdk/workflows/types.py +0 -472
  265. agenta-0.57.0.dist-info/RECORD +0 -371
  266. /agenta/sdk/{workflows → engines/running}/registry.py +0 -0
  267. {agenta-0.57.0.dist-info → agenta-0.65.0.dist-info}/WHEEL +0 -0
agenta/sdk/__init__.py CHANGED
@@ -2,6 +2,50 @@ from typing import Optional, Callable, Any
2
2
 
3
3
  from .utils.preinit import PreInitObject # always the first import!
4
4
 
5
+ __all__ = [
6
+ # Decorators
7
+ "workflow",
8
+ "application",
9
+ "evaluator",
10
+ "instrument",
11
+ "route",
12
+ "app",
13
+ # Initialization
14
+ "init",
15
+ "config",
16
+ # Types
17
+ "DictInput",
18
+ "MultipleChoice",
19
+ "FloatParam",
20
+ "IntParam",
21
+ "MultipleChoiceParam",
22
+ "GroupedMultipleChoiceParam",
23
+ "TextParam",
24
+ "MessagesInput",
25
+ "FileInputURL",
26
+ "BinaryParam",
27
+ "Prompt",
28
+ # Tracing
29
+ "Tracing",
30
+ "tracing",
31
+ "tracer",
32
+ "get_tracer",
33
+ "Reference",
34
+ # Managers
35
+ "AppManager",
36
+ "VaultManager",
37
+ "SecretsManager",
38
+ "ConfigManager",
39
+ "VariantManager",
40
+ "DeploymentManager",
41
+ # Utilities
42
+ "calculate_token_usage",
43
+ # API clients
44
+ "api",
45
+ "async_api",
46
+ "types",
47
+ ]
48
+
5
49
  import agenta.client.backend.types as client_types # pylint: disable=wrong-import-order
6
50
 
7
51
  from .types import (
@@ -21,9 +65,13 @@ from .types import (
21
65
  )
22
66
 
23
67
  from .tracing import Tracing, get_tracer
24
- from .decorators.tracing import instrument
25
- from .decorators.running import workflow, workflows
26
- from .decorators.serving import entrypoint, app, route
68
+ from agenta.sdk.decorators.tracing import instrument
69
+ from agenta.sdk.decorators.running import (
70
+ workflow,
71
+ application,
72
+ evaluator,
73
+ )
74
+ from agenta.sdk.decorators.serving import route, app
27
75
  from .tracing.conventions import Reference
28
76
  from .agenta_init import Config, AgentaSingleton, init as _init
29
77
  from .utils.costs import calculate_token_usage
@@ -33,6 +81,7 @@ from .managers.secrets import SecretsManager
33
81
  from .managers.config import ConfigManager
34
82
  from .managers.variant import VariantManager
35
83
  from .managers.deployment import DeploymentManager
84
+ from .managers import testsets as testsets
36
85
 
37
86
 
38
87
  config = PreInitObject("agenta.config", Config)
agenta/sdk/agenta_init.py CHANGED
@@ -9,7 +9,7 @@ from agenta.sdk.utils.logging import get_module_logger
9
9
  from agenta.client.client import AgentaApi, AsyncAgentaApi
10
10
 
11
11
  from agenta.sdk.tracing import Tracing
12
- from agenta.sdk.context.serving import serving_context
12
+ from agenta.sdk.contexts.routing import RoutingContext
13
13
 
14
14
 
15
15
  log = get_module_logger(__name__)
@@ -27,6 +27,7 @@ class AgentaSingleton:
27
27
 
28
28
  def __init__(self):
29
29
  self.host = None
30
+ self.api_url = None
30
31
  self.api_key = None
31
32
 
32
33
  self.scope_type = None
@@ -41,6 +42,7 @@ class AgentaSingleton:
41
42
  self,
42
43
  *,
43
44
  host: Optional[str] = None,
45
+ api_url: Optional[str] = None,
44
46
  api_key: Optional[str] = None,
45
47
  config_fname: Optional[str] = None,
46
48
  redact: Optional[Callable[..., Any]] = None,
@@ -68,7 +70,7 @@ class AgentaSingleton:
68
70
 
69
71
  """
70
72
 
71
- log.info("Agenta - SDK version: %s", version("agenta"))
73
+ log.info("Agenta - SDK ver: %s", version("agenta"))
72
74
 
73
75
  config = {}
74
76
  if config_fname:
@@ -77,36 +79,59 @@ class AgentaSingleton:
77
79
  _host = (
78
80
  host
79
81
  or getenv("AGENTA_HOST")
80
- or config.get("backend_host")
81
82
  or config.get("host")
82
- or getenv("AGENTA_API_URL", "https://cloud.agenta.ai")
83
+ or "https://cloud.agenta.ai"
83
84
  )
84
85
 
86
+ _api_url = (
87
+ api_url
88
+ or getenv("AGENTA_API_INTERNAL_URL")
89
+ or getenv("AGENTA_API_URL")
90
+ or config.get("api_url")
91
+ or None # NO FALLBACK
92
+ )
93
+
94
+ if _api_url:
95
+ _api_url = parse_url(url=_api_url)
96
+ _host = _api_url.rsplit("/api", 1)[0]
97
+ elif _host:
98
+ _host = parse_url(url=_host)
99
+ _api_url = _host + "/api"
100
+
85
101
  try:
86
- assert _host and isinstance(
87
- _host, str
88
- ), "Host is required. Please provide a valid host or set AGENTA_HOST environment variable."
89
- self.host = parse_url(url=_host)
102
+ assert _api_url and isinstance(_api_url, str), (
103
+ "API URL is required. Please provide a valid API URL or set AGENTA_API_URL environment variable."
104
+ )
105
+ self.host = _host
106
+ self.api_url = _api_url
90
107
  except AssertionError as e:
91
108
  log.error(str(e))
92
109
  raise
93
110
  except Exception as e:
94
- log.error(f"Failed to parse host URL '{_host}': {e}")
111
+ log.error(f"Failed to parse API URL '{_api_url}': {e}")
95
112
  raise
96
113
 
97
- log.info("Agenta - Host: %s", self.host)
114
+ self.api_key = (
115
+ api_key
116
+ or getenv("AGENTA_API_KEY")
117
+ or config.get("api_key")
118
+ or None # NO FALLBACK
119
+ )
98
120
 
99
- self.api_key = api_key or getenv("AGENTA_API_KEY") or config.get("api_key")
121
+ log.info("Agenta - API URL: %s", self.api_url)
100
122
 
101
123
  self.scope_type = (
102
124
  scope_type
103
125
  or getenv("AGENTA_SCOPE_TYPE")
104
126
  or config.get("scope_type")
105
- or None
127
+ or None # NO FALLBACK
106
128
  )
107
129
 
108
130
  self.scope_id = (
109
- scope_id or getenv("AGENTA_SCOPE_ID") or config.get("scope_id") or None
131
+ scope_id
132
+ or getenv("AGENTA_SCOPE_ID")
133
+ or config.get("scope_id")
134
+ or None # NO FALLBACK
110
135
  )
111
136
 
112
137
  self.tracing = Tracing(
@@ -120,12 +145,12 @@ class AgentaSingleton:
120
145
  )
121
146
 
122
147
  self.api = AgentaApi(
123
- base_url=self.host + "/api",
148
+ base_url=self.api_url,
124
149
  api_key=self.api_key if self.api_key else "",
125
150
  )
126
151
 
127
152
  self.async_api = AsyncAgentaApi(
128
- base_url=self.host + "/api",
153
+ base_url=self.api_url,
129
154
  api_key=self.api_key if self.api_key else "",
130
155
  )
131
156
 
@@ -149,7 +174,7 @@ class Config:
149
174
  return self.default_parameters
150
175
 
151
176
  def __getattr__(self, key):
152
- context = serving_context.get()
177
+ context = RoutingContext.get()
153
178
 
154
179
  parameters = context.parameters
155
180
 
@@ -172,6 +197,7 @@ class Config:
172
197
 
173
198
  def init(
174
199
  host: Optional[str] = None,
200
+ api_url: Optional[str] = None,
175
201
  api_key: Optional[str] = None,
176
202
  config_fname: Optional[str] = None,
177
203
  redact: Optional[Callable[..., Any]] = None,
@@ -200,6 +226,7 @@ def init(
200
226
 
201
227
  singleton.init(
202
228
  host=host,
229
+ api_url=api_url,
203
230
  api_key=api_key,
204
231
  config_fname=config_fname,
205
232
  redact=redact,
agenta/sdk/assets.py CHANGED
@@ -1,6 +1,8 @@
1
1
  supported_llm_models = {
2
- "Anthropic": [
2
+ "anthropic": [
3
3
  "anthropic/claude-sonnet-4-5",
4
+ "anthropic/claude-haiku-4-5",
5
+ "anthropic/claude-opus-4-1",
4
6
  "anthropic/claude-sonnet-4-20250514",
5
7
  "anthropic/claude-opus-4-20250514",
6
8
  "anthropic/claude-3-7-sonnet-20250219",
@@ -13,29 +15,33 @@ supported_llm_models = {
13
15
  "anthropic/claude-2.1",
14
16
  "anthropic/claude-2",
15
17
  ],
16
- "Cohere": [
18
+ "cohere": [
17
19
  "cohere/command-light",
18
20
  "cohere/command-r-plus",
19
21
  "cohere/command-nightly",
20
22
  ],
21
- "DeepInfra": [
23
+ "deepinfra": [
22
24
  "deepinfra/meta-llama/Llama-2-70b-chat-hf",
23
25
  "deepinfra/meta-llama/Llama-2-13b-chat-hf",
24
26
  "deepinfra/codellama/CodeLlama-34b-Instruct-hf",
25
27
  "deepinfra/mistralai/Mistral-7B-Instruct-v0.1",
26
28
  ],
27
- "Gemini": [
29
+ "gemini": [
30
+ "gemini/gemini-3-pro-preview",
31
+ "gemini/gemini-2.5-pro",
32
+ "gemini/gemini-2.5-pro-preview-05-06",
33
+ "gemini/gemini-2.5-flash",
34
+ "gemini/gemini-2.5-flash-preview-09-2025",
28
35
  "gemini/gemini-2.5-flash-preview-05-20",
29
36
  "gemini/gemini-2.5-flash-preview-04-17",
37
+ "gemini/gemini-2.5-flash-lite",
38
+ "gemini/gemini-2.5-flash-lite-preview-09-2025",
39
+ "gemini/gemini-2.0-flash",
30
40
  "gemini/gemini-2.0-flash-001",
31
- "gemini/gemini-2.5-pro-preview-05-06",
32
- "gemini/gemini-2.0-flash-lite-preview-02-05",
33
- "gemini/gemini-1.5-pro-latest",
34
41
  "gemini/gemini-2.0-flash-lite",
35
- "gemini/gemini-1.5-flash",
36
- "gemini/gemini-1.5-flash-8b",
42
+ "gemini/gemini-2.0-flash-lite-preview-02-05",
37
43
  ],
38
- "Groq": [
44
+ "groq": [
39
45
  "groq/deepseek-r1-distill-llama-70b",
40
46
  "groq/deepseek-r1-distill-llama-70b-specdec",
41
47
  "groq/gemma2-9b-it",
@@ -51,14 +57,15 @@ supported_llm_models = {
51
57
  "groq/llama3-8b-8192",
52
58
  "groq/mixtral-8x7b-32768",
53
59
  ],
54
- "Mistral": [
60
+ "mistral": [
55
61
  "mistral/mistral-tiny",
56
62
  "mistral/mistral-small",
57
63
  "mistral/mistral-medium",
58
64
  "mistral/mistral-large-latest",
59
65
  ],
60
- "OpenAI": [
66
+ "openai": [
61
67
  "gpt-5",
68
+ "gpt-5.1",
62
69
  "gpt-5-mini",
63
70
  "gpt-5-nano",
64
71
  "gpt-4.5-preview",
@@ -73,7 +80,7 @@ supported_llm_models = {
73
80
  "gpt-4.1-nano",
74
81
  "o4-mini",
75
82
  ],
76
- "OpenRouter": [
83
+ "openrouter": [
77
84
  "openrouter/qwen/qwen3-235b-a22b",
78
85
  "openrouter/qwen/qwen3-32b",
79
86
  "openrouter/qwen/qwen3-30b-a3b",
@@ -143,13 +150,13 @@ supported_llm_models = {
143
150
  "openrouter/google/gemini-2.0-flash-001",
144
151
  "openrouter/perplexity/sonar-reasoning",
145
152
  ],
146
- "Perplexity AI": [
153
+ "perplexity": [
147
154
  "perplexity/sonar",
148
155
  "perplexity/sonar-pro",
149
156
  "perplexity/sonar-reasoning",
150
157
  "perplexity/sonar-reasoning-pro",
151
158
  ],
152
- "togetherai": [
159
+ "together_ai": [
153
160
  "together_ai/deepseek-ai/DeepSeek-R1",
154
161
  "together_ai/deepseek-ai/DeepSeek-R1-Distill-Llama-70B",
155
162
  "together_ai/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
@@ -1,7 +1,7 @@
1
1
  from typing import Any, Dict, List, Optional
2
2
 
3
3
  from contextlib import contextmanager
4
- from contextvars import ContextVar
4
+ from contextvars import ContextVar, Token
5
5
 
6
6
  from pydantic import BaseModel
7
7
 
@@ -11,17 +11,29 @@ class RoutingContext(BaseModel):
11
11
  secrets: Optional[List[Any]] = None
12
12
  mock: Optional[str] = None
13
13
 
14
+ @classmethod
15
+ def get(cls) -> "RoutingContext":
16
+ try:
17
+ return routing_context.get()
18
+ except LookupError:
19
+ return RoutingContext()
14
20
 
15
- serving_context = ContextVar("serving_context", default=RoutingContext())
21
+ @classmethod
22
+ def set(cls, ctx: "RoutingContext") -> Token:
23
+ return routing_context.set(ctx)
24
+
25
+ @classmethod
26
+ def reset(cls, token: Token) -> None:
27
+ return routing_context.reset(token)
28
+
29
+
30
+ routing_context: ContextVar[RoutingContext] = ContextVar("routing_context")
16
31
 
17
32
 
18
33
  @contextmanager
19
- def serving_context_manager(
20
- *,
21
- context: Optional[RoutingContext] = None,
22
- ):
23
- token = serving_context.set(context)
34
+ def routing_context_manager(context: RoutingContext):
35
+ token = RoutingContext.set(context)
24
36
  try:
25
37
  yield
26
38
  finally:
27
- serving_context.reset(token)
39
+ RoutingContext.reset(token)
@@ -1,7 +1,7 @@
1
1
  from typing import Any, Dict, Optional
2
2
 
3
3
  from contextlib import contextmanager
4
- from contextvars import ContextVar
4
+ from contextvars import ContextVar, Token
5
5
 
6
6
  from pydantic import BaseModel
7
7
 
@@ -15,42 +15,60 @@ class TracingContext(BaseModel):
15
15
  link: Optional[Dict[str, Any]] = None
16
16
  type: Optional[str] = None
17
17
 
18
+ @classmethod
19
+ def get(cls) -> "TracingContext":
20
+ try:
21
+ return tracing_context.get()
22
+ except LookupError:
23
+ return TracingContext()
18
24
 
19
- tracing_context = ContextVar(
20
- "ag.tracing_context",
21
- default=TracingContext(),
22
- )
25
+ @classmethod
26
+ def set(cls, ctx: "TracingContext") -> Token:
27
+ return tracing_context.set(ctx)
28
+
29
+ @classmethod
30
+ def reset(cls, token: Token) -> None:
31
+ return tracing_context.reset(token)
32
+
33
+
34
+ tracing_context: ContextVar[TracingContext] = ContextVar("ag.tracing_context")
23
35
 
24
36
 
25
37
  @contextmanager
26
- def tracing_context_manager(
27
- *,
28
- context: Optional[TracingContext] = None,
29
- ):
30
- token = tracing_context.set(context)
38
+ def tracing_context_manager(context: TracingContext):
39
+ token = TracingContext.set(context)
31
40
  try:
32
41
  yield
33
42
  finally:
34
- tracing_context.reset(token)
43
+ TracingContext.reset(token)
35
44
 
36
45
 
37
- class TracingExporterContext(BaseModel):
46
+ class OTLPContext(BaseModel):
38
47
  credentials: Optional[str] = None
39
48
 
49
+ @classmethod
50
+ def get(cls) -> "OTLPContext":
51
+ try:
52
+ return otlp_context.get()
53
+ except LookupError:
54
+ return OTLPContext()
55
+
56
+ @classmethod
57
+ def set(cls, ctx: "OTLPContext") -> Token:
58
+ return otlp_context.set(ctx)
59
+
60
+ @classmethod
61
+ def reset(cls, token: Token) -> None:
62
+ return otlp_context.reset(token)
63
+
40
64
 
41
- tracing_exporter_context = ContextVar(
42
- "ag.tracing_exporter_context",
43
- default=TracingExporterContext(),
44
- )
65
+ otlp_context: ContextVar[OTLPContext] = ContextVar("ag.otlp_context")
45
66
 
46
67
 
47
68
  @contextmanager
48
- def tracing_exporter_context_manager(
49
- *,
50
- context: Optional[TracingExporterContext] = None,
51
- ):
52
- token = tracing_exporter_context.set(context)
69
+ def otlp_context_manager(context: OTLPContext):
70
+ token = otlp_context.set(context)
53
71
  try:
54
72
  yield
55
73
  finally:
56
- tracing_exporter_context.reset(token)
74
+ otlp_context.reset(token)
File without changes
@@ -0,0 +1,38 @@
1
+ from typing import Optional
2
+ from contextvars import ContextVar, Token
3
+ from contextlib import contextmanager
4
+
5
+ from pydantic import BaseModel
6
+
7
+
8
+ class RoutingContext(BaseModel):
9
+ parameters: Optional[dict] = None
10
+ secrets: Optional[list] = None
11
+ mock: Optional[str] = None
12
+
13
+ @classmethod
14
+ def get(cls) -> "RoutingContext":
15
+ try:
16
+ return routing_context.get()
17
+ except LookupError:
18
+ return RoutingContext()
19
+
20
+ @classmethod
21
+ def set(cls, ctx: "RoutingContext") -> Token:
22
+ return routing_context.set(ctx)
23
+
24
+ @classmethod
25
+ def reset(cls, token: Token) -> None:
26
+ return routing_context.reset(token)
27
+
28
+
29
+ routing_context: ContextVar[RoutingContext] = ContextVar("routing_context")
30
+
31
+
32
+ @contextmanager
33
+ def routing_context_manager(context: RoutingContext):
34
+ token = RoutingContext.set(context)
35
+ try:
36
+ yield
37
+ finally:
38
+ RoutingContext.reset(token)
@@ -0,0 +1,57 @@
1
+ from typing import Optional, Union, Callable
2
+ from contextvars import Token, ContextVar
3
+ from contextlib import contextmanager
4
+
5
+
6
+ from pydantic import BaseModel
7
+
8
+ from agenta.sdk.models.workflows import (
9
+ WorkflowServiceInterface,
10
+ WorkflowServiceConfiguration,
11
+ )
12
+
13
+
14
+ class RunningContext(BaseModel):
15
+ flags: Optional[dict] = None
16
+ tags: Optional[dict] = None
17
+ meta: Optional[dict] = None
18
+
19
+ aggregate: Optional[Union[bool, Callable]] = None # stream to batch
20
+ annotate: Optional[bool] = None # annotation vs invocation
21
+
22
+ interface: Optional[WorkflowServiceInterface] = None
23
+ configuration: Optional[WorkflowServiceConfiguration] = None
24
+ parameters: Optional[dict] = None
25
+ schemas: Optional[dict] = None
26
+
27
+ secrets: Optional[list] = None
28
+ credentials: Optional[str] = None
29
+
30
+ handler: Optional[Callable] = None
31
+
32
+ @classmethod
33
+ def get(cls) -> "RunningContext":
34
+ try:
35
+ return running_context.get()
36
+ except LookupError:
37
+ return RunningContext()
38
+
39
+ @classmethod
40
+ def set(cls, ctx: "RunningContext") -> Token:
41
+ return running_context.set(ctx)
42
+
43
+ @classmethod
44
+ def reset(cls, token: Token) -> None:
45
+ return running_context.reset(token)
46
+
47
+
48
+ running_context: ContextVar[RunningContext] = ContextVar("running_context")
49
+
50
+
51
+ @contextmanager
52
+ def running_context_manager(context: RunningContext):
53
+ token = RunningContext.set(context)
54
+ try:
55
+ yield
56
+ finally:
57
+ RunningContext.reset(token)
@@ -0,0 +1,86 @@
1
+ from typing import Optional, Union, Callable
2
+ from contextvars import ContextVar, Token
3
+ from contextlib import contextmanager
4
+
5
+ from pydantic import BaseModel
6
+
7
+
8
+ class TracingContext(BaseModel):
9
+ traceparent: Optional[dict] = None
10
+ baggage: Optional[dict] = None
11
+ #
12
+ credentials: Optional[str] = None
13
+ #
14
+ script: Optional[dict] = None
15
+ parameters: Optional[dict] = None
16
+ #
17
+ flags: Optional[dict] = None
18
+ tags: Optional[dict] = None
19
+ meta: Optional[dict] = None
20
+ #
21
+ references: Optional[dict] = None
22
+ links: Optional[dict] = None
23
+ #
24
+ type: Optional[str] = None
25
+ aggregate: Optional[Union[bool, Callable]] = None # stream to batch
26
+ annotate: Optional[bool] = None # annotation vs invocation
27
+ #
28
+ link: Optional[dict] = None
29
+
30
+ @classmethod
31
+ def get(cls) -> "TracingContext":
32
+ try:
33
+ return tracing_context.get()
34
+ except LookupError:
35
+ return TracingContext()
36
+
37
+ @classmethod
38
+ def set(cls, ctx: "TracingContext") -> Token:
39
+ return tracing_context.set(ctx)
40
+
41
+ @classmethod
42
+ def reset(cls, token: Token) -> None:
43
+ return tracing_context.reset(token)
44
+
45
+
46
+ tracing_context: ContextVar[TracingContext] = ContextVar("ag.tracing_context")
47
+
48
+
49
+ @contextmanager
50
+ def tracing_context_manager(context: TracingContext):
51
+ token = TracingContext.set(context)
52
+ try:
53
+ yield
54
+ finally:
55
+ TracingContext.reset(token)
56
+
57
+
58
+ class OTLPContext(BaseModel):
59
+ credentials: Optional[str] = None
60
+
61
+ @classmethod
62
+ def get(cls) -> "OTLPContext":
63
+ try:
64
+ return otlp_context.get()
65
+ except LookupError:
66
+ return OTLPContext()
67
+
68
+ @classmethod
69
+ def set(cls, ctx: "OTLPContext") -> Token:
70
+ return otlp_context.set(ctx)
71
+
72
+ @classmethod
73
+ def reset(cls, token: Token) -> None:
74
+ return otlp_context.reset(token)
75
+
76
+
77
+ otlp_context: ContextVar[OTLPContext] = ContextVar("ag.otlp_context")
78
+
79
+
80
+ @contextmanager
81
+ def otlp_context_manager(context: OTLPContext):
82
+ token = OTLPContext.set(context)
83
+ try:
84
+ yield
85
+ finally:
86
+ OTLPContext.reset(token)
@@ -0,0 +1 @@
1
+ from .running import application, evaluator