Skip to main content

MessageIndex

Struct MessageIndex 

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

sqlite-vec-backed index of chat-message embeddings. Cheap to clone (Arc inside). Stores vectors + metadata only; never message text.

Implementations§

Source§

impl MessageIndex

Source

pub fn open(path: PathBuf, embedder: Arc<dyn SearchEmbedder>) -> Result<Self>

Open (or create) the message index at path using the supplied embedder. The default db path (~/.ryu/message-embeddings.db) and the registry-driven embedder choice are resolved Core-side by the search_host shim.

Source

pub fn open_in_memory(embedder: Arc<dyn SearchEmbedder>) -> Result<Self>

Open an in-memory index with the supplied embedder at that embedder’s dims. Used by tests (both this crate’s and Core’s, via the search_host shim).

Source

pub fn embedder(&self) -> Arc<dyn SearchEmbedder>

Snapshot the embedder (cheap Arc clone) so embedding I/O never holds a lock.

Source

pub async fn index_message( &self, message_id: &str, conversation_id: &str, role: &str, embedding: &[f32], embed_model: &str, created_at: i64, ) -> Result<()>

Index a single message’s embedding. Idempotent on message_id (re-indexing replaces the prior row + vector). The embedding length must equal the table width; a mismatch is rejected (a vec0 insert would otherwise error).

Source

pub async fn indexed_ids(&self) -> Result<HashSet<String>>

The set of message ids already indexed (used to compute the backfill set).

Source

pub async fn search( &self, query: &str, limit: usize, conversation_ids: Option<&[String]>, ) -> Result<Vec<MessageHit>>

KNN search. Embeds query, runs a cosine-distance KNN over the vec0 table filtered to the current embedder’s model (incomparable vector spaces are skipped), optionally scoping to a set of conversation ids. Returns hits ordered nearest-first.

Trait Implementations§

Source§

impl Clone for MessageIndex

Source§

fn clone(&self) -> MessageIndex

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.