Documentation
¶
Overview ¶
Package rtvi implements the RTVI (Real-Time Voice Interface) protocol processor and message types.
Index ¶
Constants ¶
const ( TypeClientReady = "client-ready" TypeSendText = "send-text" )
Client message types.
const ( TypeBotReady = "bot-ready" TypeError = "error" TypeErrorResponse = "error-response" TypeServerResponse = "server-response" )
Server message types.
const MessageLabel = "rtvi-ai"
MessageLabel is the RTVI message label on the wire.
const ProtocolVersion = "1.2.0"
RTVI protocol version sent in bot-ready.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BotReadyData ¶
type BotReadyData struct {
Version string `json:"version"`
About map[string]any `json:"about,omitempty"`
}
BotReadyData is the data payload for bot-ready (server).
type ErrorResponseData ¶
type ErrorResponseData struct {
Error string `json:"error"`
}
ErrorResponseData is the data payload for error-response (server).
type Message ¶
type Message struct {
Label string `json:"label"`
Type string `json:"type"`
ID string `json:"id"`
Data map[string]any `json:"data,omitempty"`
}
Message is the generic RTVI wire message (client and server).
type RTVIProcessor ¶
type RTVIProcessor struct {
*processors.BaseProcessor
// contains filtered or unexported fields
}
RTVIProcessor handles RTVI protocol: StartFrame -> send bot-ready; RTVIClientMessageFrame -> client-ready/send-text; forwards other frames.
func NewRTVIProcessor ¶
func NewRTVIProcessor(name string, sender RTVISender, version string) *RTVIProcessor
NewRTVIProcessor returns an RTVI processor. If sender is nil, bot-ready and error responses are not sent.
func NewRTVIProcessorFromOptions ¶
func NewRTVIProcessorFromOptions(name string, opts json.RawMessage) *RTVIProcessor
NewRTVIProcessorFromOptions builds an RTVIProcessor from plugin_options. Sender must be set by the runner when using RTVI transport.
func (*RTVIProcessor) ProcessFrame ¶
func (p *RTVIProcessor) ProcessFrame(ctx context.Context, f frames.Frame, dir processors.Direction) error
ProcessFrame implements processors.Processor.
func (*RTVIProcessor) SetSender ¶
func (p *RTVIProcessor) SetSender(s RTVISender)
SetSender sets the RTVI sender (e.g. by the server when building the pipeline for an RTVI connection).
type RTVIProcessorOptions ¶
type RTVIProcessorOptions struct {
ProtocolVersion string `json:"protocol_version"` // optional override
}
RTVIProcessorOptions is the JSON shape for plugin_options["rtvi"].
type RTVISender ¶
RTVISender sends RTVI protocol messages to the client (e.g. bot-ready, error). Optional; when nil, processor does not send.
type SendTextData ¶
type SendTextData struct {
Content string `json:"content"`
Options *SendTextOpts `json:"options,omitempty"`
}
SendTextData is the data payload for send-text (client).
type SendTextOpts ¶
type SendTextOpts struct {
RunImmediately bool `json:"run_immediately"`
AudioResponse bool `json:"audio_response"`
}
SendTextOpts options for send-text.
type Serializer ¶
type Serializer struct{}
Serializer converts between pipeline frames and RTVI protocol JSON. Use when the transport speaks RTVI (e.g. WebSocket with ?rtvi=1).
func (Serializer) Deserialize ¶
func (Serializer) Deserialize(data []byte) (frames.Frame, error)
Deserialize parses RTVI client message JSON and returns an RTVIClientMessageFrame.
type ServerResponseData ¶
type ServerResponseData struct {
T string `json:"t"` // type from client
D map[string]any `json:"d,omitempty"`
}
ServerResponseData is the data payload for server-response (server).