pub struct WindowExpander { /* private fields */ }Expand description
Expands retrieval hits into bounded context windows.
Given a set of top-k hits from retrieval, expands each hit into a window of surrounding steps to preserve temporal context.
Implementations§
Source§impl WindowExpander
impl WindowExpander
Sourcepub fn new(config: WindowConfig) -> Self
pub fn new(config: WindowConfig) -> Self
Create a new window expander with given configuration.
Sourcepub fn default_config() -> Self
pub fn default_config() -> Self
Create a window expander with default configuration.
Sourcepub fn expand(
&self,
hits: &[RetrievalHit],
episode_step_counts: &[(Uuid, usize)],
) -> WindowExpansionResult
pub fn expand( &self, hits: &[RetrievalHit], episode_step_counts: &[(Uuid, usize)], ) -> WindowExpansionResult
Expand retrieval hits into context windows.
For each hit, compute a window of steps around it based on the configuration. Returns bounded windows that preserve context.
Sourcepub fn expand_with_context(
&self,
hits: &[RetrievalHit],
episode_data: &[(Uuid, usize, String)],
) -> WindowExpansionResult
pub fn expand_with_context( &self, hits: &[RetrievalHit], episode_data: &[(Uuid, usize, String)], ) -> WindowExpansionResult
Expand hits with episode context included.
Requires episode descriptions to be provided for context.
Sourcepub fn config(&self) -> &WindowConfig
pub fn config(&self) -> &WindowConfig
Get the configuration for this expander.
Sourcepub fn estimate_token_savings(
&self,
full_episode_steps: usize,
window_size: usize,
) -> f32
pub fn estimate_token_savings( &self, full_episode_steps: usize, window_size: usize, ) -> f32
Estimate the token savings from window-based retrieval.
Returns the estimated reduction in tokens compared to returning full episodes.
Auto Trait Implementations§
impl Freeze for WindowExpander
impl RefUnwindSafe for WindowExpander
impl Send for WindowExpander
impl Sync for WindowExpander
impl Unpin for WindowExpander
impl UnsafeUnpin for WindowExpander
impl UnwindSafe for WindowExpander
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 moreimpl<T> SendAlias for T
impl<T> SendAlias for T
impl<T> SendSyncUnwindSafe for Twhere
T: Send + Sync + UnwindSafe + ?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.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.