pub struct ContextItem {
pub id: String,
pub context_type: ContextType,
pub title: String,
pub summary: Option<String>,
pub content: String,
pub metadata: AHashMap<String, String>,
pub created_at: DateTime<Utc>,
pub relevance_score: Option<f64>,
}Expand description
Context item that can be added to LLM conversations
Fields§
§id: StringUnique identifier for the context item
context_type: ContextTypeType of context (document, search_result, user_input, etc.)
title: StringTitle or summary of the context item
summary: Option<String>Brief summary of the content (separate from full content)
content: StringThe actual content to be included in the LLM context
metadata: AHashMap<String, String>Metadata about the context (source, relevance score, etc.)
created_at: DateTime<Utc>Timestamp when this context was added
relevance_score: Option<f64>Relevance score for ordering context items
Implementations§
Source§impl ContextItem
impl ContextItem
Sourcepub fn from_document(document: &Document) -> Self
pub fn from_document(document: &Document) -> Self
Create a new context item from a document
Sourcepub fn from_search_result(query: &str, documents: &[Document]) -> Self
pub fn from_search_result(query: &str, documents: &[Document]) -> Self
Create a new context item from search results
Sourcepub fn from_kg_term_definition(kg_term: &KGTermDefinition) -> Self
pub fn from_kg_term_definition(kg_term: &KGTermDefinition) -> Self
Create a new context item from a KG term definition
Sourcepub fn from_kg_index(kg_index: &KGIndexInfo) -> Self
pub fn from_kg_index(kg_index: &KGIndexInfo) -> Self
Create a new context item from a complete KG index
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 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