google

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enable

func Enable(apiKey, modelName, actionName string) sdk.ClientOption

Enable returns a ClientOption that wires the Google provider. usage: client.New(..., google.Enable("key", "gemini-pro", "my_action"))

func EnableWithConfig added in v0.11.0

func EnableWithConfig(cfg Config, actionName string) sdk.ClientOption

EnableWithConfig wires the provider from a full Config — Vertex project mode, Vertex Express Mode, and endpoint overrides included. Enable(...) stays as the minimal code-first entry point.

func Factory

func Factory(opts map[string]any) (sdk.ClientOption, error)

Factory implements the sdk.ProviderFactory interface for Config-driven loading.

func Init

func Init(ctx context.Context, globalG *genkit.Genkit, apiKey string, modelName string, logger core.Logger) (string, error)

Init sets up the Google provider using a Proxy Pattern. It isolates the Google plugin in a local instance and registers a proxy in the global registry. logger receives a warning whenever the proxied request's GenerationConfig is dropped (see the workaround below) so the loss of Temperature/MaxOutputTokens is observable rather than silent.

func InitWithConfig added in v0.5.0

func InitWithConfig(ctx context.Context, globalG *genkit.Genkit, cfg Config, logger core.Logger) (string, error)

InitWithConfig sets up the Google provider with full configuration including Vertex AI multi-region support.

Types

type Config added in v0.5.0

type Config struct {
	APIKey     string
	ModelName  string
	Project    string // Vertex AI project (enables Vertex mode)
	Location   string // Vertex AI region (e.g. "us-central1", "us", "eu", "global")
	APIVersion string // API version override ("v1", "v1beta"; "v1alpha" for GoogleAI)
	BaseURL    string // endpoint override — a proxy, a regional host, a mock

	// Platform selects the backend explicitly: "googleai" (default) or
	// "vertex". Set it to "vertex" WITHOUT a Project to use Vertex AI
	// Express Mode: API-key auth, no project, no location, no ADC.
	// Leaving it empty keeps the historical rule (Project set => Vertex).
	Platform string
}

Config holds configuration for the Google AI provider.

func ConfigFromOpts added in v0.11.0

func ConfigFromOpts(opts map[string]any) (Config, error)

ConfigFromOpts maps provider options (mangle.yaml / WithProviderConfig) onto a Config, applying the same env fallbacks the code-first path uses.

Recognized keys: api_key, model, platform, project, location, api_version, base_url. Before this, project/location/api_version were unreachable from YAML — only code-first callers could select Vertex.

type GoogleEmbedder

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

func NewEmbedder

func NewEmbedder(ctx context.Context, apiKey string, modelName string) (*GoogleEmbedder, error)

NewEmbedder creates a new embedder using Google GenAI. Default model: "embedding-001" or "text-embedding-004"

func (*GoogleEmbedder) Dimension

func (e *GoogleEmbedder) Dimension() int

func (*GoogleEmbedder) Embed

func (e *GoogleEmbedder) Embed(ctx context.Context, text string) ([]float32, error)

func (*GoogleEmbedder) EmbedBatch

func (e *GoogleEmbedder) EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)

Jump to

Keyboard shortcuts

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