Documentation
¶
Overview ¶
Package gemini adapts Google's Gemini API to Glue's provider interface using the google.golang.org/genai SDK.
It streams text and thinking deltas, converts Glue tools to Gemini function declarations, and maps function calls and results across the normalized loop types. The model comes from AgentOptions.Model, a per-call WithModel, or the provider default. The API key is taken from Options.APIKey or the GEMINI_API_KEY environment variable.
Index ¶
Constants ¶
const DefaultModel = "gemini-2.5-flash"
DefaultModel is the registry-level default model for this provider.
const EnvKey = "GEMINI_API_KEY"
EnvKey is the environment variable the provider reads when Options.APIKey is empty. Exposed so the providers registry and downstream agents can probe key availability without hard-coding the name.
Variables ¶
This section is empty.
Functions ¶
func ConvertMessages ¶
ConvertMessages converts Glue messages to Gemini contents.
Consecutive tool-role messages are grouped into a single Gemini content with role "user" and one FunctionResponse part per message, matching how the genai SDK expects multi-tool turns to be expressed.
Types ¶
type Options ¶
Options configures the Gemini provider.
APIKey is consulted first; when empty the GEMINI_API_KEY environment variable is used. DefaultModel applies when loop.ProviderRequest.Model is empty. Client, when non-nil, is used as-is and APIKey is ignored.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider streams Gemini responses into Glue's normalized provider events.
func New ¶
New creates a Gemini provider. The genai client is created lazily on the first Provider.Stream call so that constructing a provider does not require credentials.
func (*Provider) Stream ¶
func (p *Provider) Stream(ctx context.Context, req loop.ProviderRequest) (<-chan loop.ProviderEvent, error)
Stream implements loop.Provider. It supports text-only conversations and Gemini function calling: tool specs in loop.ProviderRequest.Tools are converted to function declarations, inbound function calls become loop.ProviderEventToolCall events, and tool-role messages in the transcript are converted to function responses.