gemini

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package gemini implements the Embedder interface against Google's Gemini embeddings API via go-genai (google.golang.org/genai).

Two task-hint strategies are supported:

  • "param" — the model accepts a `task_type` API parameter (gemini-embedding-001 and similar). Strategy: set EmbedContentConfig.TaskType to the API enum string.

  • "prefix" — the model expects task hints in-band as a natural-language prompt prefix (gemini-embedding-2 and similar). Strategy: prepend the documented prefix to each input text and leave Config.TaskType unset.

Strategy is selected from the model name. Defaults assume gemini-embedding-2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Embedder

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

Embedder is a Gemini-backed embedder.

func New

func New(ctx context.Context, opts Options) (*Embedder, error)

New constructs a Gemini Embedder.

func (*Embedder) Dim

func (e *Embedder) Dim() int

func (*Embedder) Embed

func (e *Embedder) Embed(ctx context.Context, task embed.EmbedTask, texts []string) ([][]float32, error)

Embed satisfies embed.Embedder. The task hint is mapped to the strategy chosen at construction time: a TaskType API parameter for "param" models, or a prompt prefix on each input for "prefix" models. The fake embedder ignores task entirely; here we honor it.

Inputs larger than the API's per-batch cap are split transparently.

type Options

type Options struct {
	APIKey string
	Model  string
	Dim    int
}

Options configures the Gemini embedder.

Jump to

Keyboard shortcuts

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