pub struct FallbackProvider { /* private fields */ }Expand description
Provider that tries multiple inner providers in order, returning the first success.
§Construction
Use FallbackProvider::new() with a non-empty Vec of providers.
An empty vec is rejected with a config error.
Use FallbackProvider::with_retry() to enable per-provider retry
with exponential backoff on transient errors.
Implementations§
Source§impl FallbackProvider
impl FallbackProvider
Sourcepub fn new(providers: Vec<Box<dyn LlmProvider>>) -> Result<Self, RunnerError>
pub fn new(providers: Vec<Box<dyn LlmProvider>>) -> Result<Self, RunnerError>
Create a fallback chain from a non-empty list of providers.
No retries are attempted (equivalent to max_retries = 0).
§Errors
Returns RunnerError with ErrorKind::Config if providers is empty.
Sourcepub fn with_retry(
providers: Vec<Box<dyn LlmProvider>>,
retry_config: RetryConfig,
) -> Result<Self, RunnerError>
pub fn with_retry( providers: Vec<Box<dyn LlmProvider>>, retry_config: RetryConfig, ) -> Result<Self, RunnerError>
Create a fallback chain with per-provider retry configuration.
When a provider returns a transient error, the request is retried up to
retry_config.max_retries times with exponential backoff before moving
to the next provider. Permanent errors skip retries immediately.
§Errors
Returns RunnerError with ErrorKind::Config if providers is empty.
Trait Implementations§
Source§impl LlmProvider for FallbackProvider
impl LlmProvider for FallbackProvider
Source§fn display_name(&self) -> &str
fn display_name(&self) -> &str
Source§fn capabilities(&self) -> LlmCapabilities
fn capabilities(&self) -> LlmCapabilities
Source§fn default_model(&self) -> &str
fn default_model(&self) -> &str
Source§fn available_models(&self) -> &[String]
fn available_models(&self) -> &[String]
Source§fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, RunnerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, RunnerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn complete_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatStream, RunnerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn complete_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatStream, RunnerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool, RunnerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool, RunnerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl Freeze for FallbackProvider
impl !RefUnwindSafe for FallbackProvider
impl Send for FallbackProvider
impl Sync for FallbackProvider
impl Unpin for FallbackProvider
impl UnsafeUnpin for FallbackProvider
impl !UnwindSafe for FallbackProvider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more