palm

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

package palm implements a langchaingo provider for Google Vertex AI legacy PaLM models. Use the newer Gemini models via llms/googleai/vertex if possible.

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
	ErrMissingLocation          = errors.New("missing the GCP Location, set it in the GOOGLE_CLOUD_LOCATION environment variable")  //nolint:lll
	ErrUnexpectedResponseLength = errors.New("unexpected length of response")
	ErrNotImplemented           = errors.New("not implemented")
)

Functions

This section is empty.

Types

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 palmclient 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) ([][]float32, error)

CreateEmbedding creates embeddings for the given input texts.

func (*LLM) GenerateContent

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

GenerateContent implements the Model interface.

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 WithGRPCDialOption

func WithGRPCDialOption(opt grpc.DialOption) Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

func WithLocation

func WithLocation(location string) Option

WithLocation passes the Google Cloud location to the client.

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.

Jump to

Keyboard shortcuts

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