pub struct FileChatMessageHistory { /* private fields */ }Expand description
File message history implementation, aligned with LangChain’s FileChatMessageHistory Uses JSONL format, one JSON object per line
Implementations§
Source§impl FileChatMessageHistory
impl FileChatMessageHistory
Sourcepub async fn new(session_id: String, file_path: PathBuf) -> Result<Self>
pub async fn new(session_id: String, file_path: PathBuf) -> Result<Self>
Create a new file message history instance
Sourcepub async fn save_session_history(&self) -> Result<()>
pub async fn save_session_history(&self) -> Result<()>
Save session history to file (entire session as a JSON object)
Sourcepub async fn add_user_message(&self, content: String) -> Result<()>
pub async fn add_user_message(&self, content: String) -> Result<()>
Add user message, aligned with LangChain’s add_user_message
Sourcepub async fn add_ai_message(&self, content: &str) -> Result<()>
pub async fn add_ai_message(&self, content: &str) -> Result<()>
Add AI message to history
Sourcepub async fn get_messages(&self) -> Result<Vec<ChatMessageRecord>>
pub async fn get_messages(&self) -> Result<Vec<ChatMessageRecord>>
Get all messages, aligned with LangChain’s get_messages
Trait Implementations§
Source§impl Clone for FileChatMessageHistory
impl Clone for FileChatMessageHistory
Auto Trait Implementations§
impl Freeze for FileChatMessageHistory
impl !RefUnwindSafe for FileChatMessageHistory
impl Send for FileChatMessageHistory
impl Sync for FileChatMessageHistory
impl Unpin for FileChatMessageHistory
impl !UnwindSafe for FileChatMessageHistory
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