pub struct WeightedRouter { /* private fields */ }Expand description
Weighted router: pick the child with the highest weight. On ties the
earliest index wins (so all-equal weights behave like RuleRouter —
always child 0). Missing trailing weights default to 0.0. NaN at index > 0
loses to any finite weight (NaN at index 0 wins only because nothing
compares greater than NaN — avoid NaN weights). To route by cost
(lowest-cost first), pass reciprocals or negative weights.
Implementations§
Trait Implementations§
Source§impl Router for WeightedRouter
impl Router for WeightedRouter
Source§fn route(
&self,
_prompt: &LanguageModelPrompt,
models: &[ChildModel],
) -> Result<usize, AiMuxError>
fn route( &self, _prompt: &LanguageModelPrompt, models: &[ChildModel], ) -> Result<usize, AiMuxError>
Choose a child-model index.
Err means “no child can serve this prompt”. Read moreAuto Trait Implementations§
impl Freeze for WeightedRouter
impl RefUnwindSafe for WeightedRouter
impl Send for WeightedRouter
impl Sync for WeightedRouter
impl Unpin for WeightedRouter
impl UnsafeUnpin for WeightedRouter
impl UnwindSafe for WeightedRouter
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