google

package
v0.0.0-...-fa30edc Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate() (clientID string, token string, err error)

More serious authentication methods left as an exercise to the reader https://cloud.google.com/docs/authentication

func Completion

func Completion(ctx context.Context, prompt Prompt) (io.Reader, error)

func CreateVertexTextCompletionRequest

func CreateVertexTextCompletionRequest(token string, projectID string, messages []ChatMessage) (*http.Request, error)

func ParseVertexTextCompletionResponse

func ParseVertexTextCompletionResponse(resp http.Response) (io.Reader, error)

Types

type ChatMessage

type ChatMessage struct {
	Role  Role        `json:"role"`
	Parts MessagePart `json:"parts"`
}

func MessagesFromPrompt

func MessagesFromPrompt(prompt Prompt) []ChatMessage

type GenerationConfig

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

type MessagePart

type MessagePart struct {
	Text string `json:"text,omitempty"`
}

type Prompt

type Prompt interface {
	GetPurpose() string
	GetHistory() ([]string, []string)
	GetQuestion() string
	GetReferences() [][]byte
}

type Role

type Role string
var (
	User Role = "USER"
	Bot  Role = "ASSISTANT"
)

type TextCompletionRequest

type TextCompletionRequest struct {
	Contents         []ChatMessage    `json:"contents"`
	GenerationConfig GenerationConfig `json:"generation_config"`
}

type VisualCompletionRequest

type VisualCompletionRequest struct {
	Contents         []VisualRequestContents `json:"contents"`
	GenerationConfig GenerationConfig        `json:"generation_config"`
}

type VisualInlineData

type VisualInlineData struct {
	MimeType string `json:"mimeType"`
	Data     string `json:"data"`
}

type VisualRequestContents

type VisualRequestContents struct {
	Role  Role  `json:"role"`
	Parts []any `json:"parts"`
}

Jump to

Keyboard shortcuts

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