Documentation
¶
Overview ¶
Package google is a streaming LLM service backed by Google's Gemini API (generateContent with SSE). It consumes an LLMContextFrame and emits the response as LLM response frames, like every other jargo LLM service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSTT ¶ added in v0.0.4
func NewSTT(cfg STTConfig) *stt.SegmentService
NewSTT builds a Google batch Speech-to-Text service. It is segmented: a turn detector upstream delimits each utterance, which is transcribed in one request. Streaming recognition needs gRPC and is not supported.
Types ¶
type Config ¶
type Config struct {
// APIKey is the Gemini API key. Required.
APIKey string `validate:"required"`
// Model is the model id; empty uses a low-latency flash default.
Model string
// MaxTokens caps the response length; 0 uses a small default suited to voice.
MaxTokens int
// Temperature is the sampling temperature (0.0 to 2.0); nil omits it.
Temperature *float64
// TopP is the nucleus-sampling parameter (0.0 to 1.0); nil omits it.
TopP *float64
// TopK is the top-k sampling parameter; nil omits it.
TopK *int
// Extra sets arbitrary additional generationConfig fields not modeled above,
// applied to every request.
Extra map[string]any
}
Config configures the Gemini LLM service. The sampling controls are pointers so a deliberate zero is distinguishable from "unset"; a nil value is omitted from the request, leaving the API default.
type STTConfig ¶ added in v0.0.4
type STTConfig struct {
// APIKey is the Google API key. Required.
APIKey string `validate:"required"`
// Language of the audio, mapped to a Google language code; the zero value
// uses US English.
Language language.Language
// SampleRate is the input audio sample rate; 0 uses the transport's rate.
SampleRate int
}
STTConfig configures the Google Cloud Speech-to-Text batch service. Only batch recognition is supported; streaming recognition requires gRPC and is out of scope.
type Service ¶
Service is a streaming Gemini LLM processor.
func (*Service) GenerateWithTools ¶
func (s *Service) GenerateWithTools(ctx context.Context, convo *frames.LLMContext, sink llm.Sink) error
GenerateWithTools streams a tool-capable completion. It emits text deltas to the sink as they arrive and reports each functionCall the model produces. The conversation's tools are sent on the request, and any tool turns already in the context are replayed as functionCall / functionResponse parts.
type TTSConfig ¶ added in v0.0.4
type TTSConfig struct {
// APIKey is the Google API key. Required.
APIKey string `validate:"required"`
// VoiceName is the voice id (e.g. "en-US-Chirp3-HD-Charon"); empty uses a
// default.
VoiceName string
// Language selects the spoken language, mapped to a Google language code;
// the zero value uses US English.
Language language.Language
// SampleRate is the PCM rate requested and emitted downstream; 0 uses 24 kHz.
SampleRate int
}
TTSConfig configures the Google Cloud Text-to-Speech service. It emits 16-bit mono PCM at the configured rate.