pub struct FallbackProvider<P> { /* private fields */ }Expand description
A provider that automatically falls back to alternative providers on failure
Implementations§
Source§impl<P> FallbackProvider<P>
impl<P> FallbackProvider<P>
Sourcepub fn new(providers: Vec<P>) -> Self
pub fn new(providers: Vec<P>) -> Self
Create a new fallback provider with a list of providers
§Panics
Panics if the providers list is empty
Sourcepub fn with_retry_all_errors(self, retry_all: bool) -> Self
pub fn with_retry_all_errors(self, retry_all: bool) -> Self
Configure whether to fallback on all errors (default: only retryable errors)
Sourcepub fn provider_count(&self) -> usize
pub fn provider_count(&self) -> usize
Get the number of providers
Trait Implementations§
Source§impl<P: EmbeddingProvider> EmbeddingProvider for FallbackProvider<P>
impl<P: EmbeddingProvider> EmbeddingProvider for FallbackProvider<P>
fn embed<'life0, 'async_trait>(
&'life0 self,
request: EmbeddingRequest,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl<P: LlmProvider> LlmProvider for FallbackProvider<P>
impl<P: LlmProvider> LlmProvider for FallbackProvider<P>
fn complete<'life0, 'async_trait>(
&'life0 self,
request: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl<P: StreamingLlmProvider> StreamingLlmProvider for FallbackProvider<P>
impl<P: StreamingLlmProvider> StreamingLlmProvider for FallbackProvider<P>
Source§fn complete_stream<'life0, 'async_trait>(
&'life0 self,
request: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete_stream<'life0, 'async_trait>(
&'life0 self,
request: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stream completion responses token-by-token
Auto Trait Implementations§
impl<P> Freeze for FallbackProvider<P>
impl<P> RefUnwindSafe for FallbackProvider<P>where
P: RefUnwindSafe,
impl<P> Send for FallbackProvider<P>where
P: Send,
impl<P> Sync for FallbackProvider<P>where
P: Sync,
impl<P> Unpin for FallbackProvider<P>where
P: Unpin,
impl<P> UnwindSafe for FallbackProvider<P>where
P: UnwindSafe,
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
Mutably borrows from an owned value. Read more