Skip to main content

ConversationStore

Struct ConversationStore 

Source
pub struct ConversationStore { /* private fields */ }
Expand description

Manages conversation threads and their messages.

Implementations§

Source§

impl ConversationStore

Source

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.

Source

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.

Source

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.

Source

pub fn list_conversations(&self) -> Result<Vec<Conversation>>

List all conversations ordered by most-recently updated first.

Source

pub fn delete_conversation(&self, id: &str) -> Result<()>

Delete a conversation and all its messages (via ON DELETE CASCADE).

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.