Documentation
¶
Overview ¶
Package fallback provides a Model implementation that chains multiple models together, falling back to the next model when one fails with a retryable error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FallbackModel ¶
FallbackModel wraps multiple models and tries each in order until one succeeds.
func New ¶
func New(chain []models.Model, opts ...Option) (*FallbackModel, error)
New creates a FallbackModel from the given chain of models. At least two models are required.
func (*FallbackModel) Invoke ¶
func (f *FallbackModel) Invoke(ctx context.Context, req *models.InvokeRequest) (*types.ModelResponse, error)
Invoke tries each model in the chain, falling back on retryable errors.
func (*FallbackModel) InvokeStream ¶
func (f *FallbackModel) InvokeStream(ctx context.Context, req *models.InvokeRequest) (<-chan types.ResponseChunk, error)
InvokeStream tries each model in the chain for streaming. Only falls back if the stream fails to open (not mid-stream failures).
type Option ¶
type Option func(*Options)
Option configures a FallbackModel.
func WithMaxRetries ¶
WithMaxRetries sets the maximum number of retries per model. Use 0 for no retries (each model is tried once before falling back).
func WithRetryDelay ¶
WithRetryDelay sets the delay between retries.