blob_artifact#
Bases: BaseArtifact “)
Attributes#
Name |
Type |
Description |
|---|---|---|
<a href="blob_artifact.mdx#griptape.artifacts.blob_artifact.BlobArtifact.value" title="value = field(converter=lambda value: value if isinstance(value, bytes) else str(value).encode(), metadata={'serializable': True}) class-attribute instance-attribute (griptape.artifacts.blob_artifact.BlobArtifact.value)"><code class="language-python">value</code></a> |
bytes |
The binary data.<br/> |
Source Code in griptape/artifacts/blob_artifact.py
@define
class BlobArtifact(BaseArtifact):
"""Stores arbitrary binary data.
Attributes:
value: The binary data.
"""
value: bytes = field(
converter=lambda value: value if isinstance(value, bytes) else str(value).encode(),
metadata={"serializable": True},
)
@property
def base64(self) -> str:
return base64.b64encode(self.value).decode(self.encoding)
@property
def mime_type(self) -> str:
return "application/octet-stream"
def to_bytes(self, **kwargs) -> bytes:
return self.value
def to_text(self) -> str:
return self.value.decode(encoding=self.encoding, errors=self.encoding_error_handler)
base64propertymime_typepropertyvalue = field(converter=lambda value: value if isinstance(value, bytes) else str(value).encode(), metadata={'serializable': True})class-attribute instance-attribute
to_bytes(**kwargs)#
Source Code in griptape/artifacts/blob_artifact.py
def to_bytes(self, **kwargs) -> bytes:
return self.value
to_text()#
Source Code in griptape/artifacts/blob_artifact.py
def to_text(self) -> str:
return self.value.decode(encoding=self.encoding, errors=self.encoding_error_handler)