pub struct CachedRetriever { /* private fields */ }Expand description
A RetrieverTrait decorator backed by a SemanticCacheCore.
Query flow: embed once → lexical hit → semantic hit → miss (call inner, insert). On a hit no retrieval call (and only the embedding call) happens; the embedding itself could be skipped only for lexical hits — which skip embedding too. Failures of the inner retriever propagate (never cached).
Implementations§
Source§impl CachedRetriever
impl CachedRetriever
Sourcepub fn new(
inner: Arc<dyn RetrieverTrait>,
embeddings: Arc<dyn Embeddings>,
config: SemanticCacheConfig,
) -> Self
pub fn new( inner: Arc<dyn RetrieverTrait>, embeddings: Arc<dyn Embeddings>, config: SemanticCacheConfig, ) -> Self
Wraps inner with a semantic cache using config.
Sourcepub fn cache(&self) -> &Arc<SemanticCacheCore> ⓘ
pub fn cache(&self) -> &Arc<SemanticCacheCore> ⓘ
The underlying cache core (for inspection / invalidation).
Trait Implementations§
Source§impl Debug for CachedRetriever
impl Debug for CachedRetriever
Source§impl RetrieverTrait for CachedRetriever
impl RetrieverTrait for CachedRetriever
Source§fn retrieve<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, RetrieverError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn retrieve<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, RetrieverError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieves relevant documents Read more
Source§fn retrieve_with_scores<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, RetrieverError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn retrieve_with_scores<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, RetrieverError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieves relevant documents (with scores)
Auto Trait Implementations§
impl !RefUnwindSafe for CachedRetriever
impl !UnwindSafe for CachedRetriever
impl Freeze for CachedRetriever
impl Send for CachedRetriever
impl Sync for CachedRetriever
impl Unpin for CachedRetriever
impl UnsafeUnpin for CachedRetriever
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