File size: 1,242 Bytes
db4810d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
from abc import ABC, abstractmethod
from dataclasses import asdict, dataclass
from typing import Any, Dict, Sequence
@dataclass
class BaseTelemetryEvent(ABC):
@property
@abstractmethod
def name(self) -> str:
pass
@property
def properties(self) -> Dict[str, Any]:
return {k: v for k, v in asdict(self).items() if k != 'name'}
@dataclass
class RegisteredFunction:
name: str
params: dict[str, Any]
@dataclass
class ControllerRegisteredFunctionsTelemetryEvent(BaseTelemetryEvent):
registered_functions: list[RegisteredFunction]
name: str = 'controller_registered_functions'
@dataclass
class AgentStepTelemetryEvent(BaseTelemetryEvent):
agent_id: str
step: int
step_error: list[str]
consecutive_failures: int
actions: list[dict]
name: str = 'agent_step'
@dataclass
class AgentRunTelemetryEvent(BaseTelemetryEvent):
agent_id: str
use_vision: bool
task: str
model_name: str
chat_model_library: str
version: str
source: str
name: str = 'agent_run'
@dataclass
class AgentEndTelemetryEvent(BaseTelemetryEvent):
agent_id: str
steps: int
max_steps_reached: bool
is_done: bool
success: bool | None
total_input_tokens: int
total_duration_seconds: float
errors: Sequence[str | None]
name: str = 'agent_end'
|