pub struct SemanticMemory<S: VectorStore, E: Embedder> { /* private fields */ }Expand description
Semantic memory for agents using vector store
Implementations§
Source§impl<S: VectorStore, E: Embedder> SemanticMemory<S, E>
impl<S: VectorStore, E: Embedder> SemanticMemory<S, E>
pub fn new(store: S, embedder: E, agent_id: impl Into<String>) -> Self
Sourcepub async fn remember(
&self,
content: &str,
tags: Option<Vec<String>>,
) -> Result<(), MemoryError>
pub async fn remember( &self, content: &str, tags: Option<Vec<String>>, ) -> Result<(), MemoryError>
Remember a piece of information
Sourcepub async fn recall(
&self,
query: &str,
top_k: usize,
) -> Result<Vec<SearchResult>, MemoryError>
pub async fn recall( &self, query: &str, top_k: usize, ) -> Result<Vec<SearchResult>, MemoryError>
Recall relevant memories for a query
Sourcepub async fn get_context(
&self,
query: &str,
top_k: usize,
) -> Result<String, MemoryError>
pub async fn get_context( &self, query: &str, top_k: usize, ) -> Result<String, MemoryError>
Get formatted context for a query
Auto Trait Implementations§
impl<S, E> Freeze for SemanticMemory<S, E>
impl<S, E> RefUnwindSafe for SemanticMemory<S, E>where
S: RefUnwindSafe,
E: RefUnwindSafe,
impl<S, E> Send for SemanticMemory<S, E>
impl<S, E> Sync for SemanticMemory<S, E>
impl<S, E> Unpin for SemanticMemory<S, E>
impl<S, E> UnsafeUnpin for SemanticMemory<S, E>
impl<S, E> UnwindSafe for SemanticMemory<S, E>where
S: RefUnwindSafe,
E: RefUnwindSafe,
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