Skip to content

base_message_content

BaseMessageContent

Bases: ABC, SerializableMixin

Source code in griptape/common/prompt_stack/contents/base_message_content.py
@define
class BaseMessageContent(ABC, SerializableMixin):
    artifact: BaseArtifact = field(metadata={"serializable": True})

    def __str__(self) -> str:
        return self.artifact.to_text()

    def __bool__(self) -> bool:
        return bool(self.artifact)

    def __len__(self) -> int:
        return len(self.artifact)

    def to_text(self) -> str:
        return str(self.artifact)

    @classmethod
    @abstractmethod
    def from_deltas(cls, deltas: Sequence[BaseDeltaMessageContent]) -> BaseMessageContent: ...

artifact: BaseArtifact = field(metadata={'serializable': True}) class-attribute instance-attribute

__bool__()

Source code in griptape/common/prompt_stack/contents/base_message_content.py
def __bool__(self) -> bool:
    return bool(self.artifact)

__len__()

Source code in griptape/common/prompt_stack/contents/base_message_content.py
def __len__(self) -> int:
    return len(self.artifact)

__str__()

Source code in griptape/common/prompt_stack/contents/base_message_content.py
def __str__(self) -> str:
    return self.artifact.to_text()

from_deltas(deltas) abstractmethod classmethod

Source code in griptape/common/prompt_stack/contents/base_message_content.py
@classmethod
@abstractmethod
def from_deltas(cls, deltas: Sequence[BaseDeltaMessageContent]) -> BaseMessageContent: ...

to_text()

Source code in griptape/common/prompt_stack/contents/base_message_content.py
def to_text(self) -> str:
    return str(self.artifact)