pub struct VectorMemoryStore<E, V> { /* private fields */ }Expand description
A long-term memory that stores conversation turns as vector embeddings and retrieves the most relevant memories for each new query.
Implementations§
Source§impl<E, V> VectorMemoryStore<E, V>
impl<E, V> VectorMemoryStore<E, V>
Sourcepub fn new(embedder: Arc<E>, store: Arc<V>, top_k: usize) -> Self
pub fn new(embedder: Arc<E>, store: Arc<V>, top_k: usize) -> Self
Create a new VectorMemoryStore.
embedder: converts text to vectorsstore: the underlying vector storetop_k: number of memories to retrieve per query
Sourcepub fn with_memory_key(self, key: impl Into<String>) -> Self
pub fn with_memory_key(self, key: impl Into<String>) -> Self
Override the key used in the returned memory variables map.
Trait Implementations§
Source§impl<E, V> Memory for VectorMemoryStore<E, V>
impl<E, V> Memory for VectorMemoryStore<E, V>
Source§fn load_memory_variables<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Value>, WesichainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_memory_variables<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Value>, WesichainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Return key-value pairs of memory variables (e.g., chat history)
Source§fn save_context<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
inputs: &'life2 HashMap<String, Value>,
outputs: &'life3 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<(), WesichainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn save_context<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
inputs: &'life2 HashMap<String, Value>,
outputs: &'life3 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<(), WesichainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Save context from this interaction to memory
Auto Trait Implementations§
impl<E, V> Freeze for VectorMemoryStore<E, V>
impl<E, V> RefUnwindSafe for VectorMemoryStore<E, V>where
E: RefUnwindSafe,
V: RefUnwindSafe,
impl<E, V> Send for VectorMemoryStore<E, V>
impl<E, V> Sync for VectorMemoryStore<E, V>
impl<E, V> Unpin for VectorMemoryStore<E, V>
impl<E, V> UnsafeUnpin for VectorMemoryStore<E, V>
impl<E, V> UnwindSafe for VectorMemoryStore<E, V>where
E: RefUnwindSafe,
V: 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