openai

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	AuthorizationHeader string = "Authorization"
	ContentTypeHeader   string = "Content-Type"
)

Variables

This section is empty.

Functions

func EstimateCost

func EstimateCost(model string, promptTokens int, completionTokens int) float64

Types

type OpenAiClient

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

func NewOpenAiClient

func NewOpenAiClient(apiCredential string) OpenAiClient

func (OpenAiClient) Send

type OpenAiError

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

func NewOpenAiError

func NewOpenAiError(message string, errorType string, code int) *OpenAiError

func (*OpenAiError) Error

func (e *OpenAiError) Error() string

func (*OpenAiError) StatusCode

func (e *OpenAiError) StatusCode() int

type OpenAiErrorContent

type OpenAiErrorContent struct {
	Message string `json:"message"`
	Type    string `json:"type"`
}

type OpenAiErrorResponse

type OpenAiErrorResponse struct {
	Error *OpenAiErrorContent `json:"error"`
}

type OpenAiResponse

type OpenAiResponse struct {
	Id      string   `json:"id"`
	Object  string   `json:"object"`
	Created int64    `json:"created"`
	Choices []choice `json:"choices"`
	Usage   usage    `json:"usage"`
}

Jump to

Keyboard shortcuts

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