provider

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyProviderDefaults added in v0.12.1

func ApplyProviderDefaults(cfg *config.Config)

func DefaultModelsForConfig added in v0.12.1

func DefaultModelsForConfig(cfg config.Config) []string

func IsContextLimit

func IsContextLimit(err error) bool

func StreamStarted

func StreamStarted(err error) bool

func ValidateModelForConfig added in v0.12.1

func ValidateModelForConfig(cfg config.Config, modelID string) error

Types

type ChunkHandler

type ChunkHandler func(string) error

type CircuitStatus

type CircuitStatus struct {
	State               string `json:"state"`
	Requests            uint32 `json:"requests"`
	TotalSuccesses      uint32 `json:"total_successes"`
	TotalFailures       uint32 `json:"total_failures"`
	ConsecutiveFailures uint32 `json:"consecutive_failures"`
}

type Error

type Error struct {
	Status        int
	RetryAfter    time.Duration
	StreamStarted bool
	Cause         error
}

func AsError

func AsError(err error) (*Error, bool)

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ModelCatalogRequest

type ModelCatalogRequest struct {
	URL        string
	HeaderName string
	APIKey     string
}

func ModelCatalogForConfig

func ModelCatalogForConfig(cfg config.Config) (ModelCatalogRequest, bool)

type OpenAICompatible

type OpenAICompatible struct {
	Endpoint string
	APIKey   string
	Client   *http.Client
}

func (OpenAICompatible) Complete

func (p OpenAICompatible) Complete(ctx context.Context, request model.Request, onChunk ChunkHandler) (model.Response, error)

type Provider

type Provider interface {
	Complete(ctx context.Context, request model.Request, onChunk ChunkHandler) (model.Response, error)
}

type RetryEvent

type RetryEvent struct {
	Attempt int
	Delay   time.Duration
	Message string
}

type RetryPolicy

type RetryPolicy struct {
	MaxRetries      int
	BaseDelay       time.Duration
	MaxDelay        time.Duration
	ExponentialBase float64
	Jitter          bool
}

type Router

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

func NewRouter

func NewRouter(cfg RouterConfig) (*Router, error)

func (*Router) Complete

func (r *Router) Complete(ctx context.Context, request model.Request, onChunk ChunkHandler) (model.Response, error)

func (*Router) PreferFallbackAfter added in v0.14.2

func (r *Router) PreferFallbackAfter(modelID string)

type RouterConfig

type RouterConfig struct {
	Targets                 []Target
	Retry                   RetryPolicy
	CircuitFailureThreshold int
	CircuitOpenDuration     time.Duration
	State                   *RouterState
	OnRetry                 func(RetryEvent)
}

type RouterState

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

func NewRouterState

func NewRouterState() *RouterState

func (*RouterState) Status

func (s *RouterState) Status() map[string]CircuitStatus

type Target

type Target struct {
	ModelID  string
	Provider Provider
}

func TargetsForConfig

func TargetsForConfig(cfg config.Config, client *http.Client) ([]Target, error)

Jump to

Keyboard shortcuts

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