agenta 0.52.6__py3-none-any.whl → 0.63.2__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.
- agenta/__init__.py +12 -3
- agenta/client/__init__.py +4 -4
- agenta/client/backend/__init__.py +4 -4
- agenta/client/backend/api_keys/client.py +2 -2
- agenta/client/backend/billing/client.py +2 -2
- agenta/client/backend/billing/raw_client.py +2 -2
- agenta/client/backend/client.py +56 -48
- agenta/client/backend/core/client_wrapper.py +2 -2
- agenta/client/backend/core/file.py +3 -1
- agenta/client/backend/core/http_client.py +3 -3
- agenta/client/backend/core/pydantic_utilities.py +13 -3
- agenta/client/backend/human_evaluations/client.py +2 -2
- agenta/client/backend/human_evaluations/raw_client.py +2 -2
- agenta/client/backend/organization/client.py +46 -34
- agenta/client/backend/organization/raw_client.py +32 -26
- agenta/client/backend/raw_client.py +26 -26
- agenta/client/backend/testsets/client.py +18 -18
- agenta/client/backend/testsets/raw_client.py +30 -30
- agenta/client/backend/types/__init__.py +4 -4
- agenta/client/backend/types/account_request.py +3 -1
- agenta/client/backend/types/account_response.py +3 -1
- agenta/client/backend/types/agenta_node_dto.py +3 -1
- agenta/client/backend/types/agenta_nodes_response.py +3 -1
- agenta/client/backend/types/agenta_root_dto.py +3 -1
- agenta/client/backend/types/agenta_roots_response.py +3 -1
- agenta/client/backend/types/agenta_tree_dto.py +3 -1
- agenta/client/backend/types/agenta_trees_response.py +3 -1
- agenta/client/backend/types/aggregated_result.py +3 -1
- agenta/client/backend/types/analytics_response.py +3 -1
- agenta/client/backend/types/annotation.py +6 -4
- agenta/client/backend/types/annotation_create.py +3 -1
- agenta/client/backend/types/annotation_edit.py +3 -1
- agenta/client/backend/types/annotation_link.py +3 -1
- agenta/client/backend/types/annotation_link_response.py +3 -1
- agenta/client/backend/types/annotation_query.py +3 -1
- agenta/client/backend/types/annotation_query_request.py +3 -1
- agenta/client/backend/types/annotation_reference.py +3 -1
- agenta/client/backend/types/annotation_references.py +3 -1
- agenta/client/backend/types/annotation_response.py +3 -1
- agenta/client/backend/types/annotations_response.py +3 -1
- agenta/client/backend/types/app.py +3 -1
- agenta/client/backend/types/app_variant_response.py +3 -1
- agenta/client/backend/types/app_variant_revision.py +3 -1
- agenta/client/backend/types/artifact.py +6 -4
- agenta/client/backend/types/base_output.py +3 -1
- agenta/client/backend/types/body_fetch_workflow_revision.py +3 -1
- agenta/client/backend/types/body_import_testset.py +3 -1
- agenta/client/backend/types/bucket_dto.py +3 -1
- agenta/client/backend/types/collect_status_response.py +3 -1
- agenta/client/backend/types/config_db.py +3 -1
- agenta/client/backend/types/config_dto.py +3 -1
- agenta/client/backend/types/config_response_model.py +3 -1
- agenta/client/backend/types/correct_answer.py +3 -1
- agenta/client/backend/types/create_app_output.py +3 -1
- agenta/client/backend/types/custom_model_settings_dto.py +3 -1
- agenta/client/backend/types/custom_provider_dto.py +3 -1
- agenta/client/backend/types/custom_provider_kind.py +1 -1
- agenta/client/backend/types/custom_provider_settings_dto.py +3 -1
- agenta/client/backend/types/delete_evaluation.py +3 -1
- agenta/client/backend/types/environment_output.py +3 -1
- agenta/client/backend/types/environment_output_extended.py +3 -1
- agenta/client/backend/types/environment_revision.py +3 -1
- agenta/client/backend/types/error.py +3 -1
- agenta/client/backend/types/evaluation.py +3 -1
- agenta/client/backend/types/evaluation_scenario.py +3 -1
- agenta/client/backend/types/evaluation_scenario_input.py +3 -1
- agenta/client/backend/types/evaluation_scenario_output.py +3 -1
- agenta/client/backend/types/evaluation_scenario_result.py +3 -1
- agenta/client/backend/types/evaluator.py +6 -4
- agenta/client/backend/types/evaluator_config.py +6 -4
- agenta/client/backend/types/evaluator_flags.py +3 -1
- agenta/client/backend/types/evaluator_mapping_output_interface.py +3 -1
- agenta/client/backend/types/evaluator_output_interface.py +3 -1
- agenta/client/backend/types/evaluator_query.py +3 -1
- agenta/client/backend/types/evaluator_query_request.py +3 -1
- agenta/client/backend/types/evaluator_request.py +3 -1
- agenta/client/backend/types/evaluator_response.py +3 -1
- agenta/client/backend/types/evaluators_response.py +3 -1
- agenta/client/backend/types/exception_dto.py +3 -1
- agenta/client/backend/types/extended_o_tel_tracing_response.py +3 -1
- agenta/client/backend/types/get_config_response.py +3 -1
- agenta/client/backend/types/header.py +3 -1
- agenta/client/backend/types/http_validation_error.py +3 -1
- agenta/client/backend/types/human_evaluation.py +3 -1
- agenta/client/backend/types/human_evaluation_scenario.py +3 -1
- agenta/client/backend/types/human_evaluation_scenario_input.py +3 -1
- agenta/client/backend/types/human_evaluation_scenario_output.py +3 -1
- agenta/client/backend/types/invite_request.py +3 -1
- agenta/client/backend/types/legacy_analytics_response.py +3 -1
- agenta/client/backend/types/legacy_data_point.py +3 -1
- agenta/client/backend/types/legacy_evaluator.py +3 -1
- agenta/client/backend/types/legacy_scope_request.py +3 -1
- agenta/client/backend/types/legacy_scopes_response.py +3 -1
- agenta/client/backend/types/legacy_subscription_request.py +3 -1
- agenta/client/backend/types/legacy_user_request.py +3 -1
- agenta/client/backend/types/legacy_user_response.py +3 -1
- agenta/client/backend/types/lifecycle_dto.py +3 -1
- agenta/client/backend/types/link_dto.py +3 -1
- agenta/client/backend/types/list_api_keys_response.py +3 -1
- agenta/client/backend/types/llm_run_rate_limit.py +3 -1
- agenta/client/backend/types/meta_request.py +3 -1
- agenta/client/backend/types/metrics_dto.py +3 -1
- agenta/client/backend/types/new_testset.py +3 -1
- agenta/client/backend/types/node_dto.py +3 -1
- agenta/client/backend/types/o_tel_context_dto.py +3 -1
- agenta/client/backend/types/o_tel_event.py +6 -4
- agenta/client/backend/types/o_tel_event_dto.py +3 -1
- agenta/client/backend/types/o_tel_extra_dto.py +3 -1
- agenta/client/backend/types/o_tel_flat_span.py +6 -4
- agenta/client/backend/types/o_tel_link.py +6 -4
- agenta/client/backend/types/o_tel_link_dto.py +3 -1
- agenta/client/backend/types/o_tel_links_response.py +3 -1
- agenta/client/backend/types/o_tel_span.py +1 -1
- agenta/client/backend/types/o_tel_span_dto.py +3 -1
- agenta/client/backend/types/o_tel_spans_tree.py +3 -1
- agenta/client/backend/types/o_tel_tracing_data_response.py +3 -1
- agenta/client/backend/types/o_tel_tracing_request.py +3 -1
- agenta/client/backend/types/o_tel_tracing_response.py +3 -1
- agenta/client/backend/types/organization.py +3 -1
- agenta/client/backend/types/organization_details.py +3 -1
- agenta/client/backend/types/organization_membership_request.py +3 -1
- agenta/client/backend/types/organization_output.py +3 -1
- agenta/client/backend/types/organization_request.py +3 -1
- agenta/client/backend/types/parent_dto.py +3 -1
- agenta/client/backend/types/project_membership_request.py +3 -1
- agenta/client/backend/types/project_request.py +3 -1
- agenta/client/backend/types/project_scope.py +3 -1
- agenta/client/backend/types/projects_response.py +3 -1
- agenta/client/backend/types/reference.py +6 -4
- agenta/client/backend/types/reference_dto.py +3 -1
- agenta/client/backend/types/reference_request_model.py +3 -1
- agenta/client/backend/types/result.py +3 -1
- agenta/client/backend/types/root_dto.py +3 -1
- agenta/client/backend/types/scopes_response_model.py +3 -1
- agenta/client/backend/types/secret_dto.py +3 -1
- agenta/client/backend/types/secret_response_dto.py +3 -1
- agenta/client/backend/types/simple_evaluation_output.py +3 -1
- agenta/client/backend/types/span_dto.py +6 -4
- agenta/client/backend/types/standard_provider_dto.py +3 -1
- agenta/client/backend/types/standard_provider_settings_dto.py +3 -1
- agenta/client/backend/types/status_dto.py +3 -1
- agenta/client/backend/types/tags_request.py +3 -1
- agenta/client/backend/types/testcase_response.py +6 -4
- agenta/client/backend/types/testset.py +6 -4
- agenta/client/backend/types/{test_set_output_response.py → testset_output_response.py} +4 -2
- agenta/client/backend/types/testset_request.py +3 -1
- agenta/client/backend/types/testset_response.py +3 -1
- agenta/client/backend/types/{test_set_simple_response.py → testset_simple_response.py} +4 -2
- agenta/client/backend/types/testsets_response.py +3 -1
- agenta/client/backend/types/time_dto.py +3 -1
- agenta/client/backend/types/tree_dto.py +3 -1
- agenta/client/backend/types/update_app_output.py +3 -1
- agenta/client/backend/types/user_request.py +3 -1
- agenta/client/backend/types/validation_error.py +3 -1
- agenta/client/backend/types/workflow_artifact.py +6 -4
- agenta/client/backend/types/workflow_data.py +3 -1
- agenta/client/backend/types/workflow_flags.py +3 -1
- agenta/client/backend/types/workflow_request.py +3 -1
- agenta/client/backend/types/workflow_response.py +3 -1
- agenta/client/backend/types/workflow_revision.py +6 -4
- agenta/client/backend/types/workflow_revision_request.py +3 -1
- agenta/client/backend/types/workflow_revision_response.py +3 -1
- agenta/client/backend/types/workflow_revisions_response.py +3 -1
- agenta/client/backend/types/workflow_variant.py +6 -4
- agenta/client/backend/types/workflow_variant_request.py +3 -1
- agenta/client/backend/types/workflow_variant_response.py +3 -1
- agenta/client/backend/types/workflow_variants_response.py +3 -1
- agenta/client/backend/types/workflows_response.py +3 -1
- agenta/client/backend/types/workspace.py +3 -1
- agenta/client/backend/types/workspace_member_response.py +3 -1
- agenta/client/backend/types/workspace_membership_request.py +3 -1
- agenta/client/backend/types/workspace_permission.py +3 -1
- agenta/client/backend/types/workspace_request.py +3 -1
- agenta/client/backend/types/workspace_response.py +3 -1
- agenta/client/backend/vault/raw_client.py +4 -4
- agenta/client/backend/workspace/client.py +2 -2
- agenta/client/client.py +102 -88
- agenta/sdk/__init__.py +52 -3
- agenta/sdk/agenta_init.py +43 -16
- agenta/sdk/assets.py +23 -15
- agenta/sdk/context/serving.py +20 -8
- agenta/sdk/context/tracing.py +40 -22
- agenta/sdk/contexts/__init__.py +0 -0
- agenta/sdk/contexts/routing.py +38 -0
- agenta/sdk/contexts/running.py +57 -0
- agenta/sdk/contexts/tracing.py +86 -0
- agenta/sdk/decorators/__init__.py +1 -0
- agenta/sdk/decorators/routing.py +284 -0
- agenta/sdk/decorators/running.py +692 -98
- agenta/sdk/decorators/serving.py +20 -21
- agenta/sdk/decorators/tracing.py +176 -131
- agenta/sdk/engines/__init__.py +0 -0
- agenta/sdk/engines/running/__init__.py +0 -0
- agenta/sdk/engines/running/utils.py +17 -0
- agenta/sdk/engines/tracing/__init__.py +1 -0
- agenta/sdk/engines/tracing/attributes.py +185 -0
- agenta/sdk/engines/tracing/conventions.py +49 -0
- agenta/sdk/engines/tracing/exporters.py +130 -0
- agenta/sdk/engines/tracing/inline.py +1154 -0
- agenta/sdk/engines/tracing/processors.py +190 -0
- agenta/sdk/engines/tracing/propagation.py +102 -0
- agenta/sdk/engines/tracing/spans.py +136 -0
- agenta/sdk/engines/tracing/tracing.py +324 -0
- agenta/sdk/evaluations/__init__.py +2 -0
- agenta/sdk/evaluations/metrics.py +37 -0
- agenta/sdk/evaluations/preview/__init__.py +0 -0
- agenta/sdk/evaluations/preview/evaluate.py +765 -0
- agenta/sdk/evaluations/preview/utils.py +861 -0
- agenta/sdk/evaluations/results.py +66 -0
- agenta/sdk/evaluations/runs.py +153 -0
- agenta/sdk/evaluations/scenarios.py +48 -0
- agenta/sdk/litellm/litellm.py +12 -0
- agenta/sdk/litellm/mockllm.py +6 -8
- agenta/sdk/litellm/mocks/__init__.py +5 -5
- agenta/sdk/managers/applications.py +304 -0
- agenta/sdk/managers/config.py +2 -2
- agenta/sdk/managers/evaluations.py +0 -0
- agenta/sdk/managers/evaluators.py +303 -0
- agenta/sdk/managers/secrets.py +161 -24
- agenta/sdk/managers/shared.py +3 -1
- agenta/sdk/managers/testsets.py +441 -0
- agenta/sdk/managers/vault.py +3 -3
- agenta/sdk/middleware/auth.py +0 -176
- agenta/sdk/middleware/config.py +27 -9
- agenta/sdk/middleware/vault.py +204 -9
- agenta/sdk/middlewares/__init__.py +0 -0
- agenta/sdk/middlewares/routing/__init__.py +0 -0
- agenta/sdk/middlewares/routing/auth.py +263 -0
- agenta/sdk/middlewares/routing/cors.py +30 -0
- agenta/sdk/middlewares/routing/otel.py +29 -0
- agenta/sdk/middlewares/running/__init__.py +0 -0
- agenta/sdk/middlewares/running/normalizer.py +321 -0
- agenta/sdk/middlewares/running/resolver.py +161 -0
- agenta/sdk/middlewares/running/vault.py +140 -0
- agenta/sdk/models/__init__.py +0 -0
- agenta/sdk/models/blobs.py +33 -0
- agenta/sdk/models/evaluations.py +119 -0
- agenta/sdk/models/git.py +126 -0
- agenta/sdk/models/shared.py +167 -0
- agenta/sdk/models/testsets.py +163 -0
- agenta/sdk/models/tracing.py +202 -0
- agenta/sdk/models/workflows.py +753 -0
- agenta/sdk/tracing/attributes.py +4 -4
- agenta/sdk/tracing/exporters.py +67 -17
- agenta/sdk/tracing/inline.py +37 -45
- agenta/sdk/tracing/processors.py +97 -0
- agenta/sdk/tracing/propagation.py +3 -1
- agenta/sdk/tracing/spans.py +4 -0
- agenta/sdk/tracing/tracing.py +13 -15
- agenta/sdk/types.py +222 -22
- agenta/sdk/utils/cache.py +1 -1
- agenta/sdk/utils/client.py +38 -0
- agenta/sdk/utils/helpers.py +13 -12
- agenta/sdk/utils/logging.py +18 -78
- agenta/sdk/utils/references.py +23 -0
- agenta/sdk/workflows/builtin.py +600 -0
- agenta/sdk/workflows/configurations.py +22 -0
- agenta/sdk/workflows/errors.py +292 -0
- agenta/sdk/workflows/handlers.py +1791 -0
- agenta/sdk/workflows/interfaces.py +948 -0
- agenta/sdk/workflows/sandbox.py +118 -0
- agenta/sdk/workflows/utils.py +303 -6
- {agenta-0.52.6.dist-info → agenta-0.63.2.dist-info}/METADATA +37 -33
- agenta-0.63.2.dist-info/RECORD +421 -0
- {agenta-0.52.6.dist-info → agenta-0.63.2.dist-info}/WHEEL +1 -1
- agenta/sdk/middleware/adapt.py +0 -253
- agenta/sdk/middleware/base.py +0 -40
- agenta/sdk/middleware/flags.py +0 -40
- agenta/sdk/workflows/types.py +0 -472
- agenta-0.52.6.dist-info/RECORD +0 -371
- /agenta/sdk/{workflows → engines/running}/registry.py +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
|
|
26
|
-
|
|
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.
|
|
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 -
|
|
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
|
|
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
|
|
87
|
-
|
|
88
|
-
)
|
|
89
|
-
self.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
|
|
111
|
+
log.error(f"Failed to parse API URL '{_api_url}': {e}")
|
|
95
112
|
raise
|
|
96
113
|
|
|
97
|
-
|
|
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
|
-
|
|
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
|
|
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.
|
|
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.
|
|
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 =
|
|
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,5 +1,8 @@
|
|
|
1
1
|
supported_llm_models = {
|
|
2
|
-
"
|
|
2
|
+
"anthropic": [
|
|
3
|
+
"anthropic/claude-sonnet-4-5",
|
|
4
|
+
"anthropic/claude-haiku-4-5",
|
|
5
|
+
"anthropic/claude-opus-4-1",
|
|
3
6
|
"anthropic/claude-sonnet-4-20250514",
|
|
4
7
|
"anthropic/claude-opus-4-20250514",
|
|
5
8
|
"anthropic/claude-3-7-sonnet-20250219",
|
|
@@ -12,29 +15,33 @@ supported_llm_models = {
|
|
|
12
15
|
"anthropic/claude-2.1",
|
|
13
16
|
"anthropic/claude-2",
|
|
14
17
|
],
|
|
15
|
-
"
|
|
18
|
+
"cohere": [
|
|
16
19
|
"cohere/command-light",
|
|
17
20
|
"cohere/command-r-plus",
|
|
18
21
|
"cohere/command-nightly",
|
|
19
22
|
],
|
|
20
|
-
"
|
|
23
|
+
"deepinfra": [
|
|
21
24
|
"deepinfra/meta-llama/Llama-2-70b-chat-hf",
|
|
22
25
|
"deepinfra/meta-llama/Llama-2-13b-chat-hf",
|
|
23
26
|
"deepinfra/codellama/CodeLlama-34b-Instruct-hf",
|
|
24
27
|
"deepinfra/mistralai/Mistral-7B-Instruct-v0.1",
|
|
25
28
|
],
|
|
26
|
-
"
|
|
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",
|
|
27
35
|
"gemini/gemini-2.5-flash-preview-05-20",
|
|
28
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",
|
|
29
40
|
"gemini/gemini-2.0-flash-001",
|
|
30
|
-
"gemini/gemini-2.5-pro-preview-05-06",
|
|
31
|
-
"gemini/gemini-2.0-flash-lite-preview-02-05",
|
|
32
|
-
"gemini/gemini-1.5-pro-latest",
|
|
33
41
|
"gemini/gemini-2.0-flash-lite",
|
|
34
|
-
"gemini/gemini-
|
|
35
|
-
"gemini/gemini-1.5-flash-8b",
|
|
42
|
+
"gemini/gemini-2.0-flash-lite-preview-02-05",
|
|
36
43
|
],
|
|
37
|
-
"
|
|
44
|
+
"groq": [
|
|
38
45
|
"groq/deepseek-r1-distill-llama-70b",
|
|
39
46
|
"groq/deepseek-r1-distill-llama-70b-specdec",
|
|
40
47
|
"groq/gemma2-9b-it",
|
|
@@ -50,14 +57,15 @@ supported_llm_models = {
|
|
|
50
57
|
"groq/llama3-8b-8192",
|
|
51
58
|
"groq/mixtral-8x7b-32768",
|
|
52
59
|
],
|
|
53
|
-
"
|
|
60
|
+
"mistral": [
|
|
54
61
|
"mistral/mistral-tiny",
|
|
55
62
|
"mistral/mistral-small",
|
|
56
63
|
"mistral/mistral-medium",
|
|
57
64
|
"mistral/mistral-large-latest",
|
|
58
65
|
],
|
|
59
|
-
"
|
|
66
|
+
"openai": [
|
|
60
67
|
"gpt-5",
|
|
68
|
+
"gpt-5.1",
|
|
61
69
|
"gpt-5-mini",
|
|
62
70
|
"gpt-5-nano",
|
|
63
71
|
"gpt-4.5-preview",
|
|
@@ -72,7 +80,7 @@ supported_llm_models = {
|
|
|
72
80
|
"gpt-4.1-nano",
|
|
73
81
|
"o4-mini",
|
|
74
82
|
],
|
|
75
|
-
"
|
|
83
|
+
"openrouter": [
|
|
76
84
|
"openrouter/qwen/qwen3-235b-a22b",
|
|
77
85
|
"openrouter/qwen/qwen3-32b",
|
|
78
86
|
"openrouter/qwen/qwen3-30b-a3b",
|
|
@@ -142,13 +150,13 @@ supported_llm_models = {
|
|
|
142
150
|
"openrouter/google/gemini-2.0-flash-001",
|
|
143
151
|
"openrouter/perplexity/sonar-reasoning",
|
|
144
152
|
],
|
|
145
|
-
"
|
|
153
|
+
"perplexity": [
|
|
146
154
|
"perplexity/sonar",
|
|
147
155
|
"perplexity/sonar-pro",
|
|
148
156
|
"perplexity/sonar-reasoning",
|
|
149
157
|
"perplexity/sonar-reasoning-pro",
|
|
150
158
|
],
|
|
151
|
-
"
|
|
159
|
+
"together_ai": [
|
|
152
160
|
"together_ai/deepseek-ai/DeepSeek-R1",
|
|
153
161
|
"together_ai/deepseek-ai/DeepSeek-R1-Distill-Llama-70B",
|
|
154
162
|
"together_ai/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
|
agenta/sdk/context/serving.py
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
39
|
+
RoutingContext.reset(token)
|
agenta/sdk/context/tracing.py
CHANGED
|
@@ -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
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
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
|
-
|
|
43
|
+
TracingContext.reset(token)
|
|
35
44
|
|
|
36
45
|
|
|
37
|
-
class
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|