palmclient

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TextModelName = "text-bison"
	ChatModelName = "chat-bison"
)

Variables

View Source
var (
	// ErrMissingValue is returned when a value is missing.
	ErrMissingValue = errors.New("missing value")
	// ErrInvalidValue is returned when a value is invalid.
	ErrInvalidValue = errors.New("invalid value")
)
View Source
var ErrEmptyResponse = errors.New("empty response")

ErrEmptyResponse is returned when the OpenAI API returns an empty response.

Functions

This section is empty.

Types

type ChatMessage

type ChatMessage struct {
	// The content of the message.
	Content string `json:"content"`
	// The name of the author of this message. user or bot
	Author string `json:"author,omitempty"`
}

ChatMessage is a message in a chat.

func (ChatMessage) GetContent

func (m ChatMessage) GetContent() string

GetText returns the text of the message.

func (ChatMessage) GetType

func (m ChatMessage) GetType() llms.ChatMessageType

GetType returns the type of the message.

type ChatRequest

type ChatRequest struct {
	Context        string         `json:"context"`
	Messages       []*ChatMessage `json:"messages"`
	Temperature    float64        `json:"temperature"`
	TopP           int            `json:"top_p,omitempty"`
	TopK           int            `json:"top_k,omitempty"`
	CandidateCount int            `json:"candidate_count,omitempty"`
}

ChatRequest is a request to create an embedding.

type ChatResponse

type ChatResponse struct {
	Candidates []ChatMessage
}

ChatResponse is a response to a chat request.

type Completion

type Completion struct {
	Text string `json:"text"`
}

Completion is a completion.

type CompletionRequest

type CompletionRequest struct {
	Prompts       []string `json:"prompts"`
	MaxTokens     int      `json:"max_tokens"`
	Temperature   float64  `json:"temperature"`
	TopP          int      `json:"top_p,omitempty"`
	TopK          int      `json:"top_k,omitempty"`
	StopSequences []string `json:"stop_sequences"`
}

CompletionRequest is a request to create a completion.

type EmbeddingRequest

type EmbeddingRequest struct {
	Input []string `json:"input"`
}

EmbeddingRequest is a request to create an embedding.

type PaLMClient

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

PaLMClient represents a Vertex AI based PaLM API client.

func New

func New(ctx context.Context, projectID, location string, opts ...option.ClientOption) (*PaLMClient, error)

New returns a new Vertex AI based PaLM API client.

func (*PaLMClient) CreateChat

func (c *PaLMClient) CreateChat(ctx context.Context, r *ChatRequest) (*ChatResponse, error)

CreateChat creates chat request.

func (*PaLMClient) CreateCompletion

func (c *PaLMClient) CreateCompletion(ctx context.Context, r *CompletionRequest) ([]*Completion, error)

CreateCompletion creates a completion.

func (*PaLMClient) CreateEmbedding

func (c *PaLMClient) CreateEmbedding(ctx context.Context, r *EmbeddingRequest) ([][]float32, error)

CreateEmbedding creates embeddings.

Jump to

Keyboard shortcuts

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