openai

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError added in v0.1.2

type APIError struct {
	Status     int
	Type       string
	Code       string
	Message    string
	RetryAfter time.Duration
}

func AsAPIError added in v0.1.2

func AsAPIError(err error) *APIError

func (*APIError) Error added in v0.1.2

func (e *APIError) Error() string

func (*APIError) IsOverloaded added in v0.1.2

func (e *APIError) IsOverloaded() bool

func (*APIError) Retryable added in v0.1.2

func (e *APIError) Retryable() bool

type Client

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

func New

func New(options Options) *Client

func (*Client) Embed

func (c *Client) Embed(ctx context.Context, model string, texts []string) ([][]float64, error)

type Options

type Options struct {
	APIKey     string
	BaseURL    string
	Dimensions int
	HTTPClient *http.Client
	Retry      *RetryConfig

	Now   func() time.Time
	Sleep func(context.Context, time.Duration) error
}

type RetryConfig added in v0.1.2

type RetryConfig struct {
	MaxAttempts    int
	BaseDelay      time.Duration
	OverloadedBase time.Duration
	MaxDelay       time.Duration
	MaxElapsed     time.Duration
	Jitter         float64
}

func DefaultRetryConfig added in v0.1.2

func DefaultRetryConfig() RetryConfig

func NoRetry added in v0.1.2

func NoRetry() RetryConfig

Jump to

Keyboard shortcuts

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