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.
The INSERT and the updated_at bump run inside a single lock acquisition so a crash between the two operations cannot leave a stale timestamp.
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).
Sourcepub fn search_messages(
&self,
query: &str,
top_k: usize,
conversation_id: Option<&str>,
) -> Result<Vec<MessageSearchResult>>
pub fn search_messages( &self, query: &str, top_k: usize, conversation_id: Option<&str>, ) -> Result<Vec<MessageSearchResult>>
Full-text search over all message content.
Returns up to top_k results ranked by BM25 relevance.
Optionally filter to a single conversation with conversation_id.