pub struct FallbackProvider { /* private fields */ }Expand description
An LlmProvider that fails over across an ordered list of backends.
Construct with a primary, then layer secondaries with
with_fallback (or build the whole chain at once with
from_providers).
Implementations§
Source§impl FallbackProvider
impl FallbackProvider
Sourcepub fn new(primary: Arc<dyn LlmProvider>) -> Self
pub fn new(primary: Arc<dyn LlmProvider>) -> Self
Create a fallback chain with a single primary provider (no secondaries yet).
Sourcepub fn with_fallback(self, provider: Arc<dyn LlmProvider>) -> Self
pub fn with_fallback(self, provider: Arc<dyn LlmProvider>) -> Self
Append a secondary provider to the end of the failover order.
Sourcepub fn from_providers(
primary: Arc<dyn LlmProvider>,
fallbacks: impl IntoIterator<Item = Arc<dyn LlmProvider>>,
) -> Self
pub fn from_providers( primary: Arc<dyn LlmProvider>, fallbacks: impl IntoIterator<Item = Arc<dyn LlmProvider>>, ) -> Self
Build a chain from a primary and an ordered iterator of secondaries.
Trait Implementations§
Source§impl LlmProvider for FallbackProvider
impl LlmProvider for FallbackProvider
Source§fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ModelInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ModelInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delegate live model discovery to the primary provider so wrapping in a
fallback never silently loses list_models.
Source§fn chat<'life0, 'async_trait>(
&'life0 self,
request: ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatOutcome>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat<'life0, 'async_trait>(
&'life0 self,
request: ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatOutcome>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Non-streaming chat completion.
Source§fn chat_stream(&self, request: ChatRequest) -> StreamBox<'_>
fn chat_stream(&self, request: ChatRequest) -> StreamBox<'_>
Streaming chat completion. Read more
fn model(&self) -> &str
fn provider(&self) -> &'static str
Source§fn configured_thinking(&self) -> Option<&ThinkingConfig>
fn configured_thinking(&self) -> Option<&ThinkingConfig>
Provider-owned thinking configuration, if any.
Source§fn capabilities(&self) -> Option<&'static ModelCapabilities>
fn capabilities(&self) -> Option<&'static ModelCapabilities>
Canonical capability metadata for this provider/model, if known.
Source§fn model_features(&self) -> Option<&'static ModelFeatures>
fn model_features(&self) -> Option<&'static ModelFeatures>
API-shape feature metadata for this provider/model, when known. Read more
Source§fn validate_thinking_config(
&self,
thinking: Option<&ThinkingConfig>,
) -> Result<()>
fn validate_thinking_config( &self, thinking: Option<&ThinkingConfig>, ) -> Result<()>
Validate a thinking configuration against the provider/model capabilities. Read more
Source§fn resolve_thinking_config(
&self,
request_thinking: Option<&ThinkingConfig>,
) -> Result<Option<ThinkingConfig>>
fn resolve_thinking_config( &self, request_thinking: Option<&ThinkingConfig>, ) -> Result<Option<ThinkingConfig>>
Resolve the effective thinking configuration for a request. Read more
Source§fn default_max_tokens(&self) -> u32
fn default_max_tokens(&self) -> u32
Default maximum output tokens for this provider/model when the caller
does not explicitly override
AgentConfig.max_tokens.Source§fn structured_output_support(&self) -> StructuredOutputSupport
fn structured_output_support(&self) -> StructuredOutputSupport
How this provider satisfies a structured-output
(
ResponseFormat) request. Read moreAuto 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