pub struct Backend<C: LLMClient> {
pub client: C,
pub cost_per_1m: Option<(f64, f64)>,
pub priority: usize,
/* private fields */
}Expand description
A single backend in a RouterClient chain.
cost_per_1m is the (input, output) price per 1,000,000 tokens in USD,
used by RoutingStrategy::LowestCost to order backends. priority
(ascending) is used by RoutingStrategy::Fallback. Ties in either keep
insertion order (stable sort).
Fields§
§client: CThe underlying client.
cost_per_1m: Option<(f64, f64)>(input_per_1m, output_per_1m) in USD. None = unknown → sorts last.
priority: usizeLower = tried first. Defaults to 0.
Implementations§
Source§impl<C: LLMClient> Backend<C>
impl<C: LLMClient> Backend<C>
Sourcepub fn new(client: C, cost_per_1m: Option<(f64, f64)>) -> Self
pub fn new(client: C, cost_per_1m: Option<(f64, f64)>) -> Self
Create a backend with no cost metadata and default priority.
Sourcepub fn with_priority(self, priority: usize) -> Self
pub fn with_priority(self, priority: usize) -> Self
Set the fallback priority (lower = tried first).
Sourcepub fn with_label(self, label: impl Into<String>) -> Self
pub fn with_label(self, label: impl Into<String>) -> Self
Override the label used for this backend (otherwise the underlying
client’s LLMClient::model_name is used).
Auto Trait Implementations§
impl<C> Freeze for Backend<C>where
C: Freeze,
impl<C> RefUnwindSafe for Backend<C>where
C: RefUnwindSafe,
impl<C> Send for Backend<C>
impl<C> Sync for Backend<C>
impl<C> Unpin for Backend<C>where
C: Unpin,
impl<C> UnsafeUnpin for Backend<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for Backend<C>where
C: UnwindSafe,
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.