pub struct ConversationStore { /* private fields */ }Expand description
Manages conversation threads and their messages.
Implementations§
Source§impl ConversationStore
impl ConversationStore
Sourcepub fn create_conversation(
&self,
id: &str,
title: Option<&str>,
metadata: Option<Value>,
) -> Result<()>
pub fn create_conversation( &self, id: &str, title: Option<&str>, metadata: Option<Value>, ) -> Result<()>
Create a new conversation. The id must be unique; use
uuid::Uuid::new_v4().to_string() if you do not have a stable ID.
Sourcepub fn add_message(
&self,
conversation_id: &str,
role: &str,
content: &str,
metadata: Option<Value>,
) -> Result<String>
pub fn add_message( &self, conversation_id: &str, role: &str, content: &str, metadata: Option<Value>, ) -> Result<String>
Append a message to an existing conversation.
Returns the newly generated message ID.
Sourcepub fn get_messages(
&self,
conversation_id: &str,
limit: Option<usize>,
) -> Result<Vec<Message>>
pub fn get_messages( &self, conversation_id: &str, limit: Option<usize>, ) -> Result<Vec<Message>>
Return messages for a conversation in chronological order.
If limit is Some(n) only the most-recent n messages are returned
(still in ascending chronological order). Pass None for all messages.
Sourcepub fn list_conversations(&self) -> Result<Vec<Conversation>>
pub fn list_conversations(&self) -> Result<Vec<Conversation>>
List all conversations ordered by most-recently updated first.
Sourcepub fn delete_conversation(&self, id: &str) -> Result<()>
pub fn delete_conversation(&self, id: &str) -> Result<()>
Delete a conversation and all its messages (via ON DELETE CASCADE).
Auto Trait Implementations§
impl Freeze for ConversationStore
impl RefUnwindSafe for ConversationStore
impl Send for ConversationStore
impl Sync for ConversationStore
impl Unpin for ConversationStore
impl UnsafeUnpin for ConversationStore
impl UnwindSafe for ConversationStore
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