vertexai

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyResponse            = errors.New("no response")
	ErrMissingProjectID         = errors.New("missing the GCP Project ID, set it in the GOOGLE_CLOUD_PROJECT environment variable") //nolint:lll
	ErrUnexpectedResponseLength = errors.New("unexpected length of response")
	ErrNotImplemented           = errors.New("not implemented")
)

Functions

This section is empty.

Types

type Chat

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

func NewChat

func NewChat(opts ...Option) (*Chat, error)

NewChat returns a new VertexAI PaLM Chat LLM.

func (*Chat) Call

func (o *Chat) Call(ctx context.Context, messages []schema.ChatMessage, options ...llms.CallOption) (*schema.AIChatMessage, error)

Chat requests a chat response for the given messages.

func (*Chat) CreateEmbedding

func (o *Chat) CreateEmbedding(ctx context.Context, inputTexts []string) ([][]float64, error)

CreateEmbedding creates embeddings for the given input texts.

func (*Chat) Generate

func (o *Chat) Generate(ctx context.Context, messageSets [][]schema.ChatMessage, options ...llms.CallOption) ([]*llms.Generation, error)

Generate requests a chat response for each of the sets of messages.

func (*Chat) GeneratePrompt

func (o *Chat) GeneratePrompt(ctx context.Context, promptValues []schema.PromptValue, options ...llms.CallOption) (llms.LLMResult, error)

func (*Chat) GetNumTokens

func (o *Chat) GetNumTokens(text string) int

type ChatMessage

type ChatMessage = vertexaiclient.ChatMessage

type LLM

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

func New

func New(opts ...Option) (*LLM, error)

New returns a new VertexAI PaLM LLM.

func (*LLM) Call

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

Call requests a completion for the given prompt.

func (*LLM) CreateEmbedding

func (o *LLM) CreateEmbedding(ctx context.Context, inputTexts []string) ([][]float64, error)

CreateEmbedding creates embeddings for the given input texts.

func (*LLM) Generate

func (o *LLM) Generate(ctx context.Context, prompts []string, options ...llms.CallOption) ([]*llms.Generation, error)

func (*LLM) GeneratePrompt

func (o *LLM) GeneratePrompt(ctx context.Context, promptValues []schema.PromptValue, options ...llms.CallOption) (llms.LLMResult, error)

func (*LLM) GetNumTokens

func (o *LLM) GetNumTokens(text string) int

type Option

type Option func(*options)

Option is a function that can be passed to NewClient to configure options.

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey returns a ClientOption that specifies an API key to be used as the basis for authentication.

func WithCredentialsFile

func WithCredentialsFile(path string) Option

WithCredentialsFile returns a ClientOption that authenticates API calls with the given service account or refresh token JSON credentials file.

func WithCredentialsJSON

func WithCredentialsJSON(json []byte) Option

WithCredentialsJSON returns a ClientOption that authenticates API calls with the given service account or refresh token JSON credentials.

func WithProjectID

func WithProjectID(projectID string) Option

WithProjectID passes the Google Cloud project ID to the client. If not set, the project is read from the GOOGLE_CLOUD_PROJECT environment variable.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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