Skip to main content

VectorMemory

Struct VectorMemory 

Source
pub struct VectorMemory<E = SimpleEmbedder, S = InMemoryVectorStore> { /* private fields */ }
Expand description

Memory backend that combines recent history with semantic retrieval.

Implementations§

Source§

impl VectorMemory<SimpleEmbedder, InMemoryVectorStore>

Source

pub fn new() -> Self

Creates a vector memory with built-in components.

Source§

impl<E, S> VectorMemory<E, S>
where E: Embedder, S: VectorStore,

Source

pub fn with_components(embedder: Arc<E>, store: Arc<S>) -> Self

Creates a vector memory with custom embedder and store.

Trait Implementations§

Source§

impl<E, S> Memory for VectorMemory<E, S>
where E: Embedder, S: VectorStore,

Source§

fn store<'life0, 'life1, 'async_trait>( &'life0 mut self, key: &'life1 str, value: Message, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stores a message under a logical key.
Source§

fn retrieve<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves relevant messages for a query.
Source§

fn history<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the full conversation history.
Source§

fn clear<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clears the memory backend.
Source§

impl<E, S> SearchableMemory for VectorMemory<E, S>
where E: Embedder, S: VectorStore,

Source§

fn token_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the approximate token count for the current history.
Source§

fn search<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Semantic or lexical search over memory.

Auto Trait Implementations§

§

impl<E, S> Freeze for VectorMemory<E, S>

§

impl<E, S> RefUnwindSafe for VectorMemory<E, S>

§

impl<E, S> Send for VectorMemory<E, S>
where E: Sync + Send, S: Sync + Send,

§

impl<E, S> Sync for VectorMemory<E, S>
where E: Sync + Send, S: Sync + Send,

§

impl<E, S> Unpin for VectorMemory<E, S>

§

impl<E, S> UnsafeUnpin for VectorMemory<E, S>

§

impl<E, S> UnwindSafe for VectorMemory<E, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.