pub struct FallbackProvider { /* private fields */ }Expand description
Tries providers in order, advancing to the next on a retryable failure.
Non-retryable errors (invalid request, auth, budget) short-circuit — there is no point trying the next provider if the request itself is malformed.
Implementations§
Source§impl FallbackProvider
impl FallbackProvider
Sourcepub fn new(providers: Vec<Arc<dyn LlmProvider>>) -> Self
pub fn new(providers: Vec<Arc<dyn LlmProvider>>) -> Self
Build a chain from an ordered list of providers (primary first).
Trait Implementations§
Source§impl LlmProvider for FallbackProvider
impl LlmProvider for FallbackProvider
Source§fn chat<'life0, 'async_trait>(
&'life0 self,
req: ChatRequest,
) -> Pin<Box<dyn Future<Output = LlmResult<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat<'life0, 'async_trait>(
&'life0 self,
req: ChatRequest,
) -> Pin<Box<dyn Future<Output = LlmResult<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Single-shot chat completion.
Source§fn chat_stream<'life0, 'async_trait>(
&'life0 self,
req: ChatRequest,
) -> Pin<Box<dyn Future<Output = LlmResult<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat_stream<'life0, 'async_trait>(
&'life0 self,
req: ChatRequest,
) -> Pin<Box<dyn Future<Output = LlmResult<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Streaming chat completion.
Source§fn embed<'life0, 'async_trait>(
&'life0 self,
req: EmbedRequest,
) -> Pin<Box<dyn Future<Output = LlmResult<EmbedResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn embed<'life0, 'async_trait>(
&'life0 self,
req: EmbedRequest,
) -> Pin<Box<dyn Future<Output = LlmResult<EmbedResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Generate embeddings.
Source§fn estimate_cost(&self, req: &ChatRequest) -> Option<CostEstimate>
fn estimate_cost(&self, req: &ChatRequest) -> Option<CostEstimate>
Pre-flight cost estimate (no network call).
None if unknown.Auto Trait Implementations§
impl !RefUnwindSafe for FallbackProvider
impl !UnwindSafe for FallbackProvider
impl Freeze for FallbackProvider
impl Send for FallbackProvider
impl Sync for FallbackProvider
impl Unpin for FallbackProvider
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more