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
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
from typing import Dict, List, Optional, Union, Literal, Callable, Any
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel
|
|
7
|
+
|
|
8
|
+
from agenta.sdk.models.shared import (
|
|
9
|
+
TraceID,
|
|
10
|
+
SpanID,
|
|
11
|
+
Link,
|
|
12
|
+
Identifier,
|
|
13
|
+
Slug,
|
|
14
|
+
Version,
|
|
15
|
+
Reference,
|
|
16
|
+
Lifecycle,
|
|
17
|
+
Header,
|
|
18
|
+
Flags,
|
|
19
|
+
Tags,
|
|
20
|
+
Meta,
|
|
21
|
+
Metadata,
|
|
22
|
+
Data,
|
|
23
|
+
Commit,
|
|
24
|
+
AliasConfig,
|
|
25
|
+
sync_alias,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# ------------------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Origin = Literal["custom", "human", "auto"]
|
|
33
|
+
# Target = Union[List[UUID], Dict[UUID, Origin], List[Callable]]
|
|
34
|
+
Target = Union[
|
|
35
|
+
List[List[Dict[str, Any]]], # testcases_data
|
|
36
|
+
List[Callable], # workflow_handlers
|
|
37
|
+
List[UUID], # entity_ids
|
|
38
|
+
Dict[UUID, Origin], # entity_ids with origins
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# oss.src.core.evaluations.types
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class EvaluationStatus(str, Enum):
|
|
46
|
+
PENDING = "pending"
|
|
47
|
+
QUEUED = "queued"
|
|
48
|
+
RUNNING = "running"
|
|
49
|
+
SUCCESS = "success"
|
|
50
|
+
FAILURE = "failure"
|
|
51
|
+
ERRORS = "errors"
|
|
52
|
+
CANCELLED = "cancelled"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class EvaluationRunFlags(BaseModel):
|
|
56
|
+
is_closed: Optional[bool] = None # Indicates if the run is immutable
|
|
57
|
+
is_live: Optional[bool] = None # Indicates if the run is updated periodically
|
|
58
|
+
is_active: Optional[bool] = None # Indicates if the run is currently active
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class SimpleEvaluationFlags(EvaluationRunFlags):
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
SimpleEvaluationStatus = EvaluationStatus
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class SimpleEvaluationData(BaseModel):
|
|
69
|
+
status: Optional[SimpleEvaluationStatus] = None
|
|
70
|
+
|
|
71
|
+
query_steps: Optional[Target] = None
|
|
72
|
+
testset_steps: Optional[Target] = None
|
|
73
|
+
application_steps: Optional[Target] = None
|
|
74
|
+
evaluator_steps: Optional[Target] = None
|
|
75
|
+
|
|
76
|
+
repeats: Optional[int] = None
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class EvaluationRun(BaseModel):
|
|
80
|
+
id: UUID
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class EvaluationScenario(BaseModel):
|
|
84
|
+
id: UUID
|
|
85
|
+
|
|
86
|
+
run_id: UUID
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class EvaluationResult(BaseModel):
|
|
90
|
+
id: UUID
|
|
91
|
+
|
|
92
|
+
run_id: UUID
|
|
93
|
+
scenario_id: UUID
|
|
94
|
+
step_key: str
|
|
95
|
+
|
|
96
|
+
testcase_id: Optional[UUID] = None
|
|
97
|
+
trace_id: Optional[UUID] = None
|
|
98
|
+
error: Optional[dict] = None
|
|
99
|
+
|
|
100
|
+
flags: Optional[Dict[str, Any]] = None
|
|
101
|
+
tags: Optional[Dict[str, Any]] = None
|
|
102
|
+
meta: Optional[Dict[str, Any]] = None
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class EvaluationMetrics(Identifier, Lifecycle):
|
|
106
|
+
flags: Optional[Dict[str, Any]] = None
|
|
107
|
+
tags: Optional[Dict[str, Any]] = None
|
|
108
|
+
meta: Optional[Dict[str, Any]] = None
|
|
109
|
+
|
|
110
|
+
status: Optional[EvaluationStatus] = None
|
|
111
|
+
|
|
112
|
+
timestamp: Optional[datetime] = None
|
|
113
|
+
interval: Optional[int] = None
|
|
114
|
+
|
|
115
|
+
data: Optional[Data] = None
|
|
116
|
+
|
|
117
|
+
scenario_id: Optional[UUID] = None
|
|
118
|
+
|
|
119
|
+
run_id: UUID
|
agenta/sdk/models/git.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
from uuid import UUID
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel, Field
|
|
5
|
+
|
|
6
|
+
from agenta.sdk.models.shared import (
|
|
7
|
+
TraceID,
|
|
8
|
+
SpanID,
|
|
9
|
+
Link,
|
|
10
|
+
Identifier,
|
|
11
|
+
Slug,
|
|
12
|
+
Version,
|
|
13
|
+
Reference,
|
|
14
|
+
Lifecycle,
|
|
15
|
+
Header,
|
|
16
|
+
Flags,
|
|
17
|
+
Tags,
|
|
18
|
+
Meta,
|
|
19
|
+
Metadata,
|
|
20
|
+
Data,
|
|
21
|
+
Commit,
|
|
22
|
+
AliasConfig,
|
|
23
|
+
sync_alias,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
from typing import Optional, List
|
|
28
|
+
from uuid import UUID
|
|
29
|
+
|
|
30
|
+
from pydantic import BaseModel
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# artifacts --------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Artifact(Identifier, Slug, Lifecycle, Header, Metadata):
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class ArtifactCreate(Slug, Header, Metadata):
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ArtifactEdit(Identifier, Header, Metadata):
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class ArtifactQuery(Metadata):
|
|
49
|
+
pass
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# variants ---------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class Variant(Identifier, Slug, Lifecycle, Header, Metadata):
|
|
56
|
+
artifact_id: Optional[UUID] = None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class VariantCreate(Slug, Header, Metadata):
|
|
60
|
+
artifact_id: Optional[UUID] = None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class VariantEdit(Identifier, Header, Metadata):
|
|
64
|
+
pass
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class VariantQuery(Metadata):
|
|
68
|
+
pass
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# revisions --------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class Revision(Identifier, Slug, Version, Lifecycle, Header, Metadata, Commit):
|
|
75
|
+
data: Optional[Data] = None
|
|
76
|
+
|
|
77
|
+
artifact_id: Optional[UUID] = None
|
|
78
|
+
variant_id: Optional[UUID] = None
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class RevisionCreate(Slug, Header, Metadata):
|
|
82
|
+
artifact_id: Optional[UUID] = None
|
|
83
|
+
variant_id: Optional[UUID] = None
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class RevisionEdit(Identifier, Header, Metadata):
|
|
87
|
+
pass
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class RevisionQuery(Metadata):
|
|
91
|
+
authors: Optional[List[UUID]] = None
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class RevisionCommit(Slug, Header, Metadata):
|
|
95
|
+
data: Optional[Data] = None
|
|
96
|
+
|
|
97
|
+
message: Optional[str] = None
|
|
98
|
+
|
|
99
|
+
artifact_id: Optional[UUID] = None
|
|
100
|
+
variant_id: Optional[UUID] = None
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class RevisionsLog(BaseModel):
|
|
104
|
+
artifact_id: Optional[UUID] = None
|
|
105
|
+
variant_id: Optional[UUID] = None
|
|
106
|
+
revision_id: Optional[UUID] = None
|
|
107
|
+
|
|
108
|
+
depth: Optional[int] = None
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# forks ------------------------------------------------------------------------
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class RevisionFork(Slug, Header, Metadata):
|
|
115
|
+
data: Optional[Data] = None
|
|
116
|
+
|
|
117
|
+
message: Optional[str] = None
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class VariantFork(Slug, Header, Metadata):
|
|
121
|
+
pass
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class ArtifactFork(RevisionsLog):
|
|
125
|
+
variant: Optional[VariantFork] = None
|
|
126
|
+
revision: Optional[RevisionFork] = None
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
from typing import Optional, Dict, List, Union, Literal
|
|
2
|
+
from typing_extensions import TypeAliasType
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from uuid import UUID
|
|
5
|
+
from re import match
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, field_validator
|
|
8
|
+
|
|
9
|
+
BoolJson = TypeAliasType( # type: ignore
|
|
10
|
+
"BoolJson",
|
|
11
|
+
Union[bool, Dict[str, "BoolJson"]], # type: ignore
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
StringJson = TypeAliasType( # type: ignore
|
|
15
|
+
"StringJson",
|
|
16
|
+
Union[str, Dict[str, "StringJson"]], # type: ignore
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
FullJson = TypeAliasType( # type: ignore
|
|
20
|
+
"FullJson",
|
|
21
|
+
Union[str, int, float, bool, None, Dict[str, "FullJson"], List["FullJson"]], # type: ignore
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
NumericJson = TypeAliasType( # type: ignore
|
|
25
|
+
"NumericJson",
|
|
26
|
+
Union[int, float, Dict[str, "NumericJson"]], # type: ignore
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
NoListJson = TypeAliasType( # type: ignore
|
|
30
|
+
"NoListJson",
|
|
31
|
+
Union[str, int, float, bool, None, Dict[str, "NoListJson"]], # type: ignore
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
LabelJson = TypeAliasType( # type: ignore
|
|
35
|
+
"LabelJson",
|
|
36
|
+
Union[bool, str, Dict[str, "LabelJson"]], # type: ignore
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
Json = Dict[str, FullJson] # type: ignore
|
|
40
|
+
|
|
41
|
+
Data = Dict[str, FullJson] # type: ignore
|
|
42
|
+
|
|
43
|
+
Flags = Dict[str, LabelJson] # type: ignore
|
|
44
|
+
|
|
45
|
+
Tags = Dict[str, LabelJson] # type: ignore
|
|
46
|
+
|
|
47
|
+
Meta = Dict[str, FullJson] # type: ignore
|
|
48
|
+
|
|
49
|
+
Hashes = Dict[str, StringJson] # type: ignore
|
|
50
|
+
|
|
51
|
+
Metrics = Dict[str, NumericJson] # type: ignore
|
|
52
|
+
|
|
53
|
+
Schema = Dict[str, FullJson] # type: ignore
|
|
54
|
+
|
|
55
|
+
Mappings = Dict[str, str]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class Lifecycle(BaseModel):
|
|
59
|
+
created_at: Optional[datetime] = None
|
|
60
|
+
updated_at: Optional[datetime] = None
|
|
61
|
+
deleted_at: Optional[datetime] = None
|
|
62
|
+
|
|
63
|
+
created_by_id: Optional[UUID] = None
|
|
64
|
+
updated_by_id: Optional[UUID] = None
|
|
65
|
+
deleted_by_id: Optional[UUID] = None
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class TraceID(BaseModel):
|
|
69
|
+
trace_id: Optional[str] = None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class SpanID(BaseModel):
|
|
73
|
+
span_id: Optional[str] = None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class Link(TraceID, SpanID):
|
|
77
|
+
pass
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class Identifier(BaseModel):
|
|
81
|
+
id: Optional[UUID] = None
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class Slug(BaseModel):
|
|
85
|
+
slug: Optional[str] = None
|
|
86
|
+
|
|
87
|
+
@field_validator("slug")
|
|
88
|
+
def check_url_safety(cls, v):
|
|
89
|
+
if v is not None:
|
|
90
|
+
if not match(r"^[a-zA-Z0-9_-]+$", v):
|
|
91
|
+
raise ValueError("slug must be URL-safe.")
|
|
92
|
+
return v
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class Version(BaseModel):
|
|
96
|
+
version: Optional[str] = None
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class Reference(Identifier, Slug, Version):
|
|
100
|
+
pass
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class Header(BaseModel):
|
|
104
|
+
name: Optional[str] = None
|
|
105
|
+
description: Optional[str] = None
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class Metadata(BaseModel):
|
|
109
|
+
flags: Optional[Flags] = None
|
|
110
|
+
tags: Optional[Tags] = None
|
|
111
|
+
meta: Optional[Meta] = None
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class Commit(BaseModel):
|
|
115
|
+
author: Optional[UUID] = None
|
|
116
|
+
date: Optional[datetime] = None
|
|
117
|
+
message: Optional[str] = None
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class Status(BaseModel):
|
|
121
|
+
code: Optional[int] = 200
|
|
122
|
+
message: Optional[str] = "Success"
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class AliasConfig(BaseModel):
|
|
126
|
+
model_config = {
|
|
127
|
+
"populate_by_name": True,
|
|
128
|
+
"from_attributes": True,
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def sync_alias(primary: str, alias: str, instance: BaseModel) -> None:
|
|
133
|
+
primary_val = getattr(instance, primary)
|
|
134
|
+
alias_val = getattr(instance, alias)
|
|
135
|
+
|
|
136
|
+
if primary_val and alias_val is None:
|
|
137
|
+
object.__setattr__(instance, alias, primary_val)
|
|
138
|
+
elif alias_val and primary_val is None:
|
|
139
|
+
object.__setattr__(instance, primary, alias_val)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class Windowing(BaseModel):
|
|
143
|
+
# RANGE
|
|
144
|
+
newest: Optional[datetime] = None
|
|
145
|
+
oldest: Optional[datetime] = None
|
|
146
|
+
# TOKEN
|
|
147
|
+
next: Optional[UUID] = None
|
|
148
|
+
# LIMIT
|
|
149
|
+
limit: Optional[int] = None
|
|
150
|
+
# ORDER
|
|
151
|
+
order: Optional[Literal["ascending", "descending"]] = None
|
|
152
|
+
# BUCKETS
|
|
153
|
+
interval: Optional[int] = None
|
|
154
|
+
# SAMPLES
|
|
155
|
+
rate: Optional[float] = None
|
|
156
|
+
|
|
157
|
+
@field_validator("rate")
|
|
158
|
+
def check_rate(cls, v):
|
|
159
|
+
if v is not None and (v < 0.0 or v > 1.0):
|
|
160
|
+
raise ValueError("Sampling rate must be between 0.0 and 1.0.")
|
|
161
|
+
return v
|
|
162
|
+
|
|
163
|
+
@field_validator("interval")
|
|
164
|
+
def check_interval(cls, v):
|
|
165
|
+
if v is not None and v <= 0:
|
|
166
|
+
raise ValueError("Bucket interval must be a positive integer.")
|
|
167
|
+
return v
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
from typing import List, Optional, Dict, Any
|
|
2
|
+
from uuid import UUID
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel, Field
|
|
5
|
+
|
|
6
|
+
from agenta.sdk.models.shared import (
|
|
7
|
+
TraceID,
|
|
8
|
+
SpanID,
|
|
9
|
+
Link,
|
|
10
|
+
Identifier,
|
|
11
|
+
Slug,
|
|
12
|
+
Version,
|
|
13
|
+
Reference,
|
|
14
|
+
Lifecycle,
|
|
15
|
+
Header,
|
|
16
|
+
Flags,
|
|
17
|
+
Tags,
|
|
18
|
+
Meta,
|
|
19
|
+
Metadata,
|
|
20
|
+
Data,
|
|
21
|
+
Commit,
|
|
22
|
+
AliasConfig,
|
|
23
|
+
sync_alias,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
from agenta.sdk.models.git import (
|
|
27
|
+
Artifact,
|
|
28
|
+
ArtifactCreate,
|
|
29
|
+
ArtifactEdit,
|
|
30
|
+
ArtifactQuery,
|
|
31
|
+
ArtifactFork,
|
|
32
|
+
Variant,
|
|
33
|
+
VariantCreate,
|
|
34
|
+
VariantEdit,
|
|
35
|
+
VariantQuery,
|
|
36
|
+
VariantFork,
|
|
37
|
+
Revision,
|
|
38
|
+
RevisionCreate,
|
|
39
|
+
RevisionEdit,
|
|
40
|
+
RevisionQuery,
|
|
41
|
+
RevisionCommit,
|
|
42
|
+
RevisionsLog,
|
|
43
|
+
RevisionFork,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
from agenta.sdk.models.blobs import (
|
|
47
|
+
Blob,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class TestsetIdAlias(AliasConfig):
|
|
52
|
+
testset_id: Optional[UUID] = None
|
|
53
|
+
set_id: Optional[UUID] = Field(
|
|
54
|
+
default=None,
|
|
55
|
+
exclude=True,
|
|
56
|
+
alias="testset_id",
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class TestsetVariantIdAlias(AliasConfig):
|
|
61
|
+
testset_variant_id: Optional[UUID] = None
|
|
62
|
+
variant_id: Optional[UUID] = Field(
|
|
63
|
+
default=None,
|
|
64
|
+
exclude=True,
|
|
65
|
+
alias="testset_variant_id",
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class Testcase(Blob, TestsetIdAlias):
|
|
70
|
+
def model_post_init(self, __context) -> None:
|
|
71
|
+
sync_alias("testset_id", "set_id", self)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class TestsetFlags(BaseModel):
|
|
75
|
+
has_testcases: Optional[bool] = None
|
|
76
|
+
has_traces: Optional[bool] = None
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class TestsetRevisionData(BaseModel):
|
|
80
|
+
testcase_ids: Optional[List[UUID]] = None
|
|
81
|
+
testcases: Optional[List[Testcase]] = None
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class SimpleTestset(
|
|
85
|
+
Identifier,
|
|
86
|
+
Slug,
|
|
87
|
+
Lifecycle,
|
|
88
|
+
Header,
|
|
89
|
+
):
|
|
90
|
+
flags: Optional[TestsetFlags] = None
|
|
91
|
+
tags: Optional[Tags] = None # type: ignore
|
|
92
|
+
meta: Optional[Meta] = None # type: ignore
|
|
93
|
+
|
|
94
|
+
data: Optional[TestsetRevisionData] = None
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class Testset(Artifact):
|
|
98
|
+
flags: Optional[TestsetFlags] = None # type: ignore
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class TestsetRevision(
|
|
102
|
+
Revision,
|
|
103
|
+
TestsetIdAlias,
|
|
104
|
+
TestsetVariantIdAlias,
|
|
105
|
+
):
|
|
106
|
+
flags: Optional[TestsetFlags] = None # type: ignore
|
|
107
|
+
|
|
108
|
+
data: Optional[TestsetRevisionData] = None # type: ignore
|
|
109
|
+
|
|
110
|
+
def model_post_init(self, __context) -> None:
|
|
111
|
+
sync_alias("testset_id", "artifact_id", self)
|
|
112
|
+
sync_alias("testset_variant_id", "variant_id", self)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class SimpleTestsetCreate(Slug, Header):
|
|
116
|
+
tags: Optional[Tags] = None # type: ignore
|
|
117
|
+
meta: Optional[Meta] = None # type: ignore
|
|
118
|
+
data: Optional[TestsetRevisionData] = None
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class SimpleTestsetEdit(
|
|
122
|
+
Identifier,
|
|
123
|
+
Header,
|
|
124
|
+
):
|
|
125
|
+
# flags: Optional[TestsetFlags] = None
|
|
126
|
+
tags: Optional[Tags] = None # type: ignore
|
|
127
|
+
meta: Optional[Meta] = None # type: ignore
|
|
128
|
+
|
|
129
|
+
data: Optional[TestsetRevisionData] = None
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class TestsetResponse(BaseModel):
|
|
133
|
+
count: int = 0
|
|
134
|
+
testset: Optional[Testset] = None
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class TestsetRevisionResponse(BaseModel):
|
|
138
|
+
count: int = 0
|
|
139
|
+
testset_revision: Optional[TestsetRevision] = None
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class SimpleTestsetResponse(BaseModel):
|
|
143
|
+
count: int = 0
|
|
144
|
+
testset: Optional[SimpleTestset] = None
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class TestsetsResponse(BaseModel):
|
|
148
|
+
count: int = 0
|
|
149
|
+
testsets: List[Testset] = []
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class SimpleTestsetsResponse(BaseModel):
|
|
153
|
+
count: int = 0
|
|
154
|
+
testsets: List[SimpleTestset] = []
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
# LEGACY TESTSETS --------------------------------------------------------------
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class LegacyTestset(BaseModel):
|
|
161
|
+
id: str
|
|
162
|
+
name: Optional[str] = None
|
|
163
|
+
csvdata: Optional[List[Dict[str, Any]]] = None
|