Struct langchain_rust::schemas::document::Document
source · pub struct Document {
pub page_content: String,
pub metadata: HashMap<String, Value>,
pub score: f64,
}
Expand description
The Document
struct represents a document with content, metadata, and a score.
The page_content
field is a string that contains the content of the document.
The metadata
field is a HashMap
where the keys represent metadata properties and the values represent property values.
The score
field represents a relevance score for the document and is a floating point number.
§Usage
ⓘ
let my_doc = Document::new("This is the document content.".to_string())
.with_metadata({
let mut metadata = HashMap::new();
metadata.insert("author".to_string(), json!("John Doe"));
metadata
})
.with_score(0.75);
Fields§
§page_content: String
§metadata: HashMap<String, Value>
§score: f64
Implementations§
source§impl Document
impl Document
sourcepub fn new<S: Into<String>>(page_content: S) -> Self
pub fn new<S: Into<String>>(page_content: S) -> Self
Constructs a new Document
with provided page_content
, an empty metadata
map and a score
of 0.
sourcepub fn with_metadata(self, metadata: HashMap<String, Value>) -> Self
pub fn with_metadata(self, metadata: HashMap<String, Value>) -> Self
Sets the metadata
Map of the Document
to the provided HashMap.
sourcepub fn with_score(self, score: f64) -> Self
pub fn with_score(self, score: f64) -> Self
Sets the score
of the Document
to the provided float.
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
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