Documentation
¶
Index ¶
- Variables
- type Callbacks
- type DeepgramSession
- func (s *DeepgramSession) ConversationID() string
- func (s *DeepgramSession) InjectMessage(ctx context.Context, message string) error
- func (s *DeepgramSession) Running() bool
- func (s *DeepgramSession) Start(ctx context.Context, reader io.Reader, writer io.Writer, apiKey string, ...) error
- func (s *DeepgramSession) Stop()
- type ElevenLabsSession
- func (s *ElevenLabsSession) ConversationID() string
- func (s *ElevenLabsSession) InjectMessage(ctx context.Context, message string) error
- func (s *ElevenLabsSession) Running() bool
- func (s *ElevenLabsSession) Start(ctx context.Context, reader io.Reader, writer io.Writer, apiKey string, ...) error
- func (s *ElevenLabsSession) Stop()
- type Options
- type PipecatSession
- func (p *PipecatSession) ConversationID() string
- func (p *PipecatSession) InjectMessage(ctx context.Context, message string) error
- func (p *PipecatSession) Running() bool
- func (p *PipecatSession) Start(ctx context.Context, reader io.Reader, writer io.Writer, apiKey string, ...) error
- func (p *PipecatSession) Stop()
- type Provider
- type VAPISession
- func (v *VAPISession) ConversationID() string
- func (v *VAPISession) InjectMessage(ctx context.Context, message string) error
- func (v *VAPISession) Running() bool
- func (v *VAPISession) Start(ctx context.Context, reader io.Reader, writer io.Writer, apiKey string, ...) error
- func (v *VAPISession) Stop()
Constants ¶
This section is empty.
Variables ¶
var ErrNotSupported = errors.New("operation not supported by this provider")
ErrNotSupported is returned when a provider does not support an operation.
Functions ¶
This section is empty.
Types ¶
type Callbacks ¶
type Callbacks struct {
OnConnected func(conversationID string)
OnDisconnected func()
OnUserTranscript func(text string)
OnAgentResponse func(text string)
}
Callbacks receives events from the agent session.
type DeepgramSession ¶
type DeepgramSession struct {
// contains filtered or unexported fields
}
DeepgramSession manages a WebSocket connection to the Deepgram Voice Agent API.
func NewDeepgram ¶
func NewDeepgram(log *slog.Logger) *DeepgramSession
func (*DeepgramSession) ConversationID ¶
func (s *DeepgramSession) ConversationID() string
func (*DeepgramSession) InjectMessage ¶
func (s *DeepgramSession) InjectMessage(ctx context.Context, message string) error
InjectMessage sends an InjectAgentMessage command to the Deepgram Voice Agent.
func (*DeepgramSession) Running ¶
func (s *DeepgramSession) Running() bool
func (*DeepgramSession) Start ¶
func (s *DeepgramSession) Start(ctx context.Context, reader io.Reader, writer io.Writer, apiKey string, opts Options, cb Callbacks) error
Start dials the Deepgram Voice Agent WebSocket and streams audio bidirectionally. reader provides 16kHz 16-bit PCM mono (what humans say). writer receives 16kHz 16-bit PCM mono (agent's spoken audio). Blocks until the context is cancelled or an error occurs.
func (*DeepgramSession) Stop ¶
func (s *DeepgramSession) Stop()
type ElevenLabsSession ¶
type ElevenLabsSession struct {
// contains filtered or unexported fields
}
ElevenLabsSession manages a WebSocket connection to the ElevenLabs ConvAI API.
func NewElevenLabs ¶
func NewElevenLabs(log *slog.Logger) *ElevenLabsSession
func (*ElevenLabsSession) ConversationID ¶
func (s *ElevenLabsSession) ConversationID() string
ConversationID returns the conversation ID assigned by ElevenLabs.
func (*ElevenLabsSession) InjectMessage ¶
func (s *ElevenLabsSession) InjectMessage(ctx context.Context, message string) error
InjectMessage is not supported by ElevenLabs.
func (*ElevenLabsSession) Running ¶
func (s *ElevenLabsSession) Running() bool
Running returns whether the session is active.
func (*ElevenLabsSession) Start ¶
func (s *ElevenLabsSession) Start(ctx context.Context, reader io.Reader, writer io.Writer, apiKey string, opts Options, cb Callbacks) error
Start dials the ElevenLabs ConvAI WebSocket and streams audio bidirectionally. reader provides 16kHz 16-bit PCM mono (what humans say). writer receives 16kHz 16-bit PCM mono (agent's spoken audio). Blocks until the context is cancelled or an error occurs.
func (*ElevenLabsSession) Stop ¶
func (s *ElevenLabsSession) Stop()
Stop cancels the running agent session.
type Options ¶
type Options struct {
AgentID string
Language string
FirstMessage string
DynamicVariables map[string]string
Settings map[string]interface{} // Deepgram: full agent settings object
}
Options configures the agent session.
type PipecatSession ¶
type PipecatSession struct {
// contains filtered or unexported fields
}
PipecatSession manages a WebSocket connection to a Pipecat bot. The agent_id in Options is the WebSocket URL of the running Pipecat bot (e.g. "ws://my-pipecat-bot:8765").
func NewPipecat ¶
func NewPipecat(log *slog.Logger) *PipecatSession
func (*PipecatSession) ConversationID ¶
func (p *PipecatSession) ConversationID() string
ConversationID returns the Pipecat bot URL used as the conversation identifier.
func (*PipecatSession) InjectMessage ¶
func (p *PipecatSession) InjectMessage(ctx context.Context, message string) error
InjectMessage sends a TextFrame to the Pipecat bot.
func (*PipecatSession) Running ¶
func (p *PipecatSession) Running() bool
Running returns whether the session is active.
func (*PipecatSession) Start ¶
func (p *PipecatSession) Start(ctx context.Context, reader io.Reader, writer io.Writer, apiKey string, opts Options, cb Callbacks) error
Start connects to the Pipecat bot WebSocket and streams audio bidirectionally. The apiKey parameter is unused (Pipecat bots don't require platform API keys). opts.AgentID must be the WebSocket URL of the Pipecat bot.
func (*PipecatSession) Stop ¶
func (p *PipecatSession) Stop()
Stop cancels the running Pipecat session.
type Provider ¶
type Provider interface {
Start(ctx context.Context, reader io.Reader, writer io.Writer,
apiKey string, opts Options, cb Callbacks) error
Stop()
Running() bool
ConversationID() string
InjectMessage(ctx context.Context, message string) error
}
Provider is the common interface for conversational AI agent backends.
type VAPISession ¶
type VAPISession struct {
// contains filtered or unexported fields
}
VAPISession manages a WebSocket connection to the VAPI conversational AI API.
func NewVAPI ¶
func NewVAPI(log *slog.Logger) *VAPISession
func (*VAPISession) ConversationID ¶
func (v *VAPISession) ConversationID() string
ConversationID returns the call ID assigned by VAPI.
func (*VAPISession) InjectMessage ¶
func (v *VAPISession) InjectMessage(ctx context.Context, message string) error
InjectMessage sends a system message to the VAPI call via the control URL.
func (*VAPISession) Running ¶
func (v *VAPISession) Running() bool
Running returns whether the session is active.
func (*VAPISession) Start ¶
func (v *VAPISession) Start(ctx context.Context, reader io.Reader, writer io.Writer, apiKey string, opts Options, cb Callbacks) error
Start creates a VAPI call, connects to the returned WebSocket, and streams audio bidirectionally. Blocks until the context is cancelled or an error occurs.