pub struct Document {
pub content: String,
pub source: Option<String>,
pub score: Option<f32>,
}Expand description
Represents a piece of retrieved content from a knowledge source.
This is typically returned by retriever agents (agents with Output = Vec<Document>).
Documents can be attached to payloads and will be formatted by PersonaAgent
into a “Retrieved Context” section in the prompt.
§Examples
use llm_toolkit::retrieval::Document;
let doc = Document {
content: "Rust is a systems programming language.".to_string(),
source: Some("rust_intro.md".to_string()),
score: Some(0.92),
};Fields§
§content: StringThe textual content of the document
source: Option<String>Optional source identifier (e.g., file path, URL, document ID)
score: Option<f32>Optional relevance or similarity score (higher = more relevant)
Implementations§
Source§impl Document
impl Document
Sourcepub fn with_source(self, source: impl Into<String>) -> Self
pub fn with_source(self, source: impl Into<String>) -> Self
Sets the source identifier for this document.
Sourcepub fn with_score(self, score: f32) -> Self
pub fn with_score(self, score: f32) -> Self
Sets the relevance score for this document.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Document
impl<'de> Deserialize<'de> for Document
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
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnwindSafe for Document
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