pub struct ChatMessageHistory { /* private fields */ }Expand description
MemoryStore implementation backed by any Store.
Messages are stored under namespace ["memory", "{session_id}"] with key "messages".
Summaries (used by summary strategies) are stored under the same namespace with key "summary".
This replaces the old InMemoryStore (in-memory only) and FileChatMessageHistory
(file-only) with a single implementation that works with any Store backend
(InMemoryStore, FileStore, RedisStore, etc.).
Implementations§
Source§impl ChatMessageHistory
impl ChatMessageHistory
Sourcepub fn new(store: Arc<dyn Store>) -> Self
pub fn new(store: Arc<dyn Store>) -> Self
Create a new ChatMessageHistory backed by the given store.
Sourcepub async fn get_summary(
&self,
session_id: &str,
) -> Result<Option<String>, SynapticError>
pub async fn get_summary( &self, session_id: &str, ) -> Result<Option<String>, SynapticError>
Get the summary for a session (used by summary memory strategies).
Sourcepub async fn set_summary(
&self,
session_id: &str,
summary: &str,
) -> Result<(), SynapticError>
pub async fn set_summary( &self, session_id: &str, summary: &str, ) -> Result<(), SynapticError>
Set the summary for a session (used by summary memory strategies).
Trait Implementations§
Source§impl MemoryStore for ChatMessageHistory
impl MemoryStore for ChatMessageHistory
fn append<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
message: Message,
) -> Pin<Box<dyn Future<Output = Result<(), SynapticError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, SynapticError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn clear<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), SynapticError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for ChatMessageHistory
impl !RefUnwindSafe for ChatMessageHistory
impl Send for ChatMessageHistory
impl Sync for ChatMessageHistory
impl Unpin for ChatMessageHistory
impl UnsafeUnpin for ChatMessageHistory
impl !UnwindSafe for ChatMessageHistory
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