blob_artifact
Adapted from the Griptape AI Framework documentation.
Bases:
BaseArtifact
Attributes
Name | Type | Description |
---|---|---|
value | bytes | The binary data. |
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)
base64
propertymime_type
propertyvalue = 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)
- On this page
- Attributes
- to_bytes(**kwargs)
- to_text()
Could this page be better? Report a problem or suggest an addition!