boolean_artifact
Adapted from the Griptape AI Framework documentation.
Bases:
BaseArtifact
Attributes
Name | Type | Description |
---|---|---|
value | bool | The boolean value. |
Source Code in griptape/artifacts/boolean_artifact.py
@define class BooleanArtifact(BaseArtifact): """Stores a boolean value. Attributes: value: The boolean value. """ value: bool = field(converter=bool, metadata={"serializable": True}) @classmethod def parse_bool(cls, value: Union[str, bool]) -> BooleanArtifact: """Convert a string literal or bool to a BooleanArtifact. The string must be either "true" or "false".""" if value is not None: if isinstance(value, str): if value.lower() == "true": return BooleanArtifact(value=True) if value.lower() == "false": return BooleanArtifact(value=False) elif isinstance(value, bool): return BooleanArtifact(value) raise ValueError(f"Cannot convert '{value}' to BooleanArtifact") def __add__(self, other: BaseArtifact) -> BooleanArtifact: raise ValueError("Cannot add BooleanArtifact with other artifacts") def __eq__(self, value: object) -> bool: return self.value == value def to_text(self) -> str: return str(self.value).lower()
value = field(converter=bool, metadata={'serializable': True})
class-attribute instance-attribute
add(other)
Source Code in griptape/artifacts/boolean_artifact.py
def __add__(self, other: BaseArtifact) -> BooleanArtifact: raise ValueError("Cannot add BooleanArtifact with other artifacts")
eq(value)
Source Code in griptape/artifacts/boolean_artifact.py
def __eq__(self, value: object) -> bool: return self.value == value
parse_bool(value)classmethod
Source Code in griptape/artifacts/boolean_artifact.py
@classmethod def parse_bool(cls, value: Union[str, bool]) -> BooleanArtifact: """Convert a string literal or bool to a BooleanArtifact. The string must be either "true" or "false".""" if value is not None: if isinstance(value, str): if value.lower() == "true": return BooleanArtifact(value=True) if value.lower() == "false": return BooleanArtifact(value=False) elif isinstance(value, bool): return BooleanArtifact(value) raise ValueError(f"Cannot convert '{value}' to BooleanArtifact")
to_text()
Source Code in griptape/artifacts/boolean_artifact.py
def to_text(self) -> str: return str(self.value).lower()
Could this page be better? Report a problem or suggest an addition!