Documents and Elements#
ragbits.document_search.documents.document.Document
#
Bases: BaseModel
An object representing a document which is downloaded and stored locally.
from_document_meta
classmethod
#
from_document_meta(document_meta: DocumentMeta, local_path: Path) -> Document
Create a document from a document metadata. Based on the document type, it will return a different object.
PARAMETER | DESCRIPTION |
---|---|
document_meta |
The document metadata.
TYPE:
|
local_path |
The local path to the document.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Document
|
The document. |
Source code in packages/ragbits-document-search/src/ragbits/document_search/documents/document.py
ragbits.document_search.documents.element.Element
#
Bases: BaseModel
, ABC
An object representing an element in a document.
id
property
#
Get the ID of the element. The id is primarly used as a key in the vector store. The current representation is a UUID5 hash of various element metadata, including its contents and location where it was sourced from.
RETURNS | DESCRIPTION |
---|---|
str
|
The ID in the form of a UUID5 hash. |
key
property
#
Get the representation of the element for embedding.
RETURNS | DESCRIPTION |
---|---|
str
|
The representation for embedding. |
text_representation
abstractmethod
property
#
Get the text representation of the element.
RETURNS | DESCRIPTION |
---|---|
str
|
The text representation. |
from_vector_db_entry
classmethod
#
from_vector_db_entry(db_entry: VectorStoreEntry) -> Element
Create an element from a vector database entry.
PARAMETER | DESCRIPTION |
---|---|
db_entry |
The vector database entry.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
The element. |
Source code in packages/ragbits-document-search/src/ragbits/document_search/documents/element.py
to_vector_db_entry
#
to_vector_db_entry(vector: list[float]) -> VectorStoreEntry
Create a vector database entry from the element.
PARAMETER | DESCRIPTION |
---|---|
vector |
The vector.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
VectorStoreEntry
|
The vector database entry |