vertexai

package
v0.0.0-...-241fa78 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	API_ENDPOINT        = "us-central1-aiplatform.googleapis.com"
	BISON_CODE_MODEL_ID = "code-bison@001"
	BISON_TEXT_MODEL_ID = "text-bison@001"
)

Variables

View Source
var (
	DEFAULT_PARAMETER = Parameters{
		MaxOutputTokens: 256,
		Temperature:     0.2,
		TopP:            .8,
		TopK:            40,
	}
)

Functions

This section is empty.

Types

type ChatRequest

type ChatRequest struct {
	Debug      bool
	Prompt     string
	ModelID    string
	Instances  []Instance
	Parameters *Parameters
}

type Client

type Client struct {
	Response Response
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config ClientConfig) (*Client, error)

func (*Client) ChatResponse

func (c *Client) ChatResponse(req ChatRequest) (string, error)

func (*Client) FormatVertexAPIURL

func (c *Client) FormatVertexAPIURL(modelID string) string

type ClientConfig

type ClientConfig struct {
	ProjectID string
	ModelID   string
	Debug     bool
}

type Instance

type Instance struct {
	Content string `json:"content,omitempty"`
	Prefix  string `json:"prefix,omitempty"`
	Text    string `json:"text,omitempty"`
}

type Parameters

type Parameters struct {
	Temperature     float64 `json:"temperature,omitempty"`
	MaxOutputTokens int     `json:"maxOutputTokens,omitempty"`
	TopP            float64 `json:"topP,omitempty"`
	TopK            int     `json:"topK,omitempty"`
}

type Request

type Request struct {
	Instances  []Instance `json:"instances"`
	Parameters Parameters `json:"parameters"`
}

type Response

type Response struct {
	Error struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
		Status  string `json:"status"`

		Details []struct {
			Type     string `json:"@type"`
			Reason   string `json:"reason"`
			Domain   string `json:"domain"`
			Metadata struct {
				Permission string `json:"permission"`
				Resource   string `json:"resource"`
			} `json:"metadata"`
		} `json:"details"`
	} `json:"error,omitempty"`

	Predictions []struct {
		Content          string `json:"content"`
		SafetyAttributes struct {
			Blocked    bool      `json:"blocked"`
			Categories []string  `json:"categories"`
			Scores     []float64 `json:"scores"`
		} `json:"safetyAttributes"`
		CitationMetadata struct {
			Citations []interface{} `json:"citations"`
		} `json:"citationMetadata"`
	} `json:"predictions"`
}

Jump to

Keyboard shortcuts

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