llmretry

package
v1.0.0-rc.17 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 9 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

This section is empty.

Variables

This section is empty.

Functions

func NoRetry

func NoRetry(cause error) error

Types

type Duration

type Duration time.Duration

func (Duration) D

func (d Duration) D() time.Duration

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(b []byte) error

type ErrorClass

type ErrorClass string
const (
	ClassNone        ErrorClass = ""
	ClassRateLimit   ErrorClass = "rate_limit"
	ClassServerError ErrorClass = "server_error"
	ClassTimeout     ErrorClass = "timeout"
	ClassAuth        ErrorClass = "auth"
	ClassCapacity    ErrorClass = "capacity"
	ClassCanceled    ErrorClass = "canceled"
	ClassPermanent   ErrorClass = "permanent"
)

func ClassifyError

func ClassifyError(err error) ErrorClass

func (ErrorClass) IsRetryable

func (c ErrorClass) IsRetryable() bool

type Outcome

type Outcome struct {
	Attempts       int
	UsedFallback   bool
	LastErrorClass ErrorClass
	Elapsed        time.Duration
}

func Do

func Do(ctx context.Context, p RetryPolicy, primaryModel string, call func(modelID string) (any, error)) (any, Outcome, error)

type RetryPolicy

type RetryPolicy struct {
	MaxAttempts      int      `yaml:"max_attempts,omitempty" json:"max_attempts,omitempty" toml:"max_attempts,omitempty"`
	InitialBackoff   Duration `yaml:"initial_backoff,omitempty" json:"initial_backoff,omitempty" toml:"initial_backoff,omitempty"`
	MaxBackoff       Duration `yaml:"max_backoff,omitempty" json:"max_backoff,omitempty" toml:"max_backoff,omitempty"`
	Jitter           float64  `yaml:"jitter,omitempty" json:"jitter,omitempty" toml:"jitter,omitempty"`
	RateLimitMinWait Duration `yaml:"rate_limit_min_wait,omitempty" json:"rate_limit_min_wait,omitempty" toml:"rate_limit_min_wait,omitempty"`
	FallbackModelID  string   `yaml:"fallback_model_id,omitempty" json:"fallback_model_id,omitempty" toml:"fallback_model_id,omitempty"`
	FallbackAfter    int      `yaml:"fallback_after,omitempty" json:"fallback_after,omitempty" toml:"fallback_after,omitempty"`
}

Jump to

Keyboard shortcuts

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