gemini

package
v0.0.0-...-285e13b Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package gemini implements access to Google's Gemini model.

Client implements llm.Embedder and llm.GenerateText. Use NewClient to connect.

Index

Constants

View Source
const (
	DefaultEmbeddingModel  = "text-embedding-004"
	DefaultGenerativeModel = "gemini-1.5-pro"
)

Variables

This section is empty.

Functions

func Scrub

func Scrub(req *http.Request) error

Scrub is a request scrubber for use with rsc.io/httprr.

Types

type Client

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

A Client represents a connection to Gemini.

func NewClient

func NewClient(ctx context.Context, lg *slog.Logger, sdb secret.DB, hc *http.Client, embeddingModel, generativeModel string) (*Client, error)

NewClient returns a connection to Gemini, using the given logger and HTTP client. It expects to find a secret of the form "AIza..." or "user:AIza..." in sdb under the name "ai.google.dev". The embeddingModel is the model name to use for embedding, such as text-embedding-004, and the generativeModel is the model name to use for generation, such as gemini-1.5-pro.

func (*Client) EmbedDocs

func (c *Client) EmbedDocs(ctx context.Context, docs []llm.EmbedDoc) ([]llm.Vector, error)

EmbedDocs returns the vector embeddings for the docs, implementing llm.Embedder.

func (*Client) GenerateText

func (c *Client) GenerateText(ctx context.Context, promptParts ...string) (string, error)

GenerateText returns model's text response for the prompt parts, implementing llm.TextGenerator.

func (*Client) Model

func (c *Client) Model() string

Model returns the name of the client's generative model.

Jump to

Keyboard shortcuts

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