gemini

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package gemini implements the Gemini LLM provider using the Google genai SDK.

Index

Constants

View Source
const ProviderID llmproxy.ProviderID = "Gemini"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	APIKey string `env:"GEMINI_API_KEY"`

	// VertexAI holds GCP project + location for Vertex AI backend. If both fields
	// are set, the registry constructs a Vertex AI client and ignores APIKey.
	VertexAI VertexAIConfig

	// InternalTools governs whether and how native provider-side tools fire when
	// the corresponding marker tool is included in a ChatRequest.
	InternalTools InternalTools
}

Config holds Gemini-specific provider configuration. Either APIKey (for the public Gemini API) or VertexAI fields must be populated; if both are set, Vertex AI takes precedence in the registry wiring.

type InternalTools

type InternalTools struct {
	// WebSearch enables Gemini's native Google Search grounding when non-nil and
	// a llmproxy.WebSearch marker is present in the request. nil means "native
	// search disabled even if the marker is passed."
	WebSearch *WebSearchConfig
}

InternalTools groups Gemini-side native tool configurations.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements the provider and Embedder interfaces for Google Gemini.

func NewAPIProvider

func NewAPIProvider(cfg Config) (*Provider, error)

NewAPIProvider creates a new Gemini Provider using the Gemini API backend.

func NewVertexAIProvider

func NewVertexAIProvider(cfg Config) (*Provider, error)

NewVertexAIProvider creates a new Gemini Provider using the Vertex AI backend. The Vertex coordinates are read from cfg.VertexAI.

func (*Provider) AvailableModels

func (p *Provider) AvailableModels() []llmproxy.ModelInfo

AvailableModels returns the static list of Anthropic models exposed by this provider.

func (*Provider) Chat

Chat sends a prompt to Gemini and returns the response.

func (*Provider) DeleteFile

func (p *Provider) DeleteFile(ctx context.Context, fileID llmproxy.FileID) (bool, error)

DeleteFile removes a previously uploaded file from Gemini. Not supported in Vertex AI mode.

func (*Provider) Embed

Embed generates embeddings for the given inputs using a Gemini embedding model.

func (*Provider) EmbeddingDimension

func (p *Provider) EmbeddingDimension(model llmproxy.ModelID) (int, error)

EmbeddingDimension returns the output dimension for the given embedding model.

func (*Provider) Health

func (p *Provider) Health(ctx context.Context) error

Health pings Gemini to ensure connectivity.

func (*Provider) ProviderID

func (p *Provider) ProviderID() llmproxy.ProviderID

ProviderID returns the unique identifier of the LLM provider.

func (*Provider) UploadFile

UploadFile uploads a file to Gemini. Not supported in Vertex AI mode.

type VertexAIConfig

type VertexAIConfig struct {
	Project  string `env:"GCP_PROJECT"`
	Location string `env:"GCP_LOCATION"`
}

VertexAIConfig holds GCP coordinates for the Vertex AI Gemini backend.

type WebSearchConfig

type WebSearchConfig struct {
	// ExcludeDomains excludes results from these domains (Vertex AI only).
	ExcludeDomains []string
}

WebSearchConfig configures Gemini's native Google Search grounding. Most fields are Vertex AI-only; the Gemini API backend silently ignores them.

Jump to

Keyboard shortcuts

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