vertex

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 12 Imported by: 5

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

type Option func(*options)

func WithCloudLocation

func WithCloudLocation(l string) Option

WithCloudLocation passes the GCP cloud location (region) name to the client.

func WithCloudProject

func WithCloudProject(p string) Option

WithCloudProject passes the GCP cloud project name 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.

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 ...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