Source Code in griptape/utils/load_artifact_from_memory.py
defload_artifact_from_memory(
memory: Optional[TaskMemory],
artifact_namespace:str,
artifact_name:str,
artifact_type:type,)-> BaseArtifact:if memory isNone:raise ValueError("memory not found")
artifacts = memory.load_artifacts(namespace=artifact_namespace)iflen(artifacts)==0:raise ValueError("no artifacts found in namespace")try:
artifact =[a for a in artifacts if a.name == artifact_name][0]except IndexError as exc:raise ValueError(f"artifact {artifact_name} not found in namespace {artifact_namespace}")from exc
ifnotisinstance(artifact, artifact_type):raise ValueError(f"{artifact.name} is not of type {artifact_type}")return artifact