pub struct RetrievalContext {
pub query: String,
pub chunks: Vec<ContextChunk>,
pub overall_relevance: f32,
pub sources_used: Vec<ChunkSource>,
pub retrieval_time_us: u64,
pub explanation: Option<String>,
}Expand description
Complete context retrieved for a query
Fields§
§query: StringOriginal query
chunks: Vec<ContextChunk>Retrieved context chunks
overall_relevance: f32Overall relevance score
sources_used: Vec<ChunkSource>Sources used in retrieval
retrieval_time_us: u64Total retrieval time in microseconds
explanation: Option<String>Explanation of retrieval strategy
Implementations§
Source§impl RetrievalContext
impl RetrievalContext
Sourcepub fn add_chunk(&mut self, chunk: ContextChunk)
pub fn add_chunk(&mut self, chunk: ContextChunk)
Add a chunk to the context
Sourcepub fn sort_by_relevance(&mut self)
pub fn sort_by_relevance(&mut self)
Sort chunks by relevance (descending)
Sourcepub fn calculate_overall_relevance(&mut self)
pub fn calculate_overall_relevance(&mut self)
Calculate overall relevance from chunks
Sourcepub fn chunks_for_type(&self, entity_type: EntityType) -> Vec<&ContextChunk>
pub fn chunks_for_type(&self, entity_type: EntityType) -> Vec<&ContextChunk>
Get chunks for a specific entity type
Sourcepub fn chunks_from_source(&self, source: &ChunkSource) -> Vec<&ContextChunk>
pub fn chunks_from_source(&self, source: &ChunkSource) -> Vec<&ContextChunk>
Get chunks from a specific source
Sourcepub fn top_chunk(&self) -> Option<&ContextChunk>
pub fn top_chunk(&self) -> Option<&ContextChunk>
Get the top chunk
Sourcepub fn to_context_string(&self) -> String
pub fn to_context_string(&self) -> String
Convert to a text representation for LLM context
Sourcepub fn entity_ids(&self) -> Vec<&str>
pub fn entity_ids(&self) -> Vec<&str>
Get entity IDs mentioned in the context
Sourcepub fn merge(&mut self, other: RetrievalContext)
pub fn merge(&mut self, other: RetrievalContext)
Merge another context into this one
Sourcepub fn with_explanation(self, explanation: impl Into<String>) -> Self
pub fn with_explanation(self, explanation: impl Into<String>) -> Self
Set explanation
Trait Implementations§
Source§impl Clone for RetrievalContext
impl Clone for RetrievalContext
Auto Trait Implementations§
impl Forget for RetrievalContext
impl Freeze for RetrievalContextwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<ContextChunk>: Freeze,
PhantomData<ChunkSource>: Freeze,
impl Move for RetrievalContext
impl RefUnwindSafe for RetrievalContext
impl Send for RetrievalContext
impl Sync for RetrievalContext
impl Unpin for RetrievalContext
impl UnsafeUnpin for RetrievalContextwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<ContextChunk>: UnsafeUnpin,
PhantomData<ChunkSource>: UnsafeUnpin,
impl UnwindSafe for RetrievalContext
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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 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>
Wrap the input message
T in a tonic::Request