model_artifact

Bases: GenericArtifact[BaseModel]

Attributes

NameTypeDescription
valueBaseModelThe pydantic model to store.
Source Code in griptape/artifacts/model_artifact.py
@define
class ModelArtifact(GenericArtifact[BaseModel]):
    """Stores Pydantic models as Artifacts.

    Required since Pydantic models require a custom serialization method.

    Attributes:
        value: The pydantic model to store.
    """

    # We must explicitly define the type rather than rely on the parent T since
    # generic type information is lost at runtime.
    value: BaseModel = field(metadata={"serializable": True})

    def to_text(self) -> str:
        return self.value.model_dump_json()
  • value = field(metadata={'serializable': True}) class-attribute instance-attribute

to_text()

Source Code in griptape/artifacts/model_artifact.py
def to_text(self) -> str:
    return self.value.model_dump_json()

Could this page be better? Report a problem or suggest an addition!