Documentation
¶
Index ¶
- Constants
- Variables
- func AddChatTraceEvents(span trace.Span, events []ChatTraceEvent)
- func CollectOTelUsage(metrics AgentMetrics)
- func CollectOTelUsageWithContext(ctx context.Context, metrics AgentMetrics)
- func InitLoggerProvider(ctx context.Context, endpoint string, headers map[string]string) error
- func LogMetrics(metrics AgentMetrics)
- func NewLLMSpan(ctx context.Context, model, provider string) (context.Context, trace.Span)
- func NewSTTStreamSpan(ctx context.Context, model, provider string) (context.Context, trace.Span)
- func NewTTSNodeSpan(ctx context.Context, model, provider string) (context.Context, trace.Span)
- func NewTTSStreamSpan(ctx context.Context, model, provider string) (context.Context, trace.Span)
- func RecordChatEvent(ctx context.Context, eventType string, body string, ...)
- func RecordOTelTurnMetrics(report map[string]any)
- func RecordOTelTurnMetricsWithContext(ctx context.Context, report map[string]any)
- func ShutdownLoggerProvider(ctx context.Context) error
- func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- type AgentMetrics
- type AgentSessionUsage
- type AvatarMetrics
- type CachedTokenDetails
- type ChatTraceEvent
- type EOUMetrics
- type HttpServer
- type InputTokenDetails
- type InterruptionMetrics
- type InterruptionModelUsage
- type LLMMetrics
- type LLMModelUsage
- type Metadata
- type MetricLabels
- type MetricRegistry
- type ModelUsage
- type ModelUsageCollector
- type OutputTokenDetails
- type RealtimeModelMetrics
- type STTMetrics
- type STTModelUsage
- type SpanContext
- type TTSMetrics
- type TTSModelUsage
- type UsageCollector
- type UsageSummary
- type VADMetrics
Constants ¶
View Source
const ( AttrSpeechID = "lk.speech_id" AttrAgentLabel = "lk.agent_label" AttrStartTime = "lk.start_time" AttrEndTime = "lk.end_time" AttrRetryCount = "lk.retry_count" AttrParticipantID = "lk.participant_id" AttrParticipantIdentity = "lk.participant_identity" AttrParticipantKind = "lk.participant_kind" AttrJobID = "lk.job_id" AttrAgentName = "lk.agent_name" AttrRoomName = "lk.room_name" AttrSessionOptions = "lk.session_options" AttrAgentTurnID = "lk.generation_id" AttrAgentParentTurnID = "lk.parent_generation_id" AttrUserInput = "lk.user_input" AttrInstructions = "lk.instructions" AttrSpeechInterrupted = "lk.interrupted" AttrChatCtx = "lk.chat_ctx" AttrFunctionTools = "lk.function_tools" AttrProviderTools = "lk.provider_tools" AttrToolSets = "lk.tool_sets" AttrResponseText = "lk.response.text" AttrResponseFunctionCalls = "lk.response.function_calls" AttrResponseTTFB = "lk.response.ttfb" AttrFunctionToolID = "lk.function_tool.id" AttrFunctionToolName = "lk.function_tool.name" AttrFunctionToolArgs = "lk.function_tool.arguments" AttrFunctionToolIsError = "lk.function_tool.is_error" AttrFunctionToolOutput = "lk.function_tool.output" AttrTTSInputText = "lk.input_text" AttrTTSStreaming = "lk.tts.streaming" AttrTTSLabel = "lk.tts.label" AttrEOUProbability = "lk.eou.probability" AttrEOUUnlikelyThreshold = "lk.eou.unlikely_threshold" AttrEOUDelay = "lk.eou.endpointing_delay" AttrEOULanguage = "lk.eou.language" AttrUserTranscript = "lk.user_transcript" AttrTranscriptConfidence = "lk.transcript_confidence" AttrTranscriptionDelay = "lk.transcription_delay" AttrEndOfTurnDelay = "lk.end_of_turn_delay" AttrGenAIOperationName = "gen_ai.operation.name" AttrGenAIProviderName = "gen_ai.provider.name" AttrGenAIRequestModel = "gen_ai.request.model" AttrGenAIUsageInputTokens = "gen_ai.usage.input_tokens" AttrGenAIUsageOutputTokens = "gen_ai.usage.output_tokens" EventGenAISystemMessage = "gen_ai.system.message" EventGenAIUserMessage = "gen_ai.user.message" EventGenAIAssistantMessage = "gen_ai.assistant.message" EventGenAIToolMessage = "gen_ai.tool.message" EventGenAIChoice = "gen_ai.choice" )
Variables ¶
View Source
var ChatLogger log.Logger
View Source
var Tracer = otel.Tracer("livekit-agents")
Functions ¶
func AddChatTraceEvents ¶ added in v0.0.15
func AddChatTraceEvents(span trace.Span, events []ChatTraceEvent)
func CollectOTelUsage ¶ added in v0.0.15
func CollectOTelUsage(metrics AgentMetrics)
func CollectOTelUsageWithContext ¶ added in v0.0.15
func CollectOTelUsageWithContext(ctx context.Context, metrics AgentMetrics)
func InitLoggerProvider ¶
func LogMetrics ¶
func LogMetrics(metrics AgentMetrics)
func NewLLMSpan ¶
func NewSTTStreamSpan ¶
func NewTTSNodeSpan ¶ added in v0.0.15
func NewTTSStreamSpan ¶
func RecordChatEvent ¶
func RecordOTelTurnMetrics ¶ added in v0.0.15
func RecordOTelTurnMetricsWithContext ¶ added in v0.0.15
func ShutdownLoggerProvider ¶
Types ¶
type AgentMetrics ¶
type AgentMetrics interface {
GetType() string
}
type AgentSessionUsage ¶ added in v0.0.15
type AgentSessionUsage struct {
ModelUsage []ModelUsage `json:"model_usage"`
}
func (AgentSessionUsage) LLMInputTokens ¶ added in v0.0.15
func (s AgentSessionUsage) LLMInputTokens() int
func (AgentSessionUsage) LLMOutputTokens ¶ added in v0.0.15
func (s AgentSessionUsage) LLMOutputTokens() int
type AvatarMetrics ¶ added in v0.0.15
type AvatarMetrics struct {
Label string
Timestamp time.Time
PlaybackLatency float64
SessionStartedTime *time.Time
AvatarJoinedTime *time.Time
Metadata *Metadata
}
func (*AvatarMetrics) GetType ¶ added in v0.0.15
func (m *AvatarMetrics) GetType() string
type CachedTokenDetails ¶
type ChatTraceEvent ¶ added in v0.0.15
type EOUMetrics ¶
type EOUMetrics struct {
Timestamp time.Time
EndOfUtteranceDelay float64
TranscriptionDelay float64
OnUserTurnCompletedDelay float64
SpeechID string
Metadata *Metadata
}
func (*EOUMetrics) GetType ¶
func (m *EOUMetrics) GetType() string
type HttpServer ¶
func NewHttpServer ¶
func NewHttpServer(host string, port int) *HttpServer
func NewHttpServerWithListen ¶ added in v0.0.15
func (*HttpServer) Start ¶
func (s *HttpServer) Start() error
type InputTokenDetails ¶
type InputTokenDetails struct {
AudioTokens int
TextTokens int
ImageTokens int
CachedTokens int
CachedTokensDetails *CachedTokenDetails
}
type InterruptionMetrics ¶ added in v0.0.15
type InterruptionMetrics struct {
Label string
Timestamp time.Time
TotalDuration float64
PredictionDuration float64
DetectionDelay float64
NumInterruptions int
NumBackchannels int
NumRequests int
Metadata *Metadata
}
func (*InterruptionMetrics) GetType ¶ added in v0.0.15
func (m *InterruptionMetrics) GetType() string
type InterruptionModelUsage ¶ added in v0.0.15
type InterruptionModelUsage struct {
Type string `json:"type"`
Provider string `json:"provider"`
Model string `json:"model"`
TotalRequests int `json:"total_requests"`
}
func (*InterruptionModelUsage) GetType ¶ added in v0.0.15
func (u *InterruptionModelUsage) GetType() string
type LLMMetrics ¶
type LLMMetrics struct {
Label string
RequestID string
Timestamp time.Time
Duration float64
TTFT float64
Cancelled bool
CompletionTokens int
PromptTokens int
PromptCachedTokens int
TotalTokens int
TokensPerSecond float64
SpeechID string
Metadata *Metadata
}
func (*LLMMetrics) GetType ¶
func (m *LLMMetrics) GetType() string
type LLMModelUsage ¶ added in v0.0.15
type LLMModelUsage struct {
Type string `json:"type"`
Provider string `json:"provider"`
Model string `json:"model"`
InputTokens int `json:"input_tokens"`
InputCachedTokens int `json:"input_cached_tokens"`
InputAudioTokens int `json:"input_audio_tokens"`
InputCachedAudioTokens int `json:"input_cached_audio_tokens"`
InputTextTokens int `json:"input_text_tokens"`
InputCachedTextTokens int `json:"input_cached_text_tokens"`
InputImageTokens int `json:"input_image_tokens"`
InputCachedImageTokens int `json:"input_cached_image_tokens"`
OutputTokens int `json:"output_tokens"`
OutputAudioTokens int `json:"output_audio_tokens"`
OutputTextTokens int `json:"output_text_tokens"`
SessionDuration float64 `json:"session_duration"`
}
func (*LLMModelUsage) GetType ¶ added in v0.0.15
func (u *LLMModelUsage) GetType() string
type MetricLabels ¶
type MetricRegistry ¶
type MetricRegistry struct {
// contains filtered or unexported fields
}
func NewMetricRegistry ¶
func NewMetricRegistry() *MetricRegistry
func (*MetricRegistry) GetUsageCollector ¶
func (r *MetricRegistry) GetUsageCollector(labels MetricLabels) *UsageCollector
type ModelUsage ¶ added in v0.0.15
type ModelUsage interface {
GetType() string
}
type ModelUsageCollector ¶ added in v0.0.15
type ModelUsageCollector struct {
// contains filtered or unexported fields
}
func NewModelUsageCollector ¶ added in v0.0.15
func NewModelUsageCollector() *ModelUsageCollector
func (*ModelUsageCollector) Collect ¶ added in v0.0.15
func (c *ModelUsageCollector) Collect(metrics AgentMetrics)
func (*ModelUsageCollector) Flatten ¶ added in v0.0.15
func (c *ModelUsageCollector) Flatten() []ModelUsage
func (*ModelUsageCollector) Usage ¶ added in v0.0.15
func (c *ModelUsageCollector) Usage() AgentSessionUsage
type OutputTokenDetails ¶
type RealtimeModelMetrics ¶
type RealtimeModelMetrics struct {
Label string
RequestID string
Timestamp time.Time
Duration float64
SessionDuration float64
TTFT float64
Cancelled bool
InputTokens int
OutputTokens int
TotalTokens int
TokensPerSecond float64
InputTokenDetails InputTokenDetails
OutputTokenDetails OutputTokenDetails
AcquireTime float64
ConnectionReused bool
Metadata *Metadata
}
func (*RealtimeModelMetrics) GetType ¶
func (m *RealtimeModelMetrics) GetType() string
type STTMetrics ¶
type STTMetrics struct {
Label string
RequestID string
Timestamp time.Time
Duration float64
AudioDuration float64
InputTokens int
OutputTokens int
Streamed bool
AcquireTime float64
ConnectionReused bool
Metadata *Metadata
}
func (*STTMetrics) GetType ¶
func (m *STTMetrics) GetType() string
type STTModelUsage ¶ added in v0.0.15
type STTModelUsage struct {
Type string `json:"type"`
Provider string `json:"provider"`
Model string `json:"model"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
AudioDuration float64 `json:"audio_duration"`
}
func (*STTModelUsage) GetType ¶ added in v0.0.15
func (u *STTModelUsage) GetType() string
type SpanContext ¶
type TTSMetrics ¶
type TTSMetrics struct {
Label string
RequestID string
Timestamp time.Time
TTFB float64
Duration float64
AudioDuration float64
Cancelled bool
CharactersCount int
InputTokens int
OutputTokens int
Streamed bool
SegmentID string
SpeechID string
AcquireTime float64
ConnectionReused bool
Metadata *Metadata
}
func (*TTSMetrics) GetType ¶
func (m *TTSMetrics) GetType() string
type TTSModelUsage ¶ added in v0.0.15
type TTSModelUsage struct {
Type string `json:"type"`
Provider string `json:"provider"`
Model string `json:"model"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
CharactersCount int `json:"characters_count"`
AudioDuration float64 `json:"audio_duration"`
}
func (*TTSModelUsage) GetType ¶ added in v0.0.15
func (u *TTSModelUsage) GetType() string
type UsageCollector ¶
type UsageCollector struct {
// contains filtered or unexported fields
}
func NewUsageCollector ¶
func NewUsageCollector() *UsageCollector
func (*UsageCollector) Collect ¶
func (c *UsageCollector) Collect(metrics AgentMetrics)
func (*UsageCollector) GetSummary ¶
func (c *UsageCollector) GetSummary() UsageSummary
type UsageSummary ¶
type UsageSummary struct {
LLMPromptTokens int
LLMPromptCachedTokens int
LLMInputAudioTokens int
LLMInputCachedAudioTokens int
LLMInputTextTokens int
LLMInputCachedTextTokens int
LLMInputImageTokens int
LLMInputCachedImageTokens int
LLMCompletionTokens int
LLMOutputAudioTokens int
LLMOutputImageTokens int
LLMOutputTextTokens int
TTSCharactersCount int
TTSAudioDuration float64
STTAudioDuration float64
}
func (UsageSummary) LLMInputTokens ¶ added in v0.0.15
func (s UsageSummary) LLMInputTokens() int
func (UsageSummary) LLMOutputTokens ¶ added in v0.0.15
func (s UsageSummary) LLMOutputTokens() int
func (*UsageSummary) SetLLMInputTokens ¶ added in v0.0.15
func (s *UsageSummary) SetLLMInputTokens(value int)
func (*UsageSummary) SetLLMOutputTokens ¶ added in v0.0.15
func (s *UsageSummary) SetLLMOutputTokens(value int)
Click to show internal directories.
Click to hide internal directories.