Documentation
¶
Overview ¶
Package rtvi implements the RTVI protocol over a transport's messaging channel: a JSON message format and a processor that completes the client handshake and reports pipeline events to the client.
RTVI (Real-Time Voice Interface) is the protocol the Pipecat client SDKs speak, so a jargo server interoperates with existing RTVI web, iOS and Android clients. Messages are JSON objects of the form {"label":"rtvi-ai","type":...,"id":...,"data":...} exchanged over the WebRTC data channel.
Index ¶
- Constants
- type BotReadyData
- type ErrorData
- type Incoming
- type Message
- func BotLLMText(text string) Message
- func BotReady(id string) Message
- func BotTTSText(text string) Message
- func BotTranscription(text string) Message
- func Error(msg string, fatal bool) Message
- func Metrics(data MetricsData) Message
- func UserTranscription(text, userID, timestamp string, final bool) Message
- type MetricData
- type MetricsData
- type Processor
- type TextData
- type TokenMetricData
- type UserTranscriptionData
Constants ¶
const ( // MessageLabel tags every RTVI message. MessageLabel = "rtvi-ai" // ProtocolVersion is the RTVI protocol version this implementation speaks. ProtocolVersion = "2.0.0" )
const ( TypeClientReady = "client-ready" TypeBotReady = "bot-ready" TypeError = "error" TypeUserTranscription = "user-transcription" TypeBotTranscription = "bot-transcription" TypeBotTTSText = "bot-tts-text" TypeBotLLMText = "bot-llm-text" TypeUserStartedSpeaking = "user-started-speaking" TypeUserStoppedSpeaking = "user-stopped-speaking" TypeBotStartedSpeaking = "bot-started-speaking" TypeBotStoppedSpeaking = "bot-stopped-speaking" TypeMetrics = "metrics" )
Message types exchanged over the data channel.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BotReadyData ¶
type BotReadyData struct {
Version string `json:"version"`
}
BotReadyData is the payload of a bot-ready message.
type Incoming ¶
type Incoming struct {
Label string `json:"label"`
Type string `json:"type"`
ID string `json:"id"`
Data json.RawMessage `json:"data"`
}
Incoming is a received RTVI message with its data left as raw JSON for type-specific decoding.
func ParseIncoming ¶
ParseIncoming decodes a received RTVI message.
type Message ¶
type Message struct {
Label string `json:"label"`
Type string `json:"type"`
ID string `json:"id,omitempty"`
Data any `json:"data,omitempty"`
}
Message is the RTVI message envelope. Outgoing event messages omit id; bot-ready and responses echo the request id.
func BotTranscription ¶
BotTranscription builds a bot-transcription message.
func UserTranscription ¶
UserTranscription builds a user-transcription message.
type MetricData ¶
type MetricData struct {
Processor string `json:"processor"`
Value float64 `json:"value"`
Model string `json:"model,omitempty"`
}
MetricData is one timing or count entry in a metrics message (ttfb, processing or characters). Value is in seconds for timings, or a count.
type MetricsData ¶
type MetricsData struct {
TTFB []MetricData `json:"ttfb,omitempty"`
Processing []MetricData `json:"processing,omitempty"`
Characters []MetricData `json:"characters,omitempty"`
Tokens []TokenMetricData `json:"tokens,omitempty"`
}
MetricsData is the payload of a metrics message: each kind is a list so a single message can report several processors at once.
type Processor ¶
Processor bridges a pipeline to an RTVI client. It completes the handshake — replying to client-ready with bot-ready — and reports pipeline events (transcriptions, speaking state, errors, LLM text) to the client as RTVI messages. Place it in the pipeline upstream of the output transport, which carries the messages to the client.
Incoming client messages arrive as InputTransportMessageFrames; outgoing messages are pushed downstream as OutputTransportMessageFrames.
type TextData ¶
type TextData struct {
Text string `json:"text"`
}
TextData is the payload of text messages (bot-transcription, bot-tts-text, bot-llm-text).
type TokenMetricData ¶
type TokenMetricData struct {
Processor string `json:"processor"`
Model string `json:"model,omitempty"`
PromptTokens int64 `json:"prompt_tokens"`
CompletionTokens int64 `json:"completion_tokens"`
TotalTokens int64 `json:"total_tokens"`
}
TokenMetricData is one LLM token-usage entry in a metrics message.