Documentation
¶
Index ¶
- func FilterZeroValues(usage ModelUsage) map[string]any
- func LogMetric(logger *slog.Logger, metric Metric)
- func LogMetrics(logger *slog.Logger, metric Metric)
- type Avatar
- type CachedTokenDetails
- type EOTInference
- type EOU
- type InputTokenDetails
- type Interruption
- type Kind
- type LLM
- type LLMUsage
- type Metadata
- type Metric
- type ModelUsage
- type ModelUsageCollector
- type OutputTokenDetails
- type Realtime
- type RequestUsage
- type STT
- type STTUsage
- type TTS
- type TTSUsage
- type UsageCollector
- type UsageKind
- type UsageSummary
- type VAD
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterZeroValues ¶
func FilterZeroValues(usage ModelUsage) map[string]any
FilterZeroValues returns the agents-js wire representation of usage with zero-valued numeric fields removed. The type, provider, and model fields are retained even when their strings are empty, matching agents-js.
func LogMetric ¶
LogMetric emits the concise structured summary used by agents-js. The full metric remains available to telemetry subscribers.
func LogMetrics ¶
LogMetrics is the TypeScript-compatible plural name.
Types ¶
type Avatar ¶
type Avatar struct {
Timestamp time.Time
PlaybackLatency time.Duration
SessionStarted time.Time
AvatarJoined time.Time
Metadata Metadata
}
func (Avatar) MarshalJSON ¶
func (Avatar) MetricKind ¶
func (Avatar) MetricMetadata ¶
func (Avatar) MetricTime ¶
type CachedTokenDetails ¶
type EOTInference ¶
type EOTInference struct {
Timestamp time.Time
TotalDuration time.Duration
PredictionDuration time.Duration
DetectionDelay time.Duration
NumRequests int64
Metadata Metadata
}
func (EOTInference) MarshalJSON ¶
func (m EOTInference) MarshalJSON() ([]byte, error)
func (EOTInference) MetricKind ¶
func (m EOTInference) MetricKind() Kind
func (EOTInference) MetricMetadata ¶
func (m EOTInference) MetricMetadata() Metadata
func (EOTInference) MetricTime ¶
func (m EOTInference) MetricTime() time.Time
type EOU ¶
type EOU struct {
Timestamp time.Time
EndOfUtteranceDelay time.Duration
TranscriptionDelay time.Duration
OnUserTurnCompletedDelay time.Duration
LastSpeakingTime time.Time
SpeechID string
Metadata Metadata
}
func (EOU) MarshalJSON ¶
func (EOU) MetricKind ¶
func (EOU) MetricMetadata ¶
func (EOU) MetricTime ¶
type InputTokenDetails ¶
type InputTokenDetails struct {
Audio int64 `json:"audioTokens"`
Text int64 `json:"textTokens"`
Image int64 `json:"imageTokens"`
Cached int64 `json:"cachedTokens"`
CachedDetails CachedTokenDetails `json:"cachedTokensDetails,omitempty"`
}
type Interruption ¶
type Interruption struct {
Timestamp time.Time
TotalDuration time.Duration
PredictionDuration time.Duration
DetectionDelay time.Duration
NumInterruptions int64
NumBackchannels int64
NumRequests int64
Metadata Metadata
}
func (Interruption) MarshalJSON ¶
func (m Interruption) MarshalJSON() ([]byte, error)
func (Interruption) MetricKind ¶
func (m Interruption) MetricKind() Kind
func (Interruption) MetricMetadata ¶
func (m Interruption) MetricMetadata() Metadata
func (Interruption) MetricTime ¶
func (m Interruption) MetricTime() time.Time
type Kind ¶
type Kind string
const ( KindLLM Kind = "llm_metrics" KindSTT Kind = "stt_metrics" KindTTS Kind = "tts_metrics" KindVAD Kind = "vad_metrics" KindEOU Kind = "eou_metrics" KindEOTInference Kind = "eot_inference_metrics" KindRealtime Kind = "realtime_model_metrics" KindInterruption Kind = "interruption_metrics" KindAvatar Kind = "avatar_metrics" )
type LLM ¶
type LLM struct {
Label string
RequestID string
Timestamp time.Time
Duration time.Duration
TimeToFirstToken time.Duration
Cancelled bool
CompletionTokens int64
PromptTokens int64
PromptCachedTokens int64
CacheCreationTokens int64
TotalTokens int64
TokensPerSecond float64
SpeechID string
Metadata Metadata
}
func (LLM) MarshalJSON ¶
func (LLM) MetricKind ¶
func (LLM) MetricMetadata ¶
func (LLM) MetricTime ¶
type LLMUsage ¶
type LLMUsage struct {
Provider string
Model string
InputTokens int64
InputCachedTokens int64
InputCacheCreationTokens int64
InputAudioTokens int64
InputCachedAudioTokens int64
InputTextTokens int64
InputCachedTextTokens int64
InputImageTokens int64
InputCachedImageTokens int64
OutputTokens int64
OutputAudioTokens int64
OutputTextTokens int64
SessionDuration time.Duration
}
func (LLMUsage) MarshalJSON ¶
func (LLMUsage) UsageModel ¶
func (LLMUsage) UsageProvider ¶
type ModelUsage ¶
type ModelUsageCollector ¶
type ModelUsageCollector struct {
// contains filtered or unexported fields
}
ModelUsageCollector is safe for concurrent collection and snapshots.
func NewModelUsageCollector ¶
func NewModelUsageCollector() *ModelUsageCollector
func (*ModelUsageCollector) Collect ¶
func (c *ModelUsageCollector) Collect(metric Metric)
func (*ModelUsageCollector) Snapshot ¶
func (c *ModelUsageCollector) Snapshot() []ModelUsage
type OutputTokenDetails ¶
type Realtime ¶
type Realtime struct {
Label string
RequestID string
Timestamp time.Time
Duration time.Duration
SessionDuration time.Duration
TimeToFirstToken time.Duration
Cancelled bool
InputTokens int64
OutputTokens int64
TotalTokens int64
TokensPerSecond float64
InputDetails InputTokenDetails
OutputDetails OutputTokenDetails
Metadata Metadata
}
func (Realtime) MarshalJSON ¶
func (Realtime) MetricKind ¶
func (Realtime) MetricMetadata ¶
func (Realtime) MetricTime ¶
type RequestUsage ¶
func (RequestUsage) MarshalJSON ¶
func (u RequestUsage) MarshalJSON() ([]byte, error)
func (RequestUsage) UsageKind ¶
func (u RequestUsage) UsageKind() UsageKind
func (RequestUsage) UsageModel ¶
func (u RequestUsage) UsageModel() string
func (RequestUsage) UsageProvider ¶
func (u RequestUsage) UsageProvider() string
type STT ¶
type STT struct {
Label string
RequestID string
Timestamp time.Time
Duration time.Duration
AudioDuration time.Duration
InputTokens int64
OutputTokens int64
Streamed bool
Metadata Metadata
}
func (STT) MarshalJSON ¶
func (STT) MetricKind ¶
func (STT) MetricMetadata ¶
func (STT) MetricTime ¶
type STTUsage ¶
type STTUsage struct {
Provider string
Model string
InputTokens int64
OutputTokens int64
AudioDuration time.Duration
}
func (STTUsage) MarshalJSON ¶
func (STTUsage) UsageModel ¶
func (STTUsage) UsageProvider ¶
type TTS ¶
type TTS struct {
Label string
RequestID string
Timestamp time.Time
TimeToFirstByte time.Duration
Duration time.Duration
AudioDuration time.Duration
Cancelled bool
CharactersCount int64
InputTokens int64
OutputTokens int64
Streamed bool
SegmentID string
SpeechID string
Metadata Metadata
}
func (TTS) MarshalJSON ¶
func (TTS) MetricKind ¶
func (TTS) MetricMetadata ¶
func (TTS) MetricTime ¶
type TTSUsage ¶
type TTSUsage struct {
Provider string
Model string
InputTokens int64
OutputTokens int64
CharactersCount int64
AudioDuration time.Duration
}
func (TTSUsage) MarshalJSON ¶
func (TTSUsage) UsageModel ¶
func (TTSUsage) UsageProvider ¶
type UsageCollector ¶
type UsageCollector struct {
// contains filtered or unexported fields
}
UsageCollector aggregates the legacy global counters. Deprecated: use ModelUsageCollector.
func NewUsageCollector ¶
func NewUsageCollector() *UsageCollector
func (*UsageCollector) Collect ¶
func (c *UsageCollector) Collect(metric Metric)
func (*UsageCollector) GetSummary ¶
func (c *UsageCollector) GetSummary() UsageSummary
GetSummary is the agents-js compatibility name for Summary.
func (*UsageCollector) Summary ¶
func (c *UsageCollector) Summary() UsageSummary
type UsageSummary ¶
type UsageSummary struct {
LLMPromptTokens int64
LLMPromptCachedTokens int64
LLMCompletionTokens int64
TTSCharactersCount int64
STTAudioDuration time.Duration
}
UsageSummary is retained for source compatibility. Deprecated: use ModelUsageCollector for provider/model attribution.
func (UsageSummary) MarshalJSON ¶
func (s UsageSummary) MarshalJSON() ([]byte, error)
type VAD ¶
type VAD struct {
Label string
Timestamp time.Time
IdleTime time.Duration
InferenceDurationTotal time.Duration
InferenceCount int64
Metadata Metadata
}