gemini

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEmbeddingModel = "text-embedding-004"
	ModelContextVar       = "model"
	APIKeyEnvVar          = "GEMINI_API_KEY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	DefaultModel   string
	Client         *genai.Client
	DefaultContext *context.Context
	MaxBatchSize   int
	// contains filtered or unexported fields
}

func NewGeminiClient

func NewGeminiClient(opts ...Option) (*Client, error)

func (*Client) CreateEmbedding

func (c *Client) CreateEmbedding(ctx context.Context, req []string) ([]*types.Embedding, error)

type GeminiEmbeddingFunction

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

func NewGeminiEmbeddingFunction

func NewGeminiEmbeddingFunction(opts ...Option) (*GeminiEmbeddingFunction, error)

func (*GeminiEmbeddingFunction) EmbedDocuments

func (e *GeminiEmbeddingFunction) EmbedDocuments(ctx context.Context, documents []string) ([]*types.Embedding, error)

func (*GeminiEmbeddingFunction) EmbedQuery

func (e *GeminiEmbeddingFunction) EmbedQuery(ctx context.Context, document string) (*types.Embedding, error)

func (*GeminiEmbeddingFunction) EmbedRecords

func (e *GeminiEmbeddingFunction) EmbedRecords(ctx context.Context, records []*types.Record, force bool) error

type Option

type Option func(p *Client) error

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey sets the API key for the client

func WithClient

func WithClient(client *genai.Client) Option

WithClient sets the generative AI client for the client

func WithDefaultModel

func WithDefaultModel(model string) Option

WithDefaultModel sets the default model for the client

func WithEnvAPIKey

func WithEnvAPIKey() Option

WithEnvAPIKey sets the API key for the client from the environment variable GOOGLE_API_KEY

func WithMaxBatchSize

func WithMaxBatchSize(maxBatchSize int) Option

WithMaxBatchSize sets the max batch size for the client - this acts as a limit for the number of embeddings that can be sent in a single request

Jump to

Keyboard shortcuts

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