Skip to content

Load artifact from memory

load_artifact_from_memory(memory, artifact_namespace, artifact_name, artifact_type)

Source code in griptape/utils/
def load_artifact_from_memory(
    memory: TaskMemory, artifact_namespace: str, artifact_name: str, artifact_type: type
) -> BaseArtifact:
    if memory is None:
        raise ValueError("memory not found")

    artifacts = memory.load_artifacts(namespace=artifact_namespace)
    if len(artifacts) == 0:
        raise ValueError("no artifacts found in namespace")

        artifact = [a for a in artifacts if == artifact_name][0]
    except IndexError:
        raise ValueError(f"artifact {artifact_name} not found in namespace {artifact_namespace}")

    if not isinstance(artifact, artifact_type):
        raise ValueError(f"{} is not of type {artifact_type}")

    return artifact