pub struct SemanticMemoryCache { /* private fields */ }Expand description
Memory cache with semantic similarity support
Implementations§
Source§impl SemanticMemoryCache
impl SemanticMemoryCache
Sourcepub fn new(config: CacheConfig) -> Self
pub fn new(config: CacheConfig) -> Self
Create a new semantic memory cache
Sourcepub async fn find_similar(
&self,
query_embedding: &[f32],
threshold: f32,
) -> Option<(CacheEntry, f32)>
pub async fn find_similar( &self, query_embedding: &[f32], threshold: f32, ) -> Option<(CacheEntry, f32)>
Find most similar entry
Trait Implementations§
Source§impl Cache for SemanticMemoryCache
impl Cache for SemanticMemoryCache
Source§fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
context: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
context: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Get an entry from the cache
Source§fn store<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
query: &'life1 str,
context: &'life2 str,
response: &'life3 str,
function_calls: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn store<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
query: &'life1 str,
context: &'life2 str,
response: &'life3 str,
function_calls: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Store an entry in the cache
Source§fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
context: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
context: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Delete an entry from the cache
Source§fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Clear all entries
Source§fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<CacheStats, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<CacheStats, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get cache statistics
Source§fn contains<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
context: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn contains<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
context: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Check if cache contains an entry
Source§impl SemanticCache for SemanticMemoryCache
impl SemanticCache for SemanticMemoryCache
Source§fn find_similar_by_embedding<'life0, 'life1, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
threshold: f32,
) -> Pin<Box<dyn Future<Output = Result<Option<(CacheEntry, f32)>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_similar_by_embedding<'life0, 'life1, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
threshold: f32,
) -> Pin<Box<dyn Future<Output = Result<Option<(CacheEntry, f32)>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find similar entries based on embedding similarity Read more
Source§fn store_with_embedding<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
query: &'life1 str,
context: &'life2 str,
response: &'life3 str,
function_calls: Vec<String>,
embedding: Vec<f32>,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn store_with_embedding<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
query: &'life1 str,
context: &'life2 str,
response: &'life3 str,
function_calls: Vec<String>,
embedding: Vec<f32>,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Store with embedding for semantic matching Read more
Auto Trait Implementations§
impl !Freeze for SemanticMemoryCache
impl !RefUnwindSafe for SemanticMemoryCache
impl Send for SemanticMemoryCache
impl Sync for SemanticMemoryCache
impl Unpin for SemanticMemoryCache
impl UnsafeUnpin for SemanticMemoryCache
impl UnwindSafe for SemanticMemoryCache
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