openai

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 11 Imported by: 0

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