gemini

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 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 (*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.

Jump to

Keyboard shortcuts

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