gemini

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GenerateContent

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

GenerateContent implements model.LLM using the Gemini GenerateContent API.

func New

func New(ctx context.Context, apiKey, modelName string, retryCfg ...retry.Config) (*GenerateContent, error)

New creates a new GenerateContent instance for the Gemini Developer API. apiKey is required. modelName is the identifier of the Gemini model to use (e.g. "gemini-2.0-flash", "gemini-2.5-pro"). retryCfg is optional; when provided it enables automatic retry with exponential backoff on transient errors (rate limits, 5xx, network issues).

func NewVertexAI

func NewVertexAI(ctx context.Context, project, location, modelName string, retryCfg ...retry.Config) (*GenerateContent, error)

NewVertexAI creates a new GenerateContent instance backed by Google Cloud Vertex AI. project is the GCP project ID, location is the region (e.g. "us-central1"), and modelName is the Gemini model identifier (e.g. "gemini-2.0-flash"). Authentication uses Application Default Credentials (ADC) by default; set up credentials via `gcloud auth application-default login` or a service account key file pointed to by the GOOGLE_APPLICATION_CREDENTIALS environment variable. retryCfg is optional; when provided it enables automatic retry with exponential backoff on transient errors (rate limits, 5xx, network issues).

func NewVertexAIWithOptions added in v0.0.7

func NewVertexAIWithOptions(ctx context.Context, project, location, modelName string, opts ...Option) (*GenerateContent, error)

NewVertexAIWithOptions creates a new GenerateContent instance backed by Google Cloud Vertex AI with explicit adapter options.

func NewWithOptions added in v0.0.7

func NewWithOptions(ctx context.Context, apiKey, modelName string, opts ...Option) (*GenerateContent, error)

NewWithOptions creates a new GenerateContent instance for the Gemini Developer API with explicit adapter options.

func (*GenerateContent) GenerateContent

func (g *GenerateContent) GenerateContent(ctx context.Context, req *model.LLMRequest, cfg *model.GenerateConfig, stream bool) iter.Seq2[*model.LLMResponse, error]

GenerateContent sends the request to the Gemini GenerateContent API. When stream is false, exactly one complete *model.LLMResponse is yielded. When stream is true, partial text/reasoning chunks are yielded (Partial=true) followed by the assembled complete response (Partial=false, TurnComplete=true). Transient errors are automatically retried according to the retry.Config provided at construction time.

func (*GenerateContent) Name

func (g *GenerateContent) Name() string

Name returns the model identifier.

type Option added in v0.0.7

type Option func(*GenerateContent)

Option configures a Gemini GenerateContent adapter.

func WithBaseURL added in v0.0.8

func WithBaseURL(baseURL string) Option

WithBaseURL overrides the Gemini or Vertex AI API endpoint for this adapter.

func WithRetryConfig added in v0.0.7

func WithRetryConfig(cfg retry.Config) Option

WithRetryConfig sets the retry behavior for transient API errors.

func WithThinkingEnabled added in v0.0.7

func WithThinkingEnabled(enabled bool) Option

WithThinkingEnabled explicitly enables or disables Gemini thinking.

func WithThinkingLevel added in v0.0.7

func WithThinkingLevel(level ThinkingLevel) Option

WithThinkingLevel sets Gemini thinking depth for every call.

type ThinkingLevel added in v0.0.7

type ThinkingLevel string

ThinkingLevel controls Gemini thinking depth.

const (
	// ThinkingLevelMinimal requests minimal Gemini thinking depth.
	ThinkingLevelMinimal ThinkingLevel = "minimal"
	// ThinkingLevelLow requests low Gemini thinking depth.
	ThinkingLevelLow ThinkingLevel = "low"
	// ThinkingLevelMedium requests medium Gemini thinking depth.
	ThinkingLevelMedium ThinkingLevel = "medium"
	// ThinkingLevelHigh requests high Gemini thinking depth.
	ThinkingLevelHigh ThinkingLevel = "high"
)

Jump to

Keyboard shortcuts

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