pub struct QueryBuilder<'a> { /* private fields */ }Expand description
Per-call builder returned by Client::query.
Awaiting the builder retrieves candidate memories via vector search,
re-ranks them using the configured RankingStrategy (default:
RankingStrategy::default_hybrid), and returns a MemoryContext
suitable for dropping into a system prompt.
The default ranking parameters may drift pre-1.0. Callers who need
stable behavior across memoir-core versions should pass an explicit
RankingStrategy::Hybrid { .. } via Self::ranking.
Kind toggles (episodic/semantic) and metadata/time-range filters
match crate::client::SearchBuilder’s shape and semantics.
§Examples
let context = client.query("what did the user say about deployments?", scope).await?;
println!("{context}");Opt into an explicit strategy:
let context = client
.query("recent deployments", scope)
.ranking(RankingStrategy::Hybrid {
alpha: 0.5,
decay: DecayFn::Exponential { half_life: chrono::Duration::days(3) },
})
.await?;Implementations§
Source§impl<'a> QueryBuilder<'a>
impl<'a> QueryBuilder<'a>
Sourcepub fn limit(self, limit: usize) -> Self
pub fn limit(self, limit: usize) -> Self
Caps the number of returned memories. Defaults to DEFAULT_QUERY_LIMIT.
Sourcepub fn episodic(self) -> Self
pub fn episodic(self) -> Self
Restricts retrieval to episodic memories. See crate::client::SearchBuilder for kind-toggle semantics.
Sourcepub fn semantic(self) -> Self
pub fn semantic(self) -> Self
Restricts retrieval to semantic memories. See crate::client::SearchBuilder for kind-toggle semantics.
Sourcepub fn metadata_filter(self, filter: MemoryFilter) -> Self
pub fn metadata_filter(self, filter: MemoryFilter) -> Self
Applies a caller-supplied metadata filter alongside the scope+kind filter.
Sourcepub fn min_similarity(self, threshold: f32) -> Self
pub fn min_similarity(self, threshold: f32) -> Self
Drops candidates whose raw cosine score is below threshold.
Sourcepub fn created_after(self, at: impl Into<DateTime<FixedOffset>>) -> Self
pub fn created_after(self, at: impl Into<DateTime<FixedOffset>>) -> Self
Restricts to memories written at or after at (inclusive).
Sourcepub fn created_before(self, at: impl Into<DateTime<FixedOffset>>) -> Self
pub fn created_before(self, at: impl Into<DateTime<FixedOffset>>) -> Self
Restricts to memories written strictly before at (exclusive).
Sourcepub fn event_at_after(self, at: impl Into<DateTime<FixedOffset>>) -> Self
pub fn event_at_after(self, at: impl Into<DateTime<FixedOffset>>) -> Self
Restricts to memories whose event_at is at or after at (inclusive).
Sourcepub fn event_at_before(self, at: impl Into<DateTime<FixedOffset>>) -> Self
pub fn event_at_before(self, at: impl Into<DateTime<FixedOffset>>) -> Self
Restricts to memories whose event_at is strictly before at (exclusive).
Sourcepub fn ranking(self, strategy: RankingStrategy) -> Self
pub fn ranking(self, strategy: RankingStrategy) -> Self
Selects the ranking strategy. Defaults to RankingStrategy::default_hybrid.
Trait Implementations§
Source§impl<'a> IntoFuture for QueryBuilder<'a>
impl<'a> IntoFuture for QueryBuilder<'a>
Source§type Output = Result<MemoryContext, ClientError>
type Output = Result<MemoryContext, ClientError>
Source§type IntoFuture = Pin<Box<dyn Future<Output = <QueryBuilder<'a> as IntoFuture>::Output> + Send + 'a>>
type IntoFuture = Pin<Box<dyn Future<Output = <QueryBuilder<'a> as IntoFuture>::Output> + Send + 'a>>
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for QueryBuilder<'a>
impl<'a> !UnwindSafe for QueryBuilder<'a>
impl<'a> Freeze for QueryBuilder<'a>
impl<'a> Send for QueryBuilder<'a>
impl<'a> Sync for QueryBuilder<'a>
impl<'a> Unpin for QueryBuilder<'a>
impl<'a> UnsafeUnpin for QueryBuilder<'a>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request