vertex

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 13 Imported by: 3

Documentation

Overview

package vertex implements a langchaingo provider for Google Vertex AI LLMs, including the new Gemini models. See https://cloud.google.com/vertex-ai for more details.

Index

Constants

View Source
const (
	CITATIONS            = "citations"
	SAFETY               = "safety"
	RoleSystem           = "system"
	RoleModel            = "model"
	RoleUser             = "user"
	RoleTool             = "tool"
	ResponseMIMETypeJson = "application/json"
)

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")
)

Functions

This section is empty.

Types

type Vertex

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

Vertex is a type that represents a Vertex AI API client.

Right now, the Vertex Gemini SDK doesn't support embeddings; therefore, for embeddings we also hold a palmclient.

func New

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

New creates a new Vertex client.

func (*Vertex) Call

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

Call implements the llms.Model interface.

func (*Vertex) CreateEmbedding

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

CreateEmbedding creates embeddings from texts.

func (*Vertex) GenerateContent

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

GenerateContent implements the llms.Model interface.

Jump to

Keyboard shortcuts

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