pub struct EmbeddingStore { /* private fields */ }Expand description
Persistent store for embeddings, backed by SQLite.
Implementations§
Source§impl EmbeddingStore
impl EmbeddingStore
Sourcepub fn new(
conn: Arc<Mutex<Connection>>,
embedder: Box<dyn Embedder>,
) -> PunchResult<Self>
pub fn new( conn: Arc<Mutex<Connection>>, embedder: Box<dyn Embedder>, ) -> PunchResult<Self>
Create a new embedding store, creating the embeddings table if it
does not already exist.
Sourcepub fn store(
&self,
text: &str,
metadata: HashMap<String, String>,
) -> PunchResult<String>
pub fn store( &self, text: &str, metadata: HashMap<String, String>, ) -> PunchResult<String>
Store text with its embedding vector.
Sourcepub fn search(
&self,
query: &str,
k: usize,
) -> PunchResult<Vec<(f32, Embedding)>>
pub fn search( &self, query: &str, k: usize, ) -> PunchResult<Vec<(f32, Embedding)>>
Search for the top-k most similar embeddings to query.
Sourcepub fn delete(&self, id: &str) -> PunchResult<()>
pub fn delete(&self, id: &str) -> PunchResult<()>
Delete an embedding by ID.
Sourcepub fn count(&self) -> PunchResult<usize>
pub fn count(&self) -> PunchResult<usize>
Return the total number of stored embeddings.
Sourcepub fn rebuild_index(&self) -> PunchResult<usize>
pub fn rebuild_index(&self) -> PunchResult<usize>
Re-embed all stored texts. Useful when the embedder changes (e.g., after re-fitting the built-in TF-IDF vocabulary).
Auto Trait Implementations§
impl Freeze for EmbeddingStore
impl !RefUnwindSafe for EmbeddingStore
impl Send for EmbeddingStore
impl Sync for EmbeddingStore
impl Unpin for EmbeddingStore
impl UnsafeUnpin for EmbeddingStore
impl !UnwindSafe for EmbeddingStore
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