sync: migrate ai-operator to Gitea (2026-08-10)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package pipeline
|
||||
|
||||
import "time"
|
||||
|
||||
type LatencyMetrics struct {
|
||||
CallID string
|
||||
TurnID string
|
||||
TurnStartedAt time.Time
|
||||
STTFirstPartialAt time.Time
|
||||
STTCommittedAt time.Time
|
||||
LLMFirstTokenAt time.Time
|
||||
TTSFirstAudioAt time.Time
|
||||
FirstAudibleAudioAt time.Time
|
||||
CompletedAt time.Time
|
||||
STTChars int
|
||||
LLMChars int
|
||||
TTSAudioBytes int
|
||||
Interruptions int
|
||||
}
|
||||
|
||||
func (m LatencyMetrics) Snapshot() map[string]any {
|
||||
return map[string]any{
|
||||
"call_id": m.CallID,
|
||||
"turn_id": m.TurnID,
|
||||
"stt_first_partial_ms": sinceMS(m.TurnStartedAt, m.STTFirstPartialAt),
|
||||
"stt_committed_ms": sinceMS(m.TurnStartedAt, m.STTCommittedAt),
|
||||
"llm_first_token_ms": sinceMS(m.STTCommittedAt, m.LLMFirstTokenAt),
|
||||
"tts_first_audio_ms": sinceMS(m.LLMFirstTokenAt, m.TTSFirstAudioAt),
|
||||
"first_audible_audio_ms": sinceMS(m.STTCommittedAt, m.FirstAudibleAudioAt),
|
||||
"total_turn_ms": sinceMS(m.TurnStartedAt, m.CompletedAt),
|
||||
"stt_chars": m.STTChars,
|
||||
"llm_chars": m.LLMChars,
|
||||
"tts_audio_bytes": m.TTSAudioBytes,
|
||||
"interruptions_count": m.Interruptions,
|
||||
}
|
||||
}
|
||||
|
||||
func sinceMS(start, end time.Time) any {
|
||||
if start.IsZero() || end.IsZero() {
|
||||
return nil
|
||||
}
|
||||
return end.Sub(start).Milliseconds()
|
||||
}
|
||||
Reference in New Issue
Block a user