Documentation
¶
Overview ¶
Package google provides Google Gemini LLM, Vertex AI LLM, and Google Cloud STT/TTS services.
Index ¶
Constants ¶
const DefaultGoogleSTTModel = "latest_long"
DefaultGoogleSTTModel is the default Speech-to-Text v2 model (latest_long for long-form).
const DefaultGoogleTTSLanguage = "en-US"
DefaultGoogleTTSVoice is the default voice (language-specific default when name is empty).
const DefaultLLMModel = "gemini-2.5-flash"
DefaultLLMModel is the default Gemini model when none is specified.
const DefaultVertexLLMModel = "gemini-2.5-flash"
DefaultVertexLLMModel is the default model for Vertex AI when none is specified.
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
NewClient creates a Gemini API client with the given API key. If apiKey is empty, config.GetEnv("GOOGLE_API_KEY", "") is used.
func NewVertexClient ¶
NewVertexClient creates a Vertex AI client using Application Default Credentials. project and location must be set (e.g. "my-project", "us-central1"). If project or location is empty, config env GOOGLE_CLOUD_PROJECT / GOOGLE_CLOUD_LOCATION are used.
Types ¶
type LLMService ¶
type LLMService struct {
// contains filtered or unexported fields
}
LLMService implements services.LLMService using the Google Gemini API (native genai SDK).
func NewLLMService ¶
func NewLLMService(ctx context.Context, apiKey, model string) (*LLMService, error)
NewLLMService creates a Google Gemini LLM service. If apiKey is empty, config env GOOGLE_API_KEY or GEMINI_API_KEY is used. If model is empty, DefaultLLMModel is used.
func (*LLMService) Chat ¶
func (s *LLMService) Chat(ctx context.Context, messages []map[string]any, onToken func(*frames.LLMTextFrame)) error
Chat runs a completion and calls onToken for each streamed content delta (as LLMTextFrame).
type STTService ¶
type STTService struct {
// contains filtered or unexported fields
}
STTService implements services.STTService using Google Cloud Speech-to-Text V2 (non-streaming Recognize). Auth: GOOGLE_APPLICATION_CREDENTIALS or Application Default Credentials.
func NewSTT ¶
func NewSTT(ctx context.Context, project, location, model, languageCode string) (*STTService, error)
NewSTT creates a Google Cloud Speech-to-Text V2 STT service. project and location can be empty to use GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION. model can be empty for DefaultGoogleSTTModel; languageCode is e.g. "en-US" or "" for auto-detect.
func (*STTService) Close ¶
func (s *STTService) Close() error
Close releases the Speech client. Call when the service is no longer needed.
func (*STTService) Transcribe ¶
func (s *STTService) Transcribe(ctx context.Context, audio []byte, sampleRate, numChannels int) ([]*frames.TranscriptionFrame, error)
Transcribe sends audio to Speech-to-Text V2 Recognize and returns transcription frames. Audio must be raw 16-bit PCM (no WAV header); sampleRate and numChannels are used in the request.
type TTSService ¶
type TTSService struct {
// contains filtered or unexported fields
}
TTSService implements services.TTSService using Google Cloud Text-to-Speech (v1). Auth: GOOGLE_APPLICATION_CREDENTIALS or Application Default Credentials.
func NewTTS ¶
func NewTTS(ctx context.Context, languageCode, voiceName string) (*TTSService, error)
NewTTS creates a Google Cloud Text-to-Speech service. languageCode is BCP-47 (e.g. "en-US"); voiceName is optional (e.g. "en-US-Standard-A" or "" for default).
func (*TTSService) Speak ¶
func (s *TTSService) Speak(ctx context.Context, text string, sampleRate int) ([]*frames.TTSAudioRawFrame, error)
Speak synthesizes text to speech and returns TTSAudioRawFrame(s). Uses LINEAR16 (WAV) from the API and decodes to raw PCM to match pipeline expectations.
type VertexLLMService ¶
type VertexLLMService struct {
// contains filtered or unexported fields
}
VertexLLMService implements services.LLMService using Google Vertex AI (genai SDK with BackendVertexAI). It uses Application Default Credentials; no API key is required.
func NewVertexLLMService ¶
func NewVertexLLMService(ctx context.Context, project, location, model string) (*VertexLLMService, error)
NewVertexLLMService creates a Vertex AI LLM service. project and location can be empty to use GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION env vars. If model is empty, DefaultVertexLLMModel is used.
func (*VertexLLMService) Chat ¶
func (s *VertexLLMService) Chat(ctx context.Context, messages []map[string]any, onToken func(*frames.LLMTextFrame)) error
Chat runs a completion and calls onToken for each streamed content delta (as LLMTextFrame).