Skip to main content

EmbeddingStore

Struct EmbeddingStore 

Source
pub struct EmbeddingStore { /* private fields */ }

Implementations§

Source§

impl EmbeddingStore

Source

pub fn new(url: &str, pool: SqlitePool) -> Result<Self, MemoryError>

Create a new EmbeddingStore connected to the given Qdrant URL.

The pool is used for SQLite metadata operations on the embeddings_metadata table (which must already exist via sqlx migrations).

§Errors

Returns an error if the Qdrant client cannot be created.

Source

pub fn new_sqlite(pool: SqlitePool) -> Self

Create a new EmbeddingStore backed by SQLite for vector storage.

Uses the same pool for both vector data and metadata. No external Qdrant required.

Source

pub fn with_store(store: Box<dyn VectorStore>, pool: SqlitePool) -> Self

Source

pub async fn health_check(&self) -> bool

Source

pub async fn ensure_collection( &self, vector_size: u64, ) -> Result<(), MemoryError>

Ensure the collection exists in Qdrant with the given vector size.

Idempotent: no-op if the collection already exists.

§Errors

Returns an error if Qdrant cannot be reached or collection creation fails.

Source

pub async fn store( &self, message_id: MessageId, conversation_id: ConversationId, role: &str, vector: Vec<f32>, kind: MessageKind, model: &str, ) -> Result<String, MemoryError>

Store a vector in Qdrant and persist metadata to SQLite.

Returns the UUID of the newly created Qdrant point.

§Errors

Returns an error if the Qdrant upsert or SQLite insert fails.

Source

pub async fn search( &self, query_vector: &[f32], limit: usize, filter: Option<SearchFilter>, ) -> Result<Vec<SearchResult>, MemoryError>

Search for similar vectors in Qdrant, returning up to limit results.

§Errors

Returns an error if the Qdrant search fails.

Source

pub async fn ensure_named_collection( &self, name: &str, vector_size: u64, ) -> Result<(), MemoryError>

Ensure a named collection exists in Qdrant with the given vector size.

§Errors

Returns an error if Qdrant cannot be reached or collection creation fails.

Source

pub async fn store_to_collection( &self, collection: &str, payload: Value, vector: Vec<f32>, ) -> Result<String, MemoryError>

Store a vector in a named Qdrant collection with arbitrary payload.

Returns the UUID of the newly created point.

§Errors

Returns an error if the Qdrant upsert fails.

Source

pub async fn search_collection( &self, collection: &str, query_vector: &[f32], limit: usize, filter: Option<VectorFilter>, ) -> Result<Vec<ScoredVectorPoint>, MemoryError>

Search a named Qdrant collection, returning scored points with payloads.

§Errors

Returns an error if the Qdrant search fails.

Source

pub async fn get_vectors( &self, ids: &[MessageId], ) -> Result<HashMap<MessageId, Vec<f32>>, MemoryError>

Fetch raw vectors for the given message IDs from the SQLite vector store.

Returns an empty map when using Qdrant backend (vectors not locally stored).

§Errors

Returns an error if the SQLite query fails.

Source

pub async fn has_embedding( &self, message_id: MessageId, ) -> Result<bool, MemoryError>

Check whether an embedding already exists for the given message ID.

§Errors

Returns an error if the SQLite query fails.

Trait Implementations§

Source§

impl Debug for EmbeddingStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more