pub struct ModelFallback { /* private fields */ }Expand description
An ordered sequence of fallback models to attempt when the primary model (and its retries) are exhausted.
The agent tries each model in order, applying the configured
RetryStrategy independently for each model.
When all fallback models are also exhausted the error propagates normally.
§Example
use swink_agent::{ModelFallback, ModelSpec};
let fallback = ModelFallback::new(vec![
(ModelSpec::new("openai", "gpt-4o-mini"), make_stream_fn()),
(ModelSpec::new("anthropic", "claude-3-haiku-20240307"), make_stream_fn()),
]);Implementations§
Trait Implementations§
Source§impl Clone for ModelFallback
impl Clone for ModelFallback
Source§fn clone(&self) -> ModelFallback
fn clone(&self) -> ModelFallback
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ModelFallback
impl !RefUnwindSafe for ModelFallback
impl Send for ModelFallback
impl Sync for ModelFallback
impl Unpin for ModelFallback
impl UnsafeUnpin for ModelFallback
impl !UnwindSafe for ModelFallback
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