Skip to content

Meta

__all__ = ['BaseMetaEntry', 'MetaMemory', 'ActionSubtaskMetaEntry'] module-attribute

ActionSubtaskMetaEntry

Bases: BaseMetaEntry

Used to store ActionSubtask data to preserve TaskMemory pointers and context in the form of thought and action.

Attributes:

Name Type Description
thought str

CoT thought string from the LLM.

action str

ReAct action JSON string from the LLM.

answer str

tool-generated and memory-processed response from Griptape.

Source code in griptape/griptape/memory/meta/action_subtask_meta_entry.py
@define
class ActionSubtaskMetaEntry(BaseMetaEntry):
    """Used to store ActionSubtask data to preserve TaskMemory pointers and context in the form of thought and action.

    Attributes:
        thought: CoT thought string from the LLM.
        action: ReAct action JSON string from the LLM.
        answer: tool-generated and memory-processed response from Griptape.
    """

    thought: str = field(kw_only=True)
    action: str = field(kw_only=True)
    answer: str = field(kw_only=True)

    def to_dict(self) -> dict:
        from griptape.schemas import ActionSubtaskMetaEntrySchema

        return dict(ActionSubtaskMetaEntrySchema().dump(self))

action: str = field(kw_only=True) class-attribute instance-attribute

answer: str = field(kw_only=True) class-attribute instance-attribute

thought: str = field(kw_only=True) class-attribute instance-attribute

to_dict()

Source code in griptape/griptape/memory/meta/action_subtask_meta_entry.py
def to_dict(self) -> dict:
    from griptape.schemas import ActionSubtaskMetaEntrySchema

    return dict(ActionSubtaskMetaEntrySchema().dump(self))

BaseMetaEntry

Bases: ABC

Source code in griptape/griptape/memory/meta/base_meta_entry.py
@define
class BaseMetaEntry(ABC):
    def to_json(self) -> str:
        return json.dumps(self.to_dict())

    @abstractmethod
    def to_dict(self) -> dict:
        ...

to_dict() abstractmethod

Source code in griptape/griptape/memory/meta/base_meta_entry.py
@abstractmethod
def to_dict(self) -> dict:
    ...

to_json()

Source code in griptape/griptape/memory/meta/base_meta_entry.py
def to_json(self) -> str:
    return json.dumps(self.to_dict())

MetaMemory

Used to store meta entries that can be shared between tasks.

Attributes:

Name Type Description
entries list[BaseMetaEntry]

a list of meta entries for downstream tasks and subtasks to load.

Source code in griptape/griptape/memory/meta/meta_memory.py
@define
class MetaMemory:
    """Used to store meta entries that can be shared between tasks.

    Attributes:
        entries: a list of meta entries for downstream tasks and subtasks to load.
    """

    entries: list[BaseMetaEntry] = field(factory=list, kw_only=True)

    def add_entry(self, entry: BaseMetaEntry) -> None:
        self.entries.append(entry)

entries: list[BaseMetaEntry] = field(factory=list, kw_only=True) class-attribute instance-attribute

add_entry(entry)

Source code in griptape/griptape/memory/meta/meta_memory.py
def add_entry(self, entry: BaseMetaEntry) -> None:
    self.entries.append(entry)