pub struct HookedRouter<R> { /* private fields */ }Expand description
A LanguageModelRouter wrapper that attaches GenerationHooks to
every model returned by the inner router.
When the hooks slice is empty the wrapper is a zero-cost pass-through — it returns the inner model unchanged.
Implementations§
Source§impl<R> HookedRouter<R>
impl<R> HookedRouter<R>
Sourcepub fn new(inner: R, hooks: Arc<[Arc<dyn GenerationHook>]>) -> Self
pub fn new(inner: R, hooks: Arc<[Arc<dyn GenerationHook>]>) -> Self
Wrap an existing router with generation hooks.
If hooks is empty, models are returned unwrapped.
Trait Implementations§
Source§impl<R> LanguageModelRouter for HookedRouter<R>
impl<R> LanguageModelRouter for HookedRouter<R>
Source§async fn route_model(
&self,
target: RoutingTarget,
) -> Result<Box<DynLanguageModel<'static>>>
async fn route_model( &self, target: RoutingTarget, ) -> Result<Box<DynLanguageModel<'static>>>
Routes to the appropriate language model implementation based on the routing target. Read more
Auto Trait Implementations§
impl<R> Freeze for HookedRouter<R>where
R: Freeze,
impl<R> !RefUnwindSafe for HookedRouter<R>
impl<R> Send for HookedRouter<R>where
R: Send,
impl<R> Sync for HookedRouter<R>where
R: Sync,
impl<R> Unpin for HookedRouter<R>where
R: Unpin,
impl<R> UnsafeUnpin for HookedRouter<R>where
R: UnsafeUnpin,
impl<R> !UnwindSafe for HookedRouter<R>
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
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 more