pub struct ContextChunk {
pub content: String,
pub source: ChunkSource,
pub relevance: f32,
pub entity_type: Option<EntityType>,
pub entity_id: Option<String>,
pub metadata: HashMap<String, Value>,
pub vector_distance: Option<f32>,
pub graph_depth: Option<u32>,
}Expand description
A single chunk of context
Fields§
§content: StringThe content of this chunk
source: ChunkSourceSource of this chunk
relevance: f32Relevance score (0.0-1.0)
entity_type: Option<EntityType>Entity type if applicable
entity_id: Option<String>Entity ID if applicable
metadata: HashMap<String, Value>Additional metadata
vector_distance: Option<f32>Distance/similarity score from vector search (if applicable)
graph_depth: Option<u32>Graph depth from query entity (if applicable)
Implementations§
Source§impl ContextChunk
impl ContextChunk
Sourcepub fn new(
content: impl Into<String>,
source: ChunkSource,
relevance: f32,
) -> ContextChunk
pub fn new( content: impl Into<String>, source: ChunkSource, relevance: f32, ) -> ContextChunk
Create a new chunk
Sourcepub fn from_vector(
content: impl Into<String>,
collection: impl Into<String>,
distance: f32,
id: u64,
) -> ContextChunk
pub fn from_vector( content: impl Into<String>, collection: impl Into<String>, distance: f32, id: u64, ) -> ContextChunk
Create from vector search result
Sourcepub fn from_graph(
content: impl Into<String>,
depth: u32,
entity_type: EntityType,
entity_id: impl Into<String>,
) -> ContextChunk
pub fn from_graph( content: impl Into<String>, depth: u32, entity_type: EntityType, entity_id: impl Into<String>, ) -> ContextChunk
Create from graph traversal
Sourcepub fn from_table(
content: impl Into<String>,
table: impl Into<String>,
row_id: u64,
relevance: f32,
) -> ContextChunk
pub fn from_table( content: impl Into<String>, table: impl Into<String>, row_id: u64, relevance: f32, ) -> ContextChunk
Create from table query
Sourcepub fn with_entity_type(self, entity_type: EntityType) -> ContextChunk
pub fn with_entity_type(self, entity_type: EntityType) -> ContextChunk
Set entity type
Sourcepub fn with_entity_id(self, id: impl Into<String>) -> ContextChunk
pub fn with_entity_id(self, id: impl Into<String>) -> ContextChunk
Set entity ID
Sourcepub fn with_metadata(self, key: impl Into<String>, value: Value) -> ContextChunk
pub fn with_metadata(self, key: impl Into<String>, value: Value) -> ContextChunk
Add metadata
Trait Implementations§
Source§impl Clone for ContextChunk
impl Clone for ContextChunk
Source§fn clone(&self) -> ContextChunk
fn clone(&self) -> ContextChunk
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ContextChunk
impl RefUnwindSafe for ContextChunk
impl Send for ContextChunk
impl Sync for ContextChunk
impl Unpin for ContextChunk
impl UnsafeUnpin for ContextChunk
impl UnwindSafe for ContextChunk
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
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