artifacts
__all__ = ['BaseArtifact', 'ErrorArtifact', 'InfoArtifact', 'TextArtifact', 'JsonArtifact', 'BlobArtifact', 'BooleanArtifact', 'ListArtifact', 'ImageArtifact', 'AudioArtifact', 'ActionArtifact', 'GenericArtifact']
module-attribute
ActionArtifact
Bases: BaseArtifact
Represents the LLM taking an action to use a Tool.
Attributes:
Name | Type | Description |
---|---|---|
value |
ToolAction
|
The Action to take. Currently only supports ToolAction. |
Source code in griptape/artifacts/action_artifact.py
AudioArtifact
Bases: BlobArtifact
Stores audio data.
Attributes:
Name | Type | Description |
---|---|---|
format |
str
|
The audio format, e.g. "wav" or "mp3". |
Source code in griptape/artifacts/audio_artifact.py
format: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
mime_type: str
property
to_bytes()
BaseArtifact
Bases: SerializableMixin
, ABC
Serves as the base class for all Artifacts.
Artifacts are used to encapsulate data and enhance it with metadata.
Attributes:
Name | Type | Description |
---|---|---|
id |
str
|
The unique identifier of the Artifact. Defaults to a random UUID. |
reference |
Optional[Reference]
|
The optional Reference to the Artifact. |
meta |
dict[str, Any]
|
The metadata associated with the Artifact. Defaults to an empty dictionary. |
name |
str
|
The name of the Artifact. Defaults to the id. |
value |
Any
|
The value of the Artifact. |
encoding |
str
|
The encoding to use when encoding/decoding the value. |
encoding_error_handler |
str
|
The error handler to use when encoding/decoding the value. |
Source code in griptape/artifacts/base_artifact.py
encoding: str = field(default='utf-8', kw_only=True)
class-attribute
instance-attribute
encoding_error_handler: str = field(default='strict', kw_only=True)
class-attribute
instance-attribute
id: str = field(default=Factory(lambda: uuid.uuid4().hex), kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
meta: dict[str, Any] = field(factory=dict, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
name: str = field(default=Factory(lambda self: self.id, takes_self=True), kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
reference: Optional[Reference] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
value: Any = field()
class-attribute
instance-attribute
__bool__()
__len__()
__str__()
to_bytes()
BlobArtifact
Bases: BaseArtifact
Stores arbitrary binary data.
Attributes:
Name | Type | Description |
---|---|---|
value |
bytes
|
The binary data. |
Source code in griptape/artifacts/blob_artifact.py
base64: str
property
mime_type: str
property
value: bytes = field(converter=lambda value: value if isinstance(value, bytes) else str(value).encode(), metadata={'serializable': True})
class-attribute
instance-attribute
to_bytes()
BooleanArtifact
Bases: BaseArtifact
Stores a boolean value.
Attributes:
Name | Type | Description |
---|---|---|
value |
bool
|
The boolean value. |
Source code in griptape/artifacts/boolean_artifact.py
value: bool = field(converter=bool, metadata={'serializable': True})
class-attribute
instance-attribute
__add__(other)
__eq__(value)
parse_bool(value)
classmethod
Convert a string literal or bool to a BooleanArtifact. The string must be either "true" or "false".
Source code in griptape/artifacts/boolean_artifact.py
ErrorArtifact
Bases: BaseArtifact
Represents an error that may want to be conveyed to the LLM.
Attributes:
Name | Type | Description |
---|---|---|
value |
str
|
The error message. |
exception |
Optional[Exception]
|
The exception that caused the error. Defaults to None. |
Source code in griptape/artifacts/error_artifact.py
exception: Optional[Exception] = field(default=None, kw_only=True, metadata={'serializable': False})
class-attribute
instance-attribute
value: str = field(converter=str, metadata={'serializable': True})
class-attribute
instance-attribute
GenericArtifact
Bases: BaseArtifact
Serves as an escape hatch for artifacts that don't fit into any other category.
Attributes:
Name | Type | Description |
---|---|---|
value |
Any
|
The value of the Artifact. |
Source code in griptape/artifacts/generic_artifact.py
ImageArtifact
Bases: BlobArtifact
Stores image data.
Attributes:
Name | Type | Description |
---|---|---|
format |
str
|
The format of the image data. Used when building the MIME type. |
width |
int
|
The width of the image. |
height |
int
|
The height of the image |
Source code in griptape/artifacts/image_artifact.py
format: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
height: int = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
mime_type: str
property
width: int = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
to_bytes()
InfoArtifact
Bases: BaseArtifact
Represents helpful info that can be conveyed to the LLM.
For example, "No results found" or "Please try again.".
Attributes:
Name | Type | Description |
---|---|---|
value |
str
|
The info to convey. |
Source code in griptape/artifacts/info_artifact.py
JsonArtifact
Bases: BaseArtifact
Stores JSON data.
Attributes:
Name | Type | Description |
---|---|---|
value |
Json
|
The JSON data. Values will automatically be converted to a JSON-compatible format. |
Source code in griptape/artifacts/json_artifact.py
value: Json = field(converter=lambda value: JsonArtifact.value_to_json(value), metadata={'serializable': True})
class-attribute
instance-attribute
to_text()
ListArtifact
Bases: BaseArtifact
, Generic[T]
Source code in griptape/artifacts/list_artifact.py
child_type: Optional[type]
property
item_separator: str = field(default='\n\n', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
validate_uniform_types: bool = field(default=False, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
value: Sequence[T] = field(factory=list, metadata={'serializable': True})
class-attribute
instance-attribute
__add__(other)
__bool__()
__getitem__(key)
__iter__()
has_items()
is_type(target_type)
to_text()
validate_value(_, value)
Source code in griptape/artifacts/list_artifact.py
TextArtifact
Bases: BaseArtifact