pub struct HookedModel { /* private fields */ }Expand description
A model wrapper that invokes GenerationHook callbacks after
generate() completes and for each streaming part yielded by stream().
The wrapper is a pure observer — it never modifies requests or responses.
The LanguageModel
implementation lives below in this file so all trait methods are co-located.
Implementations§
Source§impl HookedModel
impl HookedModel
pub fn new( inner: Box<DynLanguageModel<'static>>, hooks: Arc<[Arc<dyn GenerationHook>]>, ) -> Self
Trait Implementations§
Source§impl LanguageModel for HookedModel
impl LanguageModel for HookedModel
Source§fn provider_name(&self) -> &str
fn provider_name(&self) -> &str
Provider name, e.g. “openai”, “anthropic”, etc.
Source§fn model_id(&self) -> &str
fn model_id(&self) -> &str
The upstream model ID, e.g. “gpt-4o”, “claude-3-5-sonnet-20241022”, etc.
Source§async fn supported_urls(&self) -> Record<String, Regex>
async fn supported_urls(&self) -> Record<String, Regex>
Media type -> Regex for supported URLs of that media type Read more
Source§async fn generate(
&self,
options: LanguageModelCallOptions,
) -> Result<LanguageModelGenerateResult>
async fn generate( &self, options: LanguageModelCallOptions, ) -> Result<LanguageModelGenerateResult>
Generates content based on the given options.
Source§async fn stream(
&self,
options: LanguageModelCallOptions,
) -> Result<LanguageModelStreamResult>
async fn stream( &self, options: LanguageModelCallOptions, ) -> Result<LanguageModelStreamResult>
Generates content based on the given options, but returns a stream of partial results.
Auto Trait Implementations§
impl Freeze for HookedModel
impl !RefUnwindSafe for HookedModel
impl Send for HookedModel
impl Sync for HookedModel
impl Unpin for HookedModel
impl UnsafeUnpin for HookedModel
impl !UnwindSafe for HookedModel
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