Documentation
¶
Index ¶
- Variables
- type LLM
- func (g *LLM) Call(ctx context.Context, prompt string, options ...llms.CallOption) (string, error)
- func (g *LLM) EmbedDocuments(ctx context.Context, texts []string) ([][]float32, error)
- func (g *LLM) EmbedQueries(ctx context.Context, texts []string) ([][]float32, error)
- func (g *LLM) EmbedQuery(ctx context.Context, text string) ([]float32, error)
- func (g *LLM) GenerateContent(ctx context.Context, messages []schema.MessageContent, ...) (*schema.ContentResponse, error)
- func (g *LLM) GetDimension(ctx context.Context) (int, error)
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoAPIKey = errors.New("gemini: API key is required") ErrInvalidModel = errors.New("gemini: invalid model specified") ErrNoContent = errors.New("gemini: no content generated") ErrSystemMessage = errors.New("gemini: system message must be the first message in the conversation") ErrEmbeddings = errors.New("gemini: failed to generate embeddings") )
Functions ¶
This section is empty.
Types ¶
type LLM ¶
type LLM struct {
// contains filtered or unexported fields
}
LLM implements both the Model and Embedder interfaces for Gemini.
func (*LLM) EmbedDocuments ¶ added in v0.9.0
EmbedDocuments generates embeddings for a slice of texts.
func (*LLM) EmbedQueries ¶ added in v0.9.0
EmbedQueries generates embeddings for multiple queries.
func (*LLM) EmbedQuery ¶ added in v0.9.0
EmbedQuery generates an embedding for a single text query.
func (*LLM) GenerateContent ¶
func (g *LLM) GenerateContent( ctx context.Context, messages []schema.MessageContent, options ...llms.CallOption, ) (*schema.ContentResponse, error)
GenerateContent handles multi-turn conversations and streaming.
func (*LLM) GetDimension ¶ added in v0.9.0
GetDimension returns the embedding dimension of the model. It caches the result after the first successful call. If the first call fails, subsequent calls will retry until a successful result is obtained.
type Option ¶
type Option func(*options)
Option is a function type for configuring the client.
func WithEmbeddingModel ¶ added in v0.9.0
WithEmbeddingModel sets the embedding model name.
func WithLogger ¶
WithLogger sets a custom logger for the client.