vertexaiclient

package
v0.0.0-...-9375fdc Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 11 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() schema.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,omitempty"`
	TopP            float64        `json:"top_p,omitempty"`
	TopK            int            `json:"top_k,omitempty"`
	MaxOutputTokens int            `json:"max_output_tokens,omitempty"`
	CandidateCount  int            `json:"candidate_count,omitempty"`
	Model           string         `json:"-"`

	StreamingFunc func(context.Context, []byte) error
}

ChatRequest is a request to create an embedding.

type ChatResponse

type ChatResponse struct {
	Candidates []ChatMessage `json:"candidates"`
}

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,omitempty"`
	TopP        float64  `json:"top_p,omitempty"`
	TopK        int      `json:"top_k,omitempty"`
}

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(projectID 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) ([][]float64, error)

CreateEmbedding creates embeddings.

type StreamedChatResponse

type StreamedChatResponse = ChatResponse

Jump to

Keyboard shortcuts

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