rtvi

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package rtvi implements the RTVI (Real-Time Voice Interface) protocol processor and message types.

Index

Constants

View Source
const (
	TypeClientReady = "client-ready"
	TypeSendText    = "send-text"
)

Client message types.

View Source
const (
	TypeBotReady       = "bot-ready"
	TypeError          = "error"
	TypeErrorResponse  = "error-response"
	TypeServerResponse = "server-response"
)

Server message types.

View Source
const MessageLabel = "rtvi-ai"

MessageLabel is the RTVI message label on the wire.

View Source
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 ErrorData

type ErrorData struct {
	Error string `json:"error"`
	Fatal bool   `json:"fatal"`
}

ErrorData is the data payload for error (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

type RTVISender interface {
	SendRTVIMessage(msg *Message) error
}

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.

func (Serializer) Serialize

func (Serializer) Serialize(f frames.Frame) ([]byte, error)

Serialize converts a pipeline frame to RTVI server message JSON. Returns nil, nil for frames that should not be sent as RTVI.

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL