pub struct FallbackLlmBuilder { /* private fields */ }Expand description
Builds a FallbackLlm: the first model, the models to fall back to in order, and the
triggers that move the chain on.
§Example
use std::sync::Arc;
use adk_core::Llm;
use adk_model::fallback::{FallbackLlm, FallbackTrigger};
use adk_model::{ScriptedLlm, ScriptedResponse};
let primary = Arc::new(ScriptedLlm::new("claude-sonnet-5-5", Vec::<ScriptedResponse>::new()));
let backup = Arc::new(ScriptedLlm::new("claude-haiku-5-5", Vec::<ScriptedResponse>::new()));
let model = FallbackLlm::builder(primary)
.fallback(backup)
.never_fall_back_on(FallbackTrigger::ModelNotFound)
.build();
assert_eq!(model.name(), "claude-sonnet-5-5");
assert_eq!(model.triggers(), [FallbackTrigger::Retryable, FallbackTrigger::QuotaExhausted]);Implementations§
Source§impl FallbackLlmBuilder
impl FallbackLlmBuilder
Sourcepub fn fallback(self, model: Arc<dyn Llm>) -> Self
pub fn fallback(self, model: Arc<dyn Llm>) -> Self
Appends model to the chain, after the models already in it.
Sourcepub fn fall_back_on(self, trigger: FallbackTrigger) -> Self
pub fn fall_back_on(self, trigger: FallbackTrigger) -> Self
Moves the chain on when trigger matches.
Sourcepub fn never_fall_back_on(self, trigger: FallbackTrigger) -> Self
pub fn never_fall_back_on(self, trigger: FallbackTrigger) -> Self
Returns the error, or the refusal, when trigger matches, instead of moving on.
Sourcepub fn triggers(
self,
triggers: impl IntoIterator<Item = FallbackTrigger>,
) -> Self
pub fn triggers( self, triggers: impl IntoIterator<Item = FallbackTrigger>, ) -> Self
Replaces the triggers with triggers.
Sourcepub fn build(self) -> FallbackLlm
pub fn build(self) -> FallbackLlm
Builds the chain.
Auto Trait Implementations§
impl !RefUnwindSafe for FallbackLlmBuilder
impl !UnwindSafe for FallbackLlmBuilder
impl Forget for FallbackLlmBuilder
impl Freeze for FallbackLlmBuilderwhere
*const u8 is !null: Freeze,
PhantomData<Arc<dyn Llm>>: Freeze,
PhantomData<FallbackTrigger>: Freeze,
impl Move for FallbackLlmBuilder
impl Send for FallbackLlmBuilder
impl Sync for FallbackLlmBuilder
impl Unpin for FallbackLlmBuilder
impl UnsafeUnpin for FallbackLlmBuilderwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Arc<dyn Llm>>: UnsafeUnpin,
PhantomData<FallbackTrigger>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestCreates a shared type from an unshared type.