turingpulse-interfaces 1.0.0__tar.gz

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.
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: turingpulse-interfaces
3
+ Version: 1.0.0
4
+ Summary: Shared Pydantic models for TuringPulse platform
5
+ Author: TuringPulse
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: pydantic<3.0.0,>=2.7.0
@@ -0,0 +1,13 @@
1
+ [project]
2
+ name = "turingpulse-interfaces"
3
+ version = "1.0.0"
4
+ description = "Shared Pydantic models for TuringPulse platform"
5
+ authors = [{name = "TuringPulse"}]
6
+ requires-python = ">=3.11"
7
+ dependencies = [
8
+ "pydantic>=2.7.0,<3.0.0",
9
+ ]
10
+
11
+ [build-system]
12
+ requires = ["setuptools>=68", "wheel"]
13
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,55 @@
1
+ """Shared Pydantic models for TuringPulse services."""
2
+
3
+ from .granularity import (
4
+ LEGACY_RESOLUTION_MAP,
5
+ RANGE_TO_RESOLUTION,
6
+ RESOLUTION_CH_INTERVAL,
7
+ RESOLUTION_DELTAS,
8
+ VALID_RESOLUTIONS,
9
+ Resolution,
10
+ normalize_resolution,
11
+ resolve_granularity,
12
+ )
13
+ from .llm import LLMProvider
14
+ from .models import (
15
+ AgentEvent,
16
+ AgentEventPayload,
17
+ AgentEventType,
18
+ AgentNode,
19
+ AgentRun,
20
+ AgentRunMetrics,
21
+ AgentTask,
22
+ AttachmentDirection,
23
+ AttachmentMetadata,
24
+ AttachmentUploadResponse,
25
+ HITLAction,
26
+ TaskStatus,
27
+ TokenBreakdown,
28
+ ToolCallInfo,
29
+ )
30
+
31
+ __all__ = [
32
+ "AgentEvent",
33
+ "AgentEventPayload",
34
+ "AgentEventType",
35
+ "AgentRun",
36
+ "AgentRunMetrics",
37
+ "AgentNode",
38
+ "AgentTask",
39
+ "AttachmentDirection",
40
+ "AttachmentMetadata",
41
+ "AttachmentUploadResponse",
42
+ "HITLAction",
43
+ "LEGACY_RESOLUTION_MAP",
44
+ "LLMProvider",
45
+ "RANGE_TO_RESOLUTION",
46
+ "RESOLUTION_CH_INTERVAL",
47
+ "RESOLUTION_DELTAS",
48
+ "Resolution",
49
+ "TaskStatus",
50
+ "TokenBreakdown",
51
+ "ToolCallInfo",
52
+ "VALID_RESOLUTIONS",
53
+ "normalize_resolution",
54
+ "resolve_granularity",
55
+ ]
@@ -0,0 +1,85 @@
1
+ """
2
+ Time-series granularity definitions — Single Source of Truth.
3
+
4
+ This module defines the canonical resolution types, the mapping from time
5
+ range duration to recommended resolution, and helpers consumed by both
6
+ Python backends and (via the mirrored TypeScript module) the portal.
7
+
8
+ Only trace-metric time-series endpoints use these resolutions. Pre-computed
9
+ KPI values, drift/anomaly events, and dimensional list endpoints are *not*
10
+ affected by resolution.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from datetime import timedelta
16
+ from enum import Enum
17
+ from typing import Dict, List, Set, Tuple
18
+
19
+
20
+ class Resolution(str, Enum):
21
+ """Supported time-series bucket widths."""
22
+
23
+ ONE_MINUTE = "1m"
24
+ FIVE_MINUTES = "5m"
25
+ FIFTEEN_MINUTES = "15m"
26
+ ONE_HOUR = "1h"
27
+ SIX_HOURS = "6h"
28
+ ONE_DAY = "1d"
29
+
30
+
31
+ RESOLUTION_DELTAS: Dict[Resolution, timedelta] = {
32
+ Resolution.ONE_MINUTE: timedelta(minutes=1),
33
+ Resolution.FIVE_MINUTES: timedelta(minutes=5),
34
+ Resolution.FIFTEEN_MINUTES: timedelta(minutes=15),
35
+ Resolution.ONE_HOUR: timedelta(hours=1),
36
+ Resolution.SIX_HOURS: timedelta(hours=6),
37
+ Resolution.ONE_DAY: timedelta(days=1),
38
+ }
39
+
40
+ RESOLUTION_CH_INTERVAL: Dict[Resolution, str] = {
41
+ Resolution.ONE_MINUTE: "1 MINUTE",
42
+ Resolution.FIVE_MINUTES: "5 MINUTE",
43
+ Resolution.FIFTEEN_MINUTES: "15 MINUTE",
44
+ Resolution.ONE_HOUR: "1 HOUR",
45
+ Resolution.SIX_HOURS: "6 HOUR",
46
+ Resolution.ONE_DAY: "1 DAY",
47
+ }
48
+
49
+ # Ordered list of (max_hours_inclusive, resolution).
50
+ # The first entry whose threshold >= the requested duration wins.
51
+ RANGE_TO_RESOLUTION: List[Tuple[float, Resolution]] = [
52
+ (1, Resolution.ONE_MINUTE),
53
+ (6, Resolution.FIVE_MINUTES),
54
+ (24, Resolution.FIFTEEN_MINUTES),
55
+ (72, Resolution.ONE_HOUR),
56
+ (336, Resolution.SIX_HOURS),
57
+ (float("inf"), Resolution.ONE_DAY),
58
+ ]
59
+
60
+ VALID_RESOLUTIONS: Set[str] = {r.value for r in Resolution}
61
+
62
+ # Legacy values accepted by earlier API versions.
63
+ LEGACY_RESOLUTION_MAP: Dict[str, Resolution] = {
64
+ "minute": Resolution.ONE_MINUTE,
65
+ "hour": Resolution.ONE_HOUR,
66
+ "day": Resolution.ONE_DAY,
67
+ }
68
+
69
+
70
+ def resolve_granularity(duration_hours: float) -> Resolution:
71
+ """Return the recommended resolution for a given time-range duration."""
72
+ for threshold_hours, resolution in RANGE_TO_RESOLUTION:
73
+ if duration_hours <= threshold_hours:
74
+ return resolution
75
+ return Resolution.ONE_DAY
76
+
77
+
78
+ def normalize_resolution(value: str) -> Resolution:
79
+ """Accept both new (``"5m"``) and legacy (``"minute"``) resolution strings.
80
+
81
+ Raises ``ValueError`` when *value* is not recognised.
82
+ """
83
+ if value in LEGACY_RESOLUTION_MAP:
84
+ return LEGACY_RESOLUTION_MAP[value]
85
+ return Resolution(value)
@@ -0,0 +1,17 @@
1
+ """Shared LLM provider configuration model."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Dict
6
+
7
+ from pydantic import BaseModel, Field
8
+
9
+
10
+ class LLMProvider(BaseModel):
11
+ name: str
12
+ provider: str
13
+ model: str
14
+ framework: str
15
+ max_context_tokens: int | None = None
16
+ temperature: float | None = None
17
+ metadata: Dict[str, str] = Field(default_factory=dict)
@@ -0,0 +1,138 @@
1
+ """Pydantic models shared across TuringPulse services."""
2
+
3
+ from datetime import datetime
4
+ from enum import Enum
5
+ from typing import Any, Dict, List, Optional
6
+
7
+ from pydantic import BaseModel, Field
8
+
9
+
10
+ class AgentEventType(str, Enum):
11
+ SPAN = "span"
12
+ METRIC = "metric"
13
+ STATE = "state"
14
+ AGENT_STEP = "agent_step" # Used by TuringPulse SDK for workflow node spans
15
+
16
+
17
+ class TokenBreakdown(BaseModel):
18
+ prompt: int = 0
19
+ completion: int = 0
20
+
21
+
22
+ class ToolCallInfo(BaseModel):
23
+ """Information about a tool call made by an agent."""
24
+ tool_name: str
25
+ tool_args: Dict[str, Any] = Field(default_factory=dict)
26
+ tool_result: Optional[str] = None
27
+ tool_id: Optional[str] = None
28
+ success: bool = True
29
+ error_message: Optional[str] = None
30
+
31
+
32
+ class AgentEventPayload(BaseModel):
33
+ name: str
34
+ duration_ms: Optional[int] = None
35
+ tokens: Optional[TokenBreakdown] = None
36
+ cost_usd: Optional[float] = None
37
+ status: Optional[str] = None
38
+ reasoning: Optional[str] = None
39
+ # Changed from Dict[str, str] to Dict[str, Any] to support numeric metadata values
40
+ metadata: Dict[str, Any] = Field(default_factory=dict)
41
+ # Tool calls made by the agent
42
+ tool_calls: Optional[List[ToolCallInfo]] = None
43
+
44
+
45
+ class AgentEvent(BaseModel):
46
+ run_id: str
47
+ agent_id: str
48
+ timestamp: datetime
49
+ type: AgentEventType
50
+ payload: AgentEventPayload
51
+ workflow_name: Optional[str] = None
52
+
53
+
54
+ class AgentNode(BaseModel):
55
+ node_id: str
56
+ name: str
57
+ runtime_ms: int
58
+ status: str
59
+ parent_node_id: Optional[str] = None
60
+
61
+
62
+ class AgentRunMetrics(BaseModel):
63
+ latency_ms: int
64
+ cost_usd: float
65
+ tokens_total: int
66
+
67
+
68
+ class AgentRun(BaseModel):
69
+ run_id: str
70
+ agent_id: str
71
+ tenant_id: Optional[str] = None # Tenant isolation
72
+ project_id: Optional[str] = None # Project isolation (UUID)
73
+ workflow_id: Optional[str] = None # Workflow ID for strict filtering
74
+ workflow_name: Optional[str] = None # Workflow display name
75
+ workflow_run_id: Optional[str] = None # Workflow run ID
76
+ started_at: datetime
77
+ completed_at: Optional[datetime]
78
+ status: str
79
+ metrics: Optional[AgentRunMetrics]
80
+ nodes: List[AgentNode] = Field(default_factory=list)
81
+
82
+
83
+ class TaskStatus(str, Enum):
84
+ TODO = "todo"
85
+ IN_PROGRESS = "in_progress"
86
+ BLOCKED = "blocked"
87
+ NEEDS_HUMAN = "needs_human"
88
+ COMPLETED = "completed"
89
+
90
+
91
+ class HITLAction(BaseModel):
92
+ reviewer: str
93
+ comment: str
94
+ created_at: datetime
95
+ resolution: Optional[str]
96
+
97
+
98
+ class AgentTask(BaseModel):
99
+ task_id: str
100
+ title: str
101
+ status: TaskStatus = TaskStatus.TODO
102
+ assignee: Optional[str]
103
+ agent_run_id: Optional[str]
104
+ hitl_required: bool = False
105
+ metadata: Dict[str, str] = Field(default_factory=dict)
106
+ hitl_actions: List[HITLAction] = Field(default_factory=list)
107
+
108
+
109
+ class AttachmentDirection(str, Enum):
110
+ INPUT = "input"
111
+ OUTPUT = "output"
112
+
113
+
114
+ class AttachmentMetadata(BaseModel):
115
+ """Metadata for a document attached to a span."""
116
+
117
+ attachment_id: str
118
+ filename: str
119
+ mime_type: str
120
+ size_bytes: int
121
+ compressed_size_bytes: Optional[int] = None
122
+ direction: AttachmentDirection
123
+ storage_path: str
124
+ extracted_text_length: Optional[int] = None
125
+ extraction_method: Optional[str] = None
126
+ checksum_sha256: Optional[str] = None
127
+
128
+
129
+ class AttachmentUploadResponse(BaseModel):
130
+ """Response from the attachment upload endpoint."""
131
+
132
+ attachment_id: str
133
+ filename: str
134
+ mime_type: str
135
+ size_bytes: int
136
+ extracted_text: Optional[str] = None
137
+ storage_path: str
138
+ deduplicated: bool = False
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: turingpulse-interfaces
3
+ Version: 1.0.0
4
+ Summary: Shared Pydantic models for TuringPulse platform
5
+ Author: TuringPulse
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: pydantic<3.0.0,>=2.7.0
@@ -0,0 +1,10 @@
1
+ pyproject.toml
2
+ turingpulse_interfaces/__init__.py
3
+ turingpulse_interfaces/granularity.py
4
+ turingpulse_interfaces/llm.py
5
+ turingpulse_interfaces/models.py
6
+ turingpulse_interfaces.egg-info/PKG-INFO
7
+ turingpulse_interfaces.egg-info/SOURCES.txt
8
+ turingpulse_interfaces.egg-info/dependency_links.txt
9
+ turingpulse_interfaces.egg-info/requires.txt
10
+ turingpulse_interfaces.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ pydantic<3.0.0,>=2.7.0
@@ -0,0 +1 @@
1
+ turingpulse_interfaces