pub struct MemoryManager { /* private fields */ }Expand description
Memory manager orchestrates short-term and long-term memory
Implementations§
Source§impl MemoryManager
impl MemoryManager
Sourcepub fn new(
config: MemoryConfig,
store: Arc<dyn MemoryStore>,
embedder: Arc<dyn EmbeddingProvider>,
) -> Self
pub fn new( config: MemoryConfig, store: Arc<dyn MemoryStore>, embedder: Arc<dyn EmbeddingProvider>, ) -> Self
Create a new memory manager
Sourcepub fn with_defaults(
store: Arc<dyn MemoryStore>,
embedder: Arc<dyn EmbeddingProvider>,
) -> Self
pub fn with_defaults( store: Arc<dyn MemoryStore>, embedder: Arc<dyn EmbeddingProvider>, ) -> Self
Create with default configuration
Sourcepub async fn remember(
&mut self,
content: &str,
memory_type: MemoryType,
) -> Result<String>
pub async fn remember( &mut self, content: &str, memory_type: MemoryType, ) -> Result<String>
Store a memory
Sourcepub async fn remember_important(
&mut self,
content: &str,
memory_type: MemoryType,
importance: f32,
) -> Result<String>
pub async fn remember_important( &mut self, content: &str, memory_type: MemoryType, importance: f32, ) -> Result<String>
Store a memory with importance
Sourcepub async fn recall(&self, query: &str) -> Result<Vec<MemoryEntry>>
pub async fn recall(&self, query: &str) -> Result<Vec<MemoryEntry>>
Recall relevant memories for a query
Sourcepub fn build_context(&self, memories: &[MemoryEntry]) -> String
pub fn build_context(&self, memories: &[MemoryEntry]) -> String
Build context string from memories
Sourcepub async fn recall_context(&self, query: &str) -> Result<String>
pub async fn recall_context(&self, query: &str) -> Result<String>
Recall and build context in one step
Sourcepub fn short_term(&self) -> &RingBuffer<MemoryEntry>
pub fn short_term(&self) -> &RingBuffer<MemoryEntry>
Get short-term memory buffer
Sourcepub fn store(&self) -> &Arc<dyn MemoryStore>
pub fn store(&self) -> &Arc<dyn MemoryStore>
Get memory store
Sourcepub fn clear_short_term(&mut self)
pub fn clear_short_term(&mut self)
Clear short-term memory
Auto Trait Implementations§
impl Freeze for MemoryManager
impl !RefUnwindSafe for MemoryManager
impl Send for MemoryManager
impl Sync for MemoryManager
impl Unpin for MemoryManager
impl UnsafeUnpin for MemoryManager
impl !UnwindSafe for MemoryManager
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