pub struct ContextStore<B: StorageBackend> { /* private fields */ }Expand description
Context store for embedding storage and retrieval
Implementations§
Source§impl<B: StorageBackend> ContextStore<B>
impl<B: StorageBackend> ContextStore<B>
Sourcepub fn new(backend: Arc<B>, table_name: &str, embedding_dim: i32) -> Self
pub fn new(backend: Arc<B>, table_name: &str, embedding_dim: i32) -> Self
Create a new context store
Sourcepub fn with_defaults(backend: Arc<B>, table_name: &str) -> Self
pub fn with_defaults(backend: Arc<B>, table_name: &str) -> Self
Create with default embedding dimension (768)
Sourcepub async fn store(&self, record: ContextRecord) -> Result<(), Status>
pub async fn store(&self, record: ContextRecord) -> Result<(), Status>
Store a single context record
Sourcepub async fn store_batch(&self, records: &[ContextRecord]) -> Result<(), Status>
pub async fn store_batch(&self, records: &[ContextRecord]) -> Result<(), Status>
Store multiple context records in a batch
Sourcepub async fn recent_by_session(
&self,
session_id: &str,
limit: usize,
) -> Result<Vec<String>, Status>
pub async fn recent_by_session( &self, session_id: &str, limit: usize, ) -> Result<Vec<String>, Status>
Get recent context by session (CAG - no semantic search)
Sourcepub async fn recent_by_model(
&self,
model_id: &str,
min_quality: Option<f64>,
limit: usize,
) -> Result<Vec<String>, Status>
pub async fn recent_by_model( &self, model_id: &str, min_quality: Option<f64>, limit: usize, ) -> Result<Vec<String>, Status>
Get recent context by model with quality filter
Sourcepub async fn search(
&self,
query_embedding: &[f32],
limit: usize,
min_quality: Option<f64>,
) -> Result<Vec<SearchResult>, Status>
pub async fn search( &self, query_embedding: &[f32], limit: usize, min_quality: Option<f64>, ) -> Result<Vec<SearchResult>, Status>
Similarity search using cosine similarity
This loads all embeddings and computes similarity in-memory. For large datasets, consider using an external vector database via ADBC.
Sourcepub async fn cleanup_before(&self, timestamp: i64) -> Result<usize, Status>
pub async fn cleanup_before(&self, timestamp: i64) -> Result<usize, Status>
Delete old context entries
Auto Trait Implementations§
impl<B> Freeze for ContextStore<B>
impl<B> RefUnwindSafe for ContextStore<B>where
B: RefUnwindSafe,
impl<B> Send for ContextStore<B>
impl<B> Sync for ContextStore<B>
impl<B> Unpin for ContextStore<B>
impl<B> UnsafeUnpin for ContextStore<B>
impl<B> UnwindSafe for ContextStore<B>where
B: RefUnwindSafe,
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more