Documentation
¶
Overview ¶
Package registry provides types for provider registration and discovery.
Index ¶
- type CallSystemProviderFactory
- type Gateway
- type GatewayProviderFactory
- type ProviderConfig
- type ProviderOption
- func WithAPIKey(apiKey string) ProviderOption
- func WithAccountSID(sid string) ProviderOption
- func WithAuthToken(token string) ProviderOption
- func WithBaseURL(baseURL string) ProviderOption
- func WithConnectionID(id string) ProviderOption
- func WithExtension(key string, value any) ProviderOption
- func WithGreeting(greeting string) ProviderOption
- func WithInstructions(instructions string) ProviderOption
- func WithInterruptionMode(mode string) ProviderOption
- func WithLLMAPIKey(apiKey string) ProviderOption
- func WithLLMModel(model string) ProviderOption
- func WithLLMProvider(provider string) ProviderOption
- func WithLLMSystemPrompt(prompt string) ProviderOption
- func WithListenAddr(addr string) ProviderOption
- func WithListener(listener net.Listener) ProviderOption
- func WithLogger(logger *slog.Logger) ProviderOption
- func WithMaxSessionDuration(d time.Duration) ProviderOption
- func WithModel(model string) ProviderOption
- func WithPhoneNumber(number string) ProviderOption
- func WithPipelineMode(mode string) ProviderOption
- func WithPublicURL(url string) ProviderOption
- func WithRegion(region string) ProviderOption
- func WithSTTAPIKey(apiKey string) ProviderOption
- func WithSTTLanguage(language string) ProviderOption
- func WithSTTModel(model string) ProviderOption
- func WithSTTProvider(provider string) ProviderOption
- func WithTTSAPIKey(apiKey string) ProviderOption
- func WithTTSModel(model string) ProviderOption
- func WithTTSProvider(provider string) ProviderOption
- func WithTTSVoiceID(voiceID string) ProviderOption
- func WithVoice(voice string) ProviderOption
- func WithWebhookURL(url string) ProviderOption
- type RealtimeProvider
- type RealtimeProviderFactory
- type Registry
- type STTProviderFactory
- type TTSProviderFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallSystemProviderFactory ¶
type CallSystemProviderFactory func(config ProviderConfig) (callsystem.CallSystem, error)
CallSystemProviderFactory creates a CallSystem provider with the given configuration.
type Gateway ¶ added in v0.14.0
type Gateway interface {
// Name returns the provider name.
Name() string
// Start starts the gateway server.
Start(ctx any) error
// Stop gracefully shuts down the gateway.
Stop() error
}
Gateway is the interface that voice gateway providers must implement. This is defined here to avoid import cycles with the gateway package. See gateway.Gateway for the full interface documentation.
type GatewayProviderFactory ¶ added in v0.14.0
type GatewayProviderFactory func(config ProviderConfig) (Gateway, error)
GatewayProviderFactory creates a voice Gateway with the given configuration. Gateway providers handle full-duplex voice calls via telephony providers.
type ProviderConfig ¶
type ProviderConfig struct {
// APIKey is the authentication key for the provider.
APIKey string //nolint:gosec // G117: This is a config struct, not storing secrets
// BaseURL is an optional custom API endpoint.
BaseURL string
// Extensions holds provider-specific configuration.
Extensions map[string]any
}
ProviderConfig holds common configuration options for creating providers.
func ApplyOptions ¶
func ApplyOptions(opts ...ProviderOption) ProviderConfig
ApplyOptions applies provider options to a config.
type ProviderOption ¶
type ProviderOption func(*ProviderConfig)
ProviderOption configures a ProviderConfig.
func WithAPIKey ¶
func WithAPIKey(apiKey string) ProviderOption
WithAPIKey sets the API key for the provider.
func WithAccountSID ¶
func WithAccountSID(sid string) ProviderOption
WithAccountSID sets the account SID (Twilio).
func WithAuthToken ¶
func WithAuthToken(token string) ProviderOption
WithAuthToken sets the auth token (Twilio).
func WithBaseURL ¶
func WithBaseURL(baseURL string) ProviderOption
WithBaseURL sets a custom base URL for the provider.
func WithConnectionID ¶ added in v0.14.0
func WithConnectionID(id string) ProviderOption
WithConnectionID sets the connection ID (Telnyx).
func WithExtension ¶
func WithExtension(key string, value any) ProviderOption
WithExtension sets a provider-specific configuration value.
func WithGreeting ¶ added in v0.14.0
func WithGreeting(greeting string) ProviderOption
WithGreeting sets the initial greeting message.
func WithInstructions ¶ added in v0.14.0
func WithInstructions(instructions string) ProviderOption
WithInstructions sets the system prompt/instructions.
func WithInterruptionMode ¶ added in v0.14.0
func WithInterruptionMode(mode string) ProviderOption
WithInterruptionMode sets the interruption mode.
func WithLLMAPIKey ¶ added in v0.14.0
func WithLLMAPIKey(apiKey string) ProviderOption
WithLLMAPIKey sets the LLM API key.
func WithLLMModel ¶ added in v0.14.0
func WithLLMModel(model string) ProviderOption
WithLLMModel sets the LLM model.
func WithLLMProvider ¶ added in v0.14.0
func WithLLMProvider(provider string) ProviderOption
WithLLMProvider sets the LLM provider name.
func WithLLMSystemPrompt ¶ added in v0.14.0
func WithLLMSystemPrompt(prompt string) ProviderOption
WithLLMSystemPrompt sets the LLM system prompt.
func WithListenAddr ¶ added in v0.14.0
func WithListenAddr(addr string) ProviderOption
WithListenAddr sets the address for the gateway to listen on.
func WithListener ¶ added in v0.14.0
func WithListener(listener net.Listener) ProviderOption
WithListener sets an external net.Listener for the gateway server. Useful for ngrok or custom listeners.
func WithLogger ¶ added in v0.14.0
func WithLogger(logger *slog.Logger) ProviderOption
WithLogger sets the logger.
func WithMaxSessionDuration ¶ added in v0.14.0
func WithMaxSessionDuration(d time.Duration) ProviderOption
WithMaxSessionDuration sets the maximum session duration.
func WithModel ¶ added in v0.14.0
func WithModel(model string) ProviderOption
WithModel sets the model for the provider.
func WithPhoneNumber ¶
func WithPhoneNumber(number string) ProviderOption
WithPhoneNumber sets the default outbound phone number.
func WithPipelineMode ¶ added in v0.14.0
func WithPipelineMode(mode string) ProviderOption
WithPipelineMode sets the pipeline mode ("text" or "realtime").
func WithPublicURL ¶ added in v0.14.0
func WithPublicURL(url string) ProviderOption
WithPublicURL sets the public URL for webhooks.
func WithSTTAPIKey ¶ added in v0.14.0
func WithSTTAPIKey(apiKey string) ProviderOption
WithSTTAPIKey sets the STT API key.
func WithSTTLanguage ¶ added in v0.14.0
func WithSTTLanguage(language string) ProviderOption
WithSTTLanguage sets the STT language.
func WithSTTModel ¶ added in v0.14.0
func WithSTTModel(model string) ProviderOption
WithSTTModel sets the STT model.
func WithSTTProvider ¶ added in v0.14.0
func WithSTTProvider(provider string) ProviderOption
WithSTTProvider sets the STT provider name.
func WithTTSAPIKey ¶ added in v0.14.0
func WithTTSAPIKey(apiKey string) ProviderOption
WithTTSAPIKey sets the TTS API key.
func WithTTSModel ¶ added in v0.14.0
func WithTTSModel(model string) ProviderOption
WithTTSModel sets the TTS model.
func WithTTSProvider ¶ added in v0.14.0
func WithTTSProvider(provider string) ProviderOption
WithTTSProvider sets the TTS provider name.
func WithTTSVoiceID ¶ added in v0.14.0
func WithTTSVoiceID(voiceID string) ProviderOption
WithTTSVoiceID sets the TTS voice ID.
func WithVoice ¶ added in v0.14.0
func WithVoice(voice string) ProviderOption
WithVoice sets the voice for realtime audio output.
func WithWebhookURL ¶
func WithWebhookURL(url string) ProviderOption
WithWebhookURL sets the webhook URL for incoming calls.
type RealtimeProvider ¶ added in v0.14.0
type RealtimeProvider interface {
// Name returns the provider name (e.g., "openai", "gemini").
Name() string
// Close closes the provider and releases resources.
Close() error
}
RealtimeProvider is the interface that realtime voice-to-voice providers must implement. This is defined here to avoid import cycles with the realtime package. See realtime.Provider for the full interface documentation.
type RealtimeProviderFactory ¶ added in v0.14.0
type RealtimeProviderFactory func(config ProviderConfig) (RealtimeProvider, error)
RealtimeProviderFactory creates realtime voice-to-voice providers. Realtime providers enable native voice-to-voice conversations with ~100-300ms latency.
type Registry ¶
type Registry interface {
// TTS registration
RegisterTTSProvider(name string, factory TTSProviderFactory)
GetTTSProvider(name string, opts ...ProviderOption) (tts.Provider, error)
ListTTSProviders() []string
HasTTSProvider(name string) bool
// STT registration
RegisterSTTProvider(name string, factory STTProviderFactory)
GetSTTProvider(name string, opts ...ProviderOption) (stt.Provider, error)
ListSTTProviders() []string
HasSTTProvider(name string) bool
// CallSystem registration
RegisterCallSystemProvider(name string, factory CallSystemProviderFactory)
GetCallSystemProvider(name string, opts ...ProviderOption) (callsystem.CallSystem, error)
ListCallSystemProviders() []string
HasCallSystemProvider(name string) bool
// Gateway registration
RegisterGatewayProvider(name string, factory GatewayProviderFactory)
GetGatewayProvider(name string, opts ...ProviderOption) (Gateway, error)
ListGatewayProviders() []string
HasGatewayProvider(name string) bool
// Realtime registration
RegisterRealtimeProvider(name string, factory RealtimeProviderFactory)
GetRealtimeProvider(name string, opts ...ProviderOption) (RealtimeProvider, error)
ListRealtimeProviders() []string
HasRealtimeProvider(name string) bool
}
Registry defines the interface for provider discovery.
type STTProviderFactory ¶
type STTProviderFactory func(config ProviderConfig) (stt.Provider, error)
STTProviderFactory creates an STT provider with the given configuration.
type TTSProviderFactory ¶
type TTSProviderFactory func(config ProviderConfig) (tts.Provider, error)
TTSProviderFactory creates a TTS provider with the given configuration.