pub struct ContextItem {
pub id: String,
pub context_type: ContextType,
pub content: String,
pub token_count: usize,
pub relevance: f32,
pub source: Option<String>,
pub metadata: HashMap<String, Value>,
}Expand description
A single piece of retrieved context
Fields§
§id: StringUnique identifier for this context item
context_type: ContextTypeType of context
content: StringThe actual content
token_count: usizeEstimated token count (informational)
relevance: f32Relevance score (0.0 to 1.0)
source: Option<String>Optional source URI (e.g., “viking://docs/auth”)
metadata: HashMap<String, Value>Additional metadata
Implementations§
Source§impl ContextItem
impl ContextItem
Sourcepub fn new(
id: impl Into<String>,
context_type: ContextType,
content: impl Into<String>,
) -> Self
pub fn new( id: impl Into<String>, context_type: ContextType, content: impl Into<String>, ) -> Self
Create a new context item
Sourcepub fn with_token_count(self, count: usize) -> Self
pub fn with_token_count(self, count: usize) -> Self
Set the token count
Sourcepub fn with_relevance(self, score: f32) -> Self
pub fn with_relevance(self, score: f32) -> Self
Set the relevance score
Sourcepub fn with_source(self, source: impl Into<String>) -> Self
pub fn with_source(self, source: impl Into<String>) -> Self
Set the source URI
Sourcepub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
pub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
Add metadata
Trait Implementations§
Source§impl Clone for ContextItem
impl Clone for ContextItem
Source§fn clone(&self) -> ContextItem
fn clone(&self) -> ContextItem
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextItem
impl Debug for ContextItem
Source§impl<'de> Deserialize<'de> for ContextItem
impl<'de> Deserialize<'de> for ContextItem
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ContextItem
impl RefUnwindSafe for ContextItem
impl Send for ContextItem
impl Sync for ContextItem
impl Unpin for ContextItem
impl UnsafeUnpin for ContextItem
impl UnwindSafe for ContextItem
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