api

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ImageURL  = "ImageURL"
	ImageData = "ImageData"
)

Variables

View Source
var (
	DefaultModel     = strings.Clone(openai.GPT3Dot5Turbo)
	DefaultImageSize = strings.Clone(openai.CreateImageSize256x256)

	ErrMissingAPIKey        = fmt.Errorf("%s env variable is not set", envKeyOpenAIApi)
	ErrModelCurieSize       = fmt.Errorf("model %s must not have more than 1024 in total", openai.GPT3TextCurie001)
	ErrChatNotSupported     = errors.New("chat is not supported for this model")
	ErrModifierNotSupported = errors.New("modifier is not supported for this model")
)
View Source
var SupportedModels = []string{
	openai.GPT4,
	openai.GPT40314,
	openai.GPT432K,
	openai.GPT432K0314,
	openai.GPT3Dot5Turbo0301,
	openai.GPT3Dot5Turbo,
	openai.GPT3TextDavinci003,
	openai.GPT3TextDavinci002,
	openai.GPT3TextCurie001,
	openai.GPT3TextBabbage001,
	openai.GPT3TextAda001,
	openai.GPT3TextDavinci001,
	openai.GPT3DavinciInstructBeta,
	openai.GPT3Davinci,
	openai.GPT3CurieInstructBeta,
	openai.GPT3Curie,
	openai.GPT3Ada,
	openai.GPT3Babbage,
}

Functions

func IsChatModel

func IsChatModel(model string) bool

Types

type Client

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

func CreateClient

func CreateClient() (*Client, error)

func (*Client) GetChatCompletion

func (c *Client) GetChatCompletion(ctx context.Context, options CompletionOptions, prompt string) (string, error)

func (*Client) GetCompletion

func (c *Client) GetCompletion(ctx context.Context, options CompletionOptions, prompt string) (string, error)

func (*Client) GetImage

func (c *Client) GetImage(ctx context.Context, options ImageOptions, prompt string) ([]string, error)

GetImage creates an image via the DALLE API. It either returns a URL to the image or the image data based on the provided ResponseFormat in the options.

type CompletionOptions

type CompletionOptions struct {
	Model       string
	MaxTokens   int
	Temperature float32
	TopP        float32
	Modifier    string
	ChatSession string
}

type ImageOptions

type ImageOptions struct {
	Count          int
	Size           string
	ResponseFormat string
}

Jump to

Keyboard shortcuts

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