mirascope.retries.fallback | Mirascope
MirascopeLilypad

mirascope.retries.fallback

Module fallback

The fallback module provides a fallback retry strategy.

Class FallbackDecorator

Bases:

Protocol

Class Fallback

The override arguments to use for this fallback attempt.

Bases:

TypedDict

Attributes

NameTypeDescription
catchRequired[type[Exception] | tuple[type[Exception]]]-
providerRequired[Provider]-
modelRequired[str]-
call_paramsNotRequired[CommonCallParams]-
clientNotRequired[Any]-

Class FallbackError

An error raised when all fallbacks fail.

Bases:

Exception

Function fallback

A decorator that retries the function call with a fallback strategy.

This must use the provider-agnostic llm.call decorator.

Parameters

NameTypeDescription
catchtype[Exception] | tuple[type[Exception]]The exception(s) to catch for the original call.
fallbackslist[Fallback]-

Returns

TypeDescription
FallbackDecoratorThe decorated function.