artifacts
__all__ = ['ActionArtifact', 'AudioArtifact', 'AudioUrlArtifact', 'BaseArtifact', 'BlobArtifact', 'UrlArtifact', 'BooleanArtifact', 'ErrorArtifact', 'GenericArtifact', 'ImageArtifact', 'ImageUrlArtifact', 'InfoArtifact', 'JsonArtifact', 'ListArtifact', 'ModelArtifact', 'TextArtifact', 'VideoUrlArtifact']
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 = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
mime_type
property
__attrs_post_init__()
Source code in griptape/artifacts/audio_artifact.py
make_name()
to_bytes(**kwargs)
AudioUrlArtifact
BaseArtifact
Bases: SerializableMixin, ABC
Serves as the base class for all Artifacts.
Artifacts are used to encapsulate data and enhance it with metadata.
Equality compares content. id and name default to generated values, so they are left out:
two artifacts built from the same content are equal.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
The unique identifier of the Artifact. Defaults to a random UUID. |
reference |
Reference | None
|
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 on_event to use when encoding/decoding the value. |
Source code in griptape/artifacts/base_artifact.py
encoding = field(default='utf-8', kw_only=True)
class-attribute
instance-attribute
encoding_error_handler = field(default='strict', kw_only=True)
class-attribute
instance-attribute
id = field(default=Factory(lambda: uuid.uuid4().hex), kw_only=True, eq=False, metadata={'serializable': True})
class-attribute
instance-attribute
meta = field(factory=dict, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
name = field(default=Factory(lambda self: self.id, takes_self=True), kw_only=True, eq=False, metadata={'serializable': True})
class-attribute
instance-attribute
reference = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
value = field()
class-attribute
instance-attribute
__bool__()
__len__()
__str__()
to_bytes(**kwargs)
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
property
mime_type
property
value = field(converter=lambda value: value if isinstance(value, bytes) else str(value).encode(), metadata={'serializable': True})
class-attribute
instance-attribute
to_bytes(**kwargs)
BooleanArtifact
Bases: BaseArtifact
Stores a boolean value.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
bool
|
The boolean value. |
Source code in griptape/artifacts/boolean_artifact.py
__hash__ = None
class-attribute
instance-attribute
value = 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 |
Exception | None
|
The exception that caused the error. Defaults to None. |
Source code in griptape/artifacts/error_artifact.py
exception = field(default=None, kw_only=True, metadata={'serializable': False})
class-attribute
instance-attribute
value = field(converter=str, metadata={'serializable': True})
class-attribute
instance-attribute
GenericArtifact
Bases: BaseArtifact, Generic[T]
Serves as an escape hatch for artifacts that don't fit into any other category.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
T
|
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 = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
height = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
mime_type
property
width = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
__attrs_post_init__()
Source code in griptape/artifacts/image_artifact.py
make_name()
to_bytes(**kwargs)
ImageUrlArtifact
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 = field(converter=lambda value: JsonArtifact.value_to_json(value), metadata={'serializable': True})
class-attribute
instance-attribute
to_text()
ListArtifact
Bases: BaseArtifact, Generic[T_co]
Source code in griptape/artifacts/list_artifact.py
child_type
property
item_separator = field(default='\n\n', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
validate_uniform_types = field(default=False, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
value = 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
ModelArtifact
Bases: GenericArtifact[BaseModel]
Stores Pydantic models as Artifacts.
Required since Pydantic models require a custom serialization method.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
BaseModel
|
The pydantic model to store. |
Source code in griptape/artifacts/model_artifact.py
TextArtifact
Bases: BaseArtifact
Source code in griptape/artifacts/text_artifact.py
embedding = field(default=None, kw_only=True)
class-attribute
instance-attribute
value = field(converter=str, metadata={'serializable': True})
class-attribute
instance-attribute
__add__(other)
__bool__()
generate_embedding(driver)
Source code in griptape/artifacts/text_artifact.py
to_text()
UrlArtifact
Bases: BaseArtifact
Stores a url.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
str
|
The url. |
Source code in griptape/artifacts/url_artifact.py
value = field(metadata={'serializable': True})
class-attribute
instance-attribute
to_bytes(*, headers=None, **kwargs)
Fetches the content of the URL and returns it as bytes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headers
|
dict | None
|
Optional headers to include in the request. |
None
|
**kwargs
|
dict
|
Additional keyword arguments, not used. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The content of the URL as bytes. |