Documentation
¶
Overview ¶
Package gemini implements the Gemini LLM provider using the Google genai SDK.
Index ¶
- Constants
- type Config
- type InternalTools
- type Provider
- func (p *Provider) AvailableModels() []llmproxy.ModelInfo
- func (p *Provider) Chat(ctx context.Context, req *llmproxy.ChatRequest) (*llmproxy.ChatResponse, error)
- func (p *Provider) DeleteFile(ctx context.Context, fileID llmproxy.FileID) (bool, error)
- func (p *Provider) Embed(ctx context.Context, req *llmproxy.EmbeddingRequest) (*llmproxy.EmbeddingResponse, error)
- func (p *Provider) EmbeddingDimension(model llmproxy.ModelID) (int, error)
- func (p *Provider) Health(ctx context.Context) error
- func (p *Provider) ProviderID() llmproxy.ProviderID
- func (p *Provider) UploadFile(ctx context.Context, req *llmproxy.FileUploadRequest) (*llmproxy.FileUploadResponse, error)
- type VertexAIConfig
- type WebSearchConfig
Constants ¶
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 ¶
NewAPIProvider creates a new Gemini Provider using the Gemini API backend.
func NewVertexAIProvider ¶
NewVertexAIProvider creates a new Gemini Provider using the Vertex AI backend. The Vertex coordinates are read from cfg.VertexAI.
func (*Provider) AvailableModels ¶
AvailableModels returns the static list of Anthropic models exposed by this provider.
func (*Provider) Chat ¶
func (p *Provider) Chat(ctx context.Context, req *llmproxy.ChatRequest) (*llmproxy.ChatResponse, error)
Chat sends a prompt to Gemini and returns the response.
func (*Provider) DeleteFile ¶
DeleteFile removes a previously uploaded file from Gemini. Not supported in Vertex AI mode.
func (*Provider) Embed ¶
func (p *Provider) Embed(ctx context.Context, req *llmproxy.EmbeddingRequest) (*llmproxy.EmbeddingResponse, error)
Embed generates embeddings for the given inputs using a Gemini embedding model.
func (*Provider) EmbeddingDimension ¶
EmbeddingDimension returns the output dimension for the given embedding model.
func (*Provider) ProviderID ¶
func (p *Provider) ProviderID() llmproxy.ProviderID
ProviderID returns the unique identifier of the LLM provider.
func (*Provider) UploadFile ¶
func (p *Provider) UploadFile(ctx context.Context, req *llmproxy.FileUploadRequest) (*llmproxy.FileUploadResponse, error)
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.