api

package
v0.0.0-...-2b9f6fe Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModelTextAda001     = "text-ada-001"
	ModelTextDavinci003 = "text-davinci-003"
)
View Source
const (
	UrlCompletions = "https://api.openai.com/v1/completions"
	UrlFiles       = "https://api.openai.com/v1/files"
	UrlFineTunes   = "https://api.openai.com/v1/fine-tunes"
	UrlImagesGen   = "https://api.openai.com/v1/images/generations"
	UrlModels      = "https://api.openai.com/v1/models"
)
View Source
const (
	ImageSize1024 = "1024x1024"
)

Variables

This section is empty.

Functions

func FileDelete

func FileDelete(apiKey, fileId string) error

func FileRetrieve

func FileRetrieve(apiKey, fileId string) ([]byte, error)

Types

type Completion

type Completion struct {
	Model   string `json:"model"`
	Choices []struct {
		Text         string      `json:"text"`
		Index        int         `json:"index"`
		Logprobs     interface{} `json:"logprobs"`
		FinishReason string      `json:"finish_reason"`
	} `json:"choices"`
	Usage struct {
		PromptTokens     int `json:"prompt_tokens"`
		CompletionTokens int `json:"completion_tokens"`
		TotalTokens      int `json:"total_tokens"`
	} `json:"usage"`
	Error *Error `json:"error"`
	// contains filtered or unexported fields
}

func GetCompletion

func GetCompletion(apiKey string, prompt string) (*Completion, error)

type CompletionRequest

type CompletionRequest struct {
	Model       string  `json:"model"`
	Prompt      string  `json:"prompt"`
	Temperature float64 `json:"temperature"`
	MaxTokens   int     `json:"max_tokens"`
}

func GetDefaultCompletionRequest

func GetDefaultCompletionRequest(prompt string) CompletionRequest

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Param   string `json:"param"`
	Type    string `json:"type"`
}

type Event

type Event struct {
	Level   string `json:"level"`
	Message string `json:"message"`
	// contains filtered or unexported fields
}

func FineTuneEvents

func FineTuneEvents(apiKey, fineTuneId string) ([]Event, error)

func (Event) Info

func (e Event) Info() string

type File

type File struct {
	Bytes    int64  `json:"bytes"`
	Filename string `json:"filename"`
	Purpose  string `json:"purpose"`
	// contains filtered or unexported fields
}

func FileList

func FileList(apiKey string) ([]File, error)

func FileUpload

func FileUpload(apiKey, filename string) (*File, error)

func (File) Info

func (f File) Info() string

type FineTune

type FineTune struct {
	Model           string      `json:"model"`
	FineTunedModel  string      `json:"fine_tuned_model"`
	HyperParams     interface{} `json:"hyperparams"`
	OrganizationId  string      `json:"organization_id"`
	ResultFiles     []File      `json:"result_files"`
	Status          string      `json:"status"`
	ValidationFiles []File      `json:"validation_files"`
	TrainingFiles   []File      `json:"training_files"`
	UpdatedAt       int64       `json:"updated_at"`
	Events          []Event     `json:"events"`
	// contains filtered or unexported fields
}

func FineTuneCancel

func FineTuneCancel(apiKey, fineTuneId string) (*FineTune, error)

func FineTuneCreate

func FineTuneCreate(apiKey, fileId string) (*FineTune, error)

func FineTuneList

func FineTuneList(apiKey string) ([]FineTune, error)

func (FineTune) Info

func (f FineTune) Info() string

type FineTuneCreateRequest

type FineTuneCreateRequest struct {
	TrainingFile string `json:"training_file"`
}

type HttpRequest

type HttpRequest struct {
	Url         string
	Data        []byte
	ApiKey      string
	ContentType string
}

func (HttpRequest) Delete

func (r HttpRequest) Delete() ([]byte, error)

func (HttpRequest) Get

func (r HttpRequest) Get() ([]byte, error)

func (HttpRequest) Post

func (r HttpRequest) Post() ([]byte, error)

type Image

type Image struct {
	Url string `json:"url"`
}

func ImageCreate

func ImageCreate(apiKey, prompt string) (*Image, error)

type ImageRequest

type ImageRequest struct {
	Prompt string `json:"prompt"`
	N      int    `json:"n"`
	Size   string `json:"size"`
}

func GetDefaultImageRequest

func GetDefaultImageRequest(prompt string) ImageRequest

type Model

type Model struct {
	OwnedBy    string       `json:"owned_by"`
	Permission []Permission `json:"permission"`
	Root       string       `json:"root"`
	Parent     string       `json:"parent"`
	// contains filtered or unexported fields
}

func GetModelList

func GetModelList(apiKey string) ([]Model, error)

func (Model) Info

func (m Model) Info() string

type Permission

type Permission struct {
	AllowCreateEngine  bool        `json:"allow_create_engine"`
	AllowSampling      bool        `json:"allow_sampling"`
	AllowLogprobs      bool        `json:"allow_logprobs"`
	AllowSearchIndices bool        `json:"allow_search_indices"`
	AllowView          bool        `json:"allow_view"`
	AllowFineTuning    bool        `json:"allow_fine_tuning"`
	Organization       string      `json:"organization"`
	Group              interface{} `json:"group"`
	IsBlocking         bool        `json:"is_blocking"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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