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
impl MessageIndex
Sourcepub fn open(path: PathBuf, embedder: Arc<dyn SearchEmbedder>) -> Result<Self>
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.
Sourcepub fn open_in_memory(embedder: Arc<dyn SearchEmbedder>) -> Result<Self>
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).
Sourcepub fn embedder(&self) -> Arc<dyn SearchEmbedder> ⓘ
pub fn embedder(&self) -> Arc<dyn SearchEmbedder> ⓘ
Snapshot the embedder (cheap Arc clone) so embedding I/O never holds a
lock.
Sourcepub async fn index_message(
&self,
message_id: &str,
conversation_id: &str,
role: &str,
embedding: &[f32],
embed_model: &str,
created_at: i64,
) -> Result<()>
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).
Sourcepub async fn indexed_ids(&self) -> Result<HashSet<String>>
pub async fn indexed_ids(&self) -> Result<HashSet<String>>
The set of message ids already indexed (used to compute the backfill set).
Sourcepub async fn search(
&self,
query: &str,
limit: usize,
conversation_ids: Option<&[String]>,
) -> Result<Vec<MessageHit>>
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
impl Clone for MessageIndex
Source§fn clone(&self) -> MessageIndex
fn clone(&self) -> MessageIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more