loaders
__all__ = ['BaseLoader', 'BaseFileLoader', 'TextLoader', 'PdfLoader', 'WebLoader', 'SqlLoader', 'CsvLoader', 'EmailLoader', 'ImageLoader', 'AudioLoader', 'BlobLoader']
module-attribute
AudioLoader
Bases: BaseFileLoader[AudioArtifact]
Loads audio content into audio artifacts.
Source code in griptape/loaders/audio_loader.py
BaseFileLoader
Bases: BaseLoader[Union[str, PathLike], bytes, A]
, ABC
Source code in griptape/loaders/base_file_loader.py
encoding: str = field(default='utf-8', kw_only=True)
class-attribute
instance-attribute
file_manager_driver: BaseFileManagerDriver = field(default=Factory(lambda: LocalFileManagerDriver(workdir=None)), kw_only=True)
class-attribute
instance-attribute
fetch(source)
Source code in griptape/loaders/base_file_loader.py
BaseLoader
Bases: FuturesExecutorMixin
, ABC
, Generic[S, F, A]
Fetches data from a source, parses it, and returns an Artifact.
Attributes:
Name | Type | Description |
---|---|---|
reference |
Optional[Reference]
|
The optional |
Source code in griptape/loaders/base_loader.py
reference: Optional[Reference] = field(default=None, kw_only=True)
class-attribute
instance-attribute
fetch(source)
abstractmethod
load(source)
load_collection(sources)
Loads a collection of sources and returns a dictionary of Artifacts.
Source code in griptape/loaders/base_loader.py
parse(data)
abstractmethod
to_key(source)
Converts the source to a key for the collection.
BlobLoader
Bases: BaseFileLoader[BlobArtifact]
Source code in griptape/loaders/blob_loader.py
CsvLoader
Bases: BaseFileLoader[ListArtifact[TextArtifact]]
Source code in griptape/loaders/csv_loader.py
delimiter: str = field(default=',', kw_only=True)
class-attribute
instance-attribute
encoding: str = field(default='utf-8', kw_only=True)
class-attribute
instance-attribute
formatter_fn: Callable[[dict], str] = field(default=lambda value: '\n'.join(f'{key}: {val}' for (key, val) in value.items()), kw_only=True)
class-attribute
instance-attribute
parse(data)
Source code in griptape/loaders/csv_loader.py
EmailLoader
Bases: BaseLoader['EmailLoader.EmailQuery', list[bytes], ListArtifact]
Source code in griptape/loaders/email_loader.py
imap_url: str = field(kw_only=True)
class-attribute
instance-attribute
password: str = field(kw_only=True)
class-attribute
instance-attribute
username: str = field(kw_only=True)
class-attribute
instance-attribute
EmailQuery
An email retrieval query.
Attributes:
Name | Type | Description |
---|---|---|
label |
str
|
Label to retrieve emails from such as 'INBOX' or 'SENT'. |
key |
Optional[str]
|
Optional key for filtering such as 'FROM' or 'SUBJECT'. |
search_criteria |
Optional[str]
|
Optional search criteria to filter emails by key. |
max_count |
Optional[int]
|
Optional max email count. |
Source code in griptape/loaders/email_loader.py
key: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
label: str = field(kw_only=True)
class-attribute
instance-attribute
max_count: Optional[int] = field(default=None, kw_only=True)
class-attribute
instance-attribute
search_criteria: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
fetch(source)
Source code in griptape/loaders/email_loader.py
parse(data)
Source code in griptape/loaders/email_loader.py
ImageLoader
Bases: BaseFileLoader[ImageArtifact]
Loads images into image artifacts.
Attributes:
Name | Type | Description |
---|---|---|
format |
Optional[str]
|
If provided, attempts to ensure image artifacts are in this format when loaded. For example, when set to 'PNG', loading image.jpg will return an ImageArtifact containing the image bytes in PNG format. |
Source code in griptape/loaders/image_loader.py
format: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
parse(data)
Source code in griptape/loaders/image_loader.py
PdfLoader
Bases: BaseFileLoader
Source code in griptape/loaders/pdf_loader.py
parse(data, *, password=None)
Source code in griptape/loaders/pdf_loader.py
SqlLoader
Bases: BaseLoader[str, list[RowResult], ListArtifact[TextArtifact]]
Source code in griptape/loaders/sql_loader.py
formatter_fn: Callable[[dict], str] = field(default=lambda value: '\n'.join(f'{key}: {val}' for (key, val) in value.items()), kw_only=True)
class-attribute
instance-attribute
sql_driver: BaseSqlDriver = field(kw_only=True)
class-attribute
instance-attribute
fetch(source)
TextLoader
Bases: BaseFileLoader[TextArtifact]
Source code in griptape/loaders/text_loader.py
encoding: str = field(default='utf-8', kw_only=True)
class-attribute
instance-attribute
WebLoader
Bases: BaseLoader[str, str, TextArtifact]