pub struct FallbackProvider { /* private fields */ }Expand description
Wraps a primary and secondary LlmProvider. On transient failure from
the primary, automatically tries the secondary.
Implements LlmProvider itself, so it can be used anywhere a provider is expected
(including inside a MiddlewareStack).
Implementations§
Source§impl FallbackProvider
impl FallbackProvider
Sourcepub fn new(primary: impl LlmProvider, secondary: impl LlmProvider) -> Self
pub fn new(primary: impl LlmProvider, secondary: impl LlmProvider) -> Self
Create a fallback provider with a primary and secondary.
Trait Implementations§
Source§impl LlmProvider for FallbackProvider
impl LlmProvider for FallbackProvider
Source§fn complete(
&self,
messages: &[Message],
tools: &[ToolSchema],
) -> Pin<Box<dyn Future<Output = Result<LlmResponse, PeError>> + Send + '_>>
fn complete( &self, messages: &[Message], tools: &[ToolSchema], ) -> Pin<Box<dyn Future<Output = Result<LlmResponse, PeError>> + Send + '_>>
Non-streaming completion. Returns the full response. Read more
Source§fn stream(&self, messages: &[Message], tools: &[ToolSchema]) -> StreamFuture<'_>
fn stream(&self, messages: &[Message], tools: &[ToolSchema]) -> StreamFuture<'_>
Streaming completion. Yields tokens (and tool call deltas) as they arrive. Read more
Source§fn embed(
&self,
text: &str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, PeError>> + Send + '_>>
fn embed( &self, text: &str, ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, PeError>> + Send + '_>>
Embed text into a vector. Used for semantic routing and memory search.
Source§fn provider_name(&self) -> &'static str
fn provider_name(&self) -> &'static str
Human-readable provider name for logging (“openai”, “anthropic”, “mock”).
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
Mutably borrows from an owned value. Read more