pub struct ShortTermMemory { /* private fields */ }Expand description
Bounded in-thread working memory (one FIFO queue per namespace).
Recall ranks by raw scorer similarity. Cloning is cheap when shared via Arc.
Implementations§
Source§impl ShortTermMemory
impl ShortTermMemory
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Creates a store with the given per-namespace capacity and the default
LexicalScorer.
Sourcepub fn with_scorer(capacity: usize, scorer: Arc<dyn SemanticScorer>) -> Self
pub fn with_scorer(capacity: usize, scorer: Arc<dyn SemanticScorer>) -> Self
Creates a store with a custom semantic scorer.
Trait Implementations§
Source§impl Debug for ShortTermMemory
impl Debug for ShortTermMemory
Source§impl MemoryStore for ShortTermMemory
impl MemoryStore for ShortTermMemory
Source§fn put<'life0, 'life1, 'async_trait>(
&'life0 self,
namespace: &'life1 str,
item: MemoryItem,
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put<'life0, 'life1, 'async_trait>(
&'life0 self,
namespace: &'life1 str,
item: MemoryItem,
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Writes/updates an item in the namespace. Re-putting an existing key refreshes
its content and access time.
Source§fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
namespace: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<MemoryItem>, MemoryError>> + 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,
namespace: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<MemoryItem>, MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Exact key lookup (
None when absent). Counts as an access.Source§fn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 MemoryQuery<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryHit>, MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 MemoryQuery<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryHit>, MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Semantic recall, best score first, capped at
query.k.Source§fn forget<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
namespace: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn forget<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
namespace: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Removes one entry; returns whether it existed.
Source§fn clear_namespace<'life0, 'life1, 'async_trait>(
&'life0 self,
namespace: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<usize, MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn clear_namespace<'life0, 'life1, 'async_trait>(
&'life0 self,
namespace: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<usize, MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Drops every entry in the namespace; returns the number removed.
Auto Trait Implementations§
impl !Freeze for ShortTermMemory
impl !RefUnwindSafe for ShortTermMemory
impl !UnwindSafe for ShortTermMemory
impl Send for ShortTermMemory
impl Sync for ShortTermMemory
impl Unpin for ShortTermMemory
impl UnsafeUnpin for ShortTermMemory
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