Documentation
¶
Overview ¶
Package gemini implements agent.LLMProvider for Google Gemini — both the public Gemini API and Vertex AI — plus the Gemini-backed embedder and multimodal media analyzer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Embedder ¶
type Embedder struct {
// contains filtered or unexported fields
}
Embedder implements tools.Embedder using Google Gemini embeddings.
Default model is text-embedding-004 (768 dims, retrieval-tuned). The SDK batches automatically; large inputs should still be chunked by the caller if they approach the per-request token limit.
func NewEmbedder ¶
NewEmbedder constructs an embedder. apiKey falls back to GEMINI_API_KEY. model defaults to "text-embedding-004".
type MediaAnalyzer ¶
type MediaAnalyzer struct {
// contains filtered or unexported fields
}
MediaAnalyzer uses Gemini's multimodal API to analyze images and videos. It accepts data URIs ("data:<mime>;base64,<data>") and passes them as inline blobs, so it works for any MIME type Gemini supports — including video/mp4, video/webm, video/quicktime, image/*, etc.
func NewMediaAnalyzer ¶
func NewMediaAnalyzer(apiKey, model string) (*MediaAnalyzer, error)
NewMediaAnalyzer builds an analyzer. apiKey defaults to GEMINI_API_KEY; model defaults to "gemini-3.8-flash".
type Option ¶
type Option func(*Provider)
Option configures a Provider at construction.
func WithSeed ¶
WithSeed requests best-effort deterministic sampling. Gemini accepts a 32-bit seed; values outside int32 range are truncated. Determinism is not guaranteed across model versions — pair with a pinned temperature for the strongest reproducibility Gemini offers.
func WithTemperature ¶
WithTemperature pins the sampling temperature (0.0–2.0 for Gemini). Use 0 for maximally reproducible classification/extraction turns; unset keeps the provider default.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements agent.LLMProvider using Google Gemini native SDK.
func New ¶
New creates a wrapper over Google Gemini's API. Empty model defaults to "gemini-3.8-flash".
func NewVertex ¶
NewVertex returns a Provider wired to Vertex AI instead of the public Gemini API. Vertex uses Application Default Credentials (ADC) plus a GCP project/location rather than an API key — run `gcloud auth application-default login` or mount a service-account key via GOOGLE_APPLICATION_CREDENTIALS.
Empty projectID / location fall back to GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION respectively. Empty model defaults to "gemini-3.8-flash".
The returned *Provider reuses the same GenerateStream implementation as the public-API backend — only the transport differs.
func (*Provider) Capabilities ¶ added in v0.40.0
func (*Provider) Capabilities() agent.LLMCapabilities
Capabilities reports features implemented by the Gemini adapter.
func (*Provider) GenerateStream ¶
func (p *Provider) GenerateStream(ctx context.Context, memory []history.Message, availableTools *tools.Registry, streamChan chan<- agent.StreamEvent) (agent.LLMResult, error)
GenerateStream maps GopherAgent history to Gemini API format and triggers streaming generation.
type Transcriber ¶ added in v0.41.0
type Transcriber struct {
// contains filtered or unexported fields
}
Transcriber implements audio.Transcriber using Gemini's multimodal API.
Gemini has no dedicated transcription endpoint, so this drives the ordinary generation API with an inline audio blob and a constraining instruction. Two consequences follow, and both are visible in the returned Transcript: Segments is always nil because generation emits no timing, and the result is a model sample rather than a decoder output, so it can paraphrase under adversarial audio in a way a dedicated ASR model does not.
It is a good fit when Gemini is already the deployment's provider and timestamps are not needed. Prefer the OpenAI Transcriber when segment timings matter.
func NewTranscriber ¶ added in v0.41.0
func NewTranscriber(apiKey, model string) (*Transcriber, error)
NewTranscriber builds a transcriber. apiKey defaults to GEMINI_API_KEY; model defaults to "gemini-3.8-flash".
func (*Transcriber) Transcribe ¶ added in v0.41.0
func (t *Transcriber) Transcribe(ctx context.Context, clip audio.Clip, opts audio.Options) (audio.Transcript, error)
Transcribe converts one clip to text. The returned Transcript never carries Segments; see the type doc.