pub struct InMemoryConversationMemory { /* private fields */ }Expand description
Re-exports of the core memory abstractions so callers only need a single
dependency on rig-memory for both the trait/backend and the policies.
A simple thread-safe in-memory ConversationMemory backed by a HashMap.
Messages are stored in process memory only and lost on restart. Useful for
tests, examples, and short-lived agents. Pass a closure to
InMemoryConversationMemory::with_filter to apply a history-shaping
transformation on every load (truncation, summarization, re-ordering, etc.).
Reusable named policies live in the rig-memory companion crate.
Implementations§
Source§impl InMemoryConversationMemory
impl InMemoryConversationMemory
Sourcepub fn new() -> InMemoryConversationMemory
pub fn new() -> InMemoryConversationMemory
Create an empty in-memory store with no filter.
Sourcepub fn with_filter<F>(self, filter: F) -> InMemoryConversationMemorywhere
F: MessageFilter + 'static,
pub fn with_filter<F>(self, filter: F) -> InMemoryConversationMemorywhere
F: MessageFilter + 'static,
Apply filter to the loaded message list on every load.
The filter runs after raw messages are read from the store and before
they are returned to the agent. Use it for truncation, summarization, or
any other shaping. For reusable named policies, depend on rig-memory.
Trait Implementations§
Source§impl Clone for InMemoryConversationMemory
impl Clone for InMemoryConversationMemory
Source§fn clone(&self) -> InMemoryConversationMemory
fn clone(&self) -> InMemoryConversationMemory
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConversationMemory for InMemoryConversationMemory
impl ConversationMemory for InMemoryConversationMemory
Source§fn load<'a>(
&'a self,
conversation_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, MemoryError>> + Send + 'a>>
fn load<'a>( &'a self, conversation_id: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, MemoryError>> + Send + 'a>>
conversation_id. Read more