pub trait BaseMemory: Send + Sync {
// Required methods
fn messages<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn add_message<'life0, 'async_trait>(
&'life0 mut self,
message: Message,
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn clear<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn add_user_message<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: &'life1 (dyn Display + Sync),
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn add_ai_message<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: &'life1 (dyn Display + Sync),
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn to_string<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Conversation memory used by chains and agents.
All methods are async and fallible so that memories can be backed by a database
or a remote service (see SqliteMessageHistory / PostgresMessageHistory).
Required Methods§
fn messages<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_message<'life0, 'async_trait>(
&'life0 mut self,
message: Message,
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Provided Methods§
fn add_user_message<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: &'life1 (dyn Display + Sync),
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_ai_message<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: &'life1 (dyn Display + Sync),
) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn to_string<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Trait Implementations§
Source§impl<M> From<M> for Box<dyn BaseMemory>where
M: BaseMemory + 'static,
impl<M> From<M> for Box<dyn BaseMemory>where
M: BaseMemory + 'static,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".