sdkerr

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERR_CONTEXT_LENGTH_EXCEEDED = NewApiError(400, "context_length_exceeded", "Please reduce the length of the messages.", "invalid_request_error", "messages")
	ERR_INVALID_API_KEY         = NewApiError(401, "invalid_api_key", "Incorrect API key provided or has been disabled.", "invalid_request_error", "")
	ERR_MODEL_NOT_FOUND         = NewApiError(404, "model_not_found", "The model does not exist or you do not have access to it.", "invalid_request_error", "")
	ERR_INSUFFICIENT_QUOTA      = NewApiError(429, "insufficient_quota", "You exceeded your current quota.", "insufficient_quota", "")
	ERR_RATE_LIMIT_EXCEEDED     = NewApiError(429, "rate_limit_exceeded", "Rate limit reached, Please try again later.", "requests", "")
)

Functions

func NewApiError added in v0.2.0

func NewApiError(httpStatusCode int, code any, message, typ, param string) error

func NewRequestError added in v0.2.0

func NewRequestError(httpStatusCode int, err error) error

Types

type ApiError added in v0.2.0

type ApiError struct {
	HttpStatusCode int     `json:"-"`
	Code           any     `json:"code,omitempty"`
	Message        string  `json:"message"`
	Type           string  `json:"type"`
	Param          *string `json:"param,omitempty"`
}

ApiError provides error information returned by the OpenAI API. InnerError struct is only valid for Azure OpenAI Service.

func (*ApiError) Error added in v0.2.0

func (e *ApiError) Error() string

func (*ApiError) UnmarshalJSON added in v0.2.0

func (e *ApiError) UnmarshalJSON(data []byte) (err error)

type ErrorResponse

type ErrorResponse struct {
	Error *ApiError `json:"error,omitempty"`
}

type RequestError

type RequestError struct {
	HttpStatusCode int
	Err            error
}

RequestError provides information about generic request sdkerr.

func (*RequestError) Error

func (e *RequestError) Error() string

func (*RequestError) Unwrap

func (e *RequestError) Unwrap() error

Jump to

Keyboard shortcuts

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