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) -> ContextItem
pub fn from_document(document: &Document) -> ContextItem
Create a new context item from a document
Sourcepub fn from_search_result(query: &str, documents: &[Document]) -> ContextItem
pub fn from_search_result(query: &str, documents: &[Document]) -> ContextItem
Create a new context item from search results
Sourcepub fn from_kg_term_definition(kg_term: &KGTermDefinition) -> ContextItem
pub fn from_kg_term_definition(kg_term: &KGTermDefinition) -> ContextItem
Create a new context item from a KG term definition
Sourcepub fn from_kg_index(kg_index: &KGIndexInfo) -> ContextItem
pub fn from_kg_index(kg_index: &KGIndexInfo) -> ContextItem
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 (const: unstable) · 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<ContextItem, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ContextItem, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for ContextItem
impl Serialize for ContextItem
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 more