pub struct SemanticCache { /* private fields */ }Expand description
Semantic cache with similarity-based retrieval
Implementations§
Source§impl SemanticCache
impl SemanticCache
Sourcepub fn new(config: SemanticCacheConfig) -> RragResult<Self>
pub fn new(config: SemanticCacheConfig) -> RragResult<Self>
Create new semantic cache
Sourcepub fn find_similar(
&self,
_query: &str,
embedding: &[f32],
) -> Vec<SimilaritySearchResult>
pub fn find_similar( &self, _query: &str, embedding: &[f32], ) -> Vec<SimilaritySearchResult>
Find semantically similar cached entries
Sourcepub fn get_or_similar(
&self,
query: &str,
embedding: Option<&[f32]>,
) -> Option<SemanticCacheEntry>
pub fn get_or_similar( &self, query: &str, embedding: Option<&[f32]>, ) -> Option<SemanticCacheEntry>
Get or find semantically similar entry
Sourcepub fn cache_with_clustering(
&mut self,
query: String,
embedding: Vec<f32>,
entry: SemanticCacheEntry,
) -> RragResult<()>
pub fn cache_with_clustering( &mut self, query: String, embedding: Vec<f32>, entry: SemanticCacheEntry, ) -> RragResult<()>
Cache entry with semantic clustering
Sourcepub fn get_clusters(&self) -> &[SemanticCluster]
pub fn get_clusters(&self) -> &[SemanticCluster]
Get cluster information
Sourcepub fn get_insights(&self) -> SemanticCacheInsights
pub fn get_insights(&self) -> SemanticCacheInsights
Get cache insights
Trait Implementations§
Source§impl Cache<String, SemanticCacheEntry> for SemanticCache
impl Cache<String, SemanticCacheEntry> for SemanticCache
Source§fn put(&mut self, key: String, value: SemanticCacheEntry) -> RragResult<()>
fn put(&mut self, key: String, value: SemanticCacheEntry) -> RragResult<()>
Put value into cache
Source§fn stats(&self) -> CacheStats
fn stats(&self) -> CacheStats
Get cache statistics
Auto Trait Implementations§
impl Freeze for SemanticCache
impl RefUnwindSafe for SemanticCache
impl Send for SemanticCache
impl Sync for SemanticCache
impl Unpin for SemanticCache
impl UnwindSafe for SemanticCache
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