googleai

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 12 Imported by: 1

README

This directory contains langchaingo provider for Google's models.

Both the googleai and vertex providers give access to Gemini-family multi-modal LLMs. The code between these providers is very similar; therefore, most of the vertex package is code-generated from the googleai package using a tool:

go run ./llms/googleai/internal/cmd/generate-vertex.go < llms/googleai/googleai.go > llms/googleai/vertex/vertex.go

Testing:

The test code between googleai and vertex is also shared, and lives in the shared_test directory. The same tests are run for both providers.

Documentation

Overview

package googleai implements a langchaingo provider for Google AI LLMs. See https://ai.google.dev/ for more details.

Index

Constants

View Source
const (
	CITATIONS = "citations"
	SAFETY    = "safety"
	RoleModel = "model"
	RoleUser  = "user"
)

Variables

View Source
var (
	ErrNoContentInResponse    = errors.New("no content in generation response")
	ErrUnknownPartInResponse  = errors.New("unknown part type in generation response")
	ErrInvalidMimeType        = errors.New("invalid mime type on content")
	ErrSystemRoleNotSupported = errors.New("system role isn't supporeted yet")
)

Functions

This section is empty.

Types

type GoogleAI

type GoogleAI struct {
	CallbacksHandler callbacks.Handler
	// contains filtered or unexported fields
}

GoogleAI is a type that represents a Google AI API client.

func New

func New(ctx context.Context, opts ...Option) (*GoogleAI, error)

New creates a new GoogleAI client.

func (*GoogleAI) Call

func (g *GoogleAI) Call(ctx context.Context, prompt string, options ...llms.CallOption) (string, error)

Call implements the llms.Model interface.

func (*GoogleAI) CreateEmbedding

func (g *GoogleAI) CreateEmbedding(ctx context.Context, texts []string) ([][]float32, error)

CreateEmbedding creates embeddings from texts.

func (*GoogleAI) GenerateContent

func (g *GoogleAI) GenerateContent(ctx context.Context, messages []llms.MessageContent, options ...llms.CallOption) (*llms.ContentResponse, error)

GenerateContent implements the llms.Model interface.

type Option

type Option func(*options)

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey passes the API KEY (token) to the client.

func WithDefaultEmbeddingModel

func WithDefaultEmbeddingModel(defaultEmbeddingModel string) Option

WithDefaultModel passes a default embedding model name to the client. This model name is used if not explicitly provided in specific client invocations.

func WithDefaultModel

func WithDefaultModel(defaultModel string) Option

WithDefaultModel passes a default content model name to the client. This model name is used if not explicitly provided in specific client invocations.

Directories

Path Synopsis
internal
cmd
Code generator for vertex.go from googleai.go nolint
Code generator for vertex.go from googleai.go nolint
package palm implements a langchaingo provider for Google Vertex AI legacy PaLM models.
package palm implements a langchaingo provider for Google Vertex AI legacy PaLM models.
package vertex implements a langchaingo provider for Google Vertex AI LLMs, including the new Gemini models.
package vertex implements a langchaingo provider for Google Vertex AI LLMs, including the new Gemini models.

Jump to

Keyboard shortcuts

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