pub struct MemoryManager { /* private fields */ }Expand description
Unified memory manager for agents
Implementations§
Source§impl MemoryManager
impl MemoryManager
Sourcepub fn new(config: MemoryConfig) -> Result<Self, MemoryError>
pub fn new(config: MemoryConfig) -> Result<Self, MemoryError>
Create a new memory manager
Sourcepub fn remember(
&mut self,
content: impl Into<String>,
memory_type: MemoryType,
source: MemorySource,
) -> Result<MemoryId, MemoryError>
pub fn remember( &mut self, content: impl Into<String>, memory_type: MemoryType, source: MemorySource, ) -> Result<MemoryId, MemoryError>
Store a memory
Sourcepub fn remember_with_embedding(
&mut self,
content: impl Into<String>,
embedding: Embedding,
memory_type: MemoryType,
source: MemorySource,
) -> Result<MemoryId, MemoryError>
pub fn remember_with_embedding( &mut self, content: impl Into<String>, embedding: Embedding, memory_type: MemoryType, source: MemorySource, ) -> Result<MemoryId, MemoryError>
Store a memory with embedding
Sourcepub fn recall(
&mut self,
query_embedding: &Embedding,
limit: usize,
) -> Vec<SearchResult>
pub fn recall( &mut self, query_embedding: &Embedding, limit: usize, ) -> Vec<SearchResult>
Recall memories similar to a query
Sourcepub fn recall_by_type(
&self,
memory_type: MemoryType,
limit: usize,
) -> Vec<&MemoryEntry>
pub fn recall_by_type( &self, memory_type: MemoryType, limit: usize, ) -> Vec<&MemoryEntry>
Recall by type
Sourcepub fn add_document(
&mut self,
document: Document,
) -> Result<String, MemoryError>
pub fn add_document( &mut self, document: Document, ) -> Result<String, MemoryError>
Add document to knowledge base
Sourcepub fn retrieve(
&mut self,
query_embedding: &Embedding,
limit: usize,
) -> Vec<SearchResult>
pub fn retrieve( &mut self, query_embedding: &Embedding, limit: usize, ) -> Vec<SearchResult>
Retrieve from knowledge base
Sourcepub fn build_context(
&mut self,
query_embedding: &Embedding,
system_prompt: &str,
conversation: &[String],
) -> String
pub fn build_context( &mut self, query_embedding: &Embedding, system_prompt: &str, conversation: &[String], ) -> String
Build context for a prompt
Sourcepub fn cache_result(
&mut self,
key: impl Into<String>,
value: String,
ttl: Option<Duration>,
)
pub fn cache_result( &mut self, key: impl Into<String>, value: String, ttl: Option<Duration>, )
Cache a computation result
Sourcepub fn get_cached(&mut self, key: &str) -> Option<String>
pub fn get_cached(&mut self, key: &str) -> Option<String>
Get cached result
Sourcepub fn stats(&self) -> MemoryStats
pub fn stats(&self) -> MemoryStats
Get statistics
Auto Trait Implementations§
impl !Freeze for MemoryManager
impl !RefUnwindSafe for MemoryManager
impl Send for MemoryManager
impl !Sync for MemoryManager
impl Unpin 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more