googai

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const ApiBaseUrl = "https://generativelanguage.googleapis.com"
View Source
const ApiVersion = "v1beta"
View Source
const ChatMessageRoleAssistant = "model"
View Source
const ChatMessageRoleSystem = "user"
View Source
const ChatMessageRoleUser = "user"

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	Content       Content        `json:"content"`
	FinishReason  string         `json:"finishReason"`
	Index         int            `json:"index"`
	SafetyRatings []SafetyRating `json:"safetyRatings"`
}

type Client

type Client struct {
	ApiBaseUrl     string
	ApiVersion     string
	ApiKey         string
	Model          string
	SafetySettings []SafetySetting
}

func NewClient

func NewClient(key string) *Client

func (*Client) CreateChatCompletion

func (c *Client) CreateChatCompletion(contents []Content) (*ResponseBody, error)

func (*Client) CreateImageCompletion

func (c *Client) CreateImageCompletion(contents []Content) (*ResponseBody, error)

type Content

type Content struct {
	Parts []Part `json:"parts"`
	Role  string `json:"role,omitempty"`
}

type Error

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

type InlineData

type InlineData struct {
	MimeType string `json:"mime_type"`
	Data     string `json:"data"`
}

type Part

type Part struct {
	Text       string     `json:"text,omitempty"`
	InlineData InlineData `json:"inline_data,omitempty"`
}

type RequestBody

type RequestBody struct {
	Contents       []Content       `json:"contents"`
	SafetySettings []SafetySetting `json:"safetySettings"`
}

type ResponseBody

type ResponseBody struct {
	Candidates     []Candidate `json:"candidates"`
	Error          Error       `json:"error"`
	PromptFeedback struct {
		BlockReason   string         `json:"blockReason"`
		SafetyRatings []SafetyRating `json:"safetyRatings"`
	} `json:"promptFeedback"`
}

type SafetyRating

type SafetyRating struct {
	Category    string `json:"category"`
	Probability string `json:"probability"`
}

type SafetySetting

type SafetySetting struct {
	Category  string `json:"category"`
	Threshold string `json:"threshold"`
}

Jump to

Keyboard shortcuts

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