Skip to content

text_artifact_storage

TextArtifactStorage

Bases: BaseArtifactStorage

Source code in griptape/memory/task/storage/text_artifact_storage.py
@define(kw_only=True)
class TextArtifactStorage(BaseArtifactStorage):
    vector_store_driver: BaseVectorStoreDriver = field(
        default=Factory(lambda: Defaults.drivers_config.vector_store_driver)
    )

    def can_store(self, artifact: BaseArtifact) -> bool:
        return isinstance(artifact, TextArtifact)

    def store_artifact(self, namespace: str, artifact: BaseArtifact) -> None:
        if isinstance(artifact, TextArtifact):
            self.vector_store_driver.upsert(artifact, namespace=namespace)
        else:
            raise ValueError("Artifact must be of instance TextArtifact")

    def load_artifacts(self, namespace: str) -> ListArtifact:
        return self.vector_store_driver.load_artifacts(namespace=namespace)

vector_store_driver = field(default=Factory(lambda: Defaults.drivers_config.vector_store_driver)) class-attribute instance-attribute

can_store(artifact)

Source code in griptape/memory/task/storage/text_artifact_storage.py
def can_store(self, artifact: BaseArtifact) -> bool:
    return isinstance(artifact, TextArtifact)

load_artifacts(namespace)

Source code in griptape/memory/task/storage/text_artifact_storage.py
def load_artifacts(self, namespace: str) -> ListArtifact:
    return self.vector_store_driver.load_artifacts(namespace=namespace)

store_artifact(namespace, artifact)

Source code in griptape/memory/task/storage/text_artifact_storage.py
def store_artifact(self, namespace: str, artifact: BaseArtifact) -> None:
    if isinstance(artifact, TextArtifact):
        self.vector_store_driver.upsert(artifact, namespace=namespace)
    else:
        raise ValueError("Artifact must be of instance TextArtifact")