model_artifact
Adapted from the Griptape AI Framework documentation.
Bases:
GenericArtifact[BaseModel]
Attributes
Name | Type | Description |
---|---|---|
value | BaseModel | The 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()
- On this page
- Attributes
- to_text()
Could this page be better? Report a problem or suggest an addition!