google

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: BSD-2-Clause Imports: 16 Imported by: 0

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.

func NewTTS added in v0.0.4

func NewTTS(cfg TTSConfig) *tts.Base

NewTTS builds a Google Cloud Text-to-Speech service.

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.

func (Config) Validate

func (c Config) Validate() error

Validate reports whether the configuration is usable.

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.

func (STTConfig) Validate added in v0.0.4

func (c STTConfig) Validate() error

Validate reports whether the configuration is usable.

type Service

type Service struct {
	*llm.Base
	// contains filtered or unexported fields
}

Service is a streaming Gemini LLM processor.

func NewLLM

func NewLLM(cfg Config) *Service

NewLLM builds a Gemini LLM service.

func (*Service) Generate

func (s *Service) Generate(ctx context.Context, convo *frames.LLMContext, emit llm.Emit) error

Generate streams a Gemini completion, emitting each text delta.

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.

func (TTSConfig) Validate added in v0.0.4

func (c TTSConfig) Validate() error

Validate reports whether the configuration is usable.

Jump to

Keyboard shortcuts

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