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.document.DocumentType
#
Bases: str
, Enum
Types of documents that can be stored.
ragbits.document_search.documents.element.Element
#
Bases: BaseModel
, ABC
An object representing an element in a document.
id
property
#
Retrieve the ID of the element, primarily used to represent the element's data.
RETURNS | DESCRIPTION |
---|---|
str
|
string representing element
TYPE:
|
key
property
#
Get the representation of the element for embedding.
RETURNS | DESCRIPTION |
---|---|
str | None
|
The representation for embedding. |
text_representation
abstractmethod
property
#
Get the text representation of the element.
RETURNS | DESCRIPTION |
---|---|
str | None
|
The text representation. |
get_id_components
#
Creates a dictionary of key value pairs of id components
RETURNS | DESCRIPTION |
---|---|
dict
|
a dictionary
TYPE:
|
Source code in packages/ragbits-document-search/src/ragbits/document_search/documents/element.py
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], embedding_type: EmbeddingType) -> VectorStoreEntry
Create a vector database entry from the element.
PARAMETER | DESCRIPTION |
---|---|
vector |
The vector.
TYPE:
|
embedding_type |
EmbeddingTypes
TYPE:
|
Returns: The vector database entry