Skip to content

Schemas

__all__ = ['BaseSchema', 'PolymorphicSchema', 'Bytes', 'BaseArtifactSchema', 'InfoArtifactSchema', 'TextArtifactSchema', 'ErrorArtifactSchema', 'BlobArtifactSchema', 'CsvRowArtifactSchema', 'ListArtifactSchema', 'ImageArtifactSchema', 'RunSchema', 'ConversationMemorySchema', 'SummaryConversationMemorySchema', 'ActionSubtaskMetaEntrySchema', 'BaseEventSchema', 'BaseTaskEventSchema', 'BaseActionSubtaskEventSchema', 'StartTaskEventSchema', 'FinishTaskEventSchema', 'StartActionSubtaskEventSchema', 'FinishActionSubtaskEventSchema', 'BasePromptEventSchema', 'StartPromptEventSchema', 'FinishPromptEventSchema', 'StartStructureRunEventSchema', 'FinishStructureRunEventSchema', 'CompletionChunkEventSchema', 'PromptStackSchema', 'PromptStackInputSchema', 'StartImageGenerationEventSchema', 'FinishImageGenerationEventSchema'] module-attribute

ActionSubtaskMetaEntrySchema

Bases: BaseSchema

Source code in griptape/griptape/schemas/memory/meta/action_subtask_meta_entry_schema.py
class ActionSubtaskMetaEntrySchema(BaseSchema):
    thought = fields.Str()
    action = fields.Str()
    answer = fields.Str()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.memory.meta import ActionSubtaskMetaEntry

        return ActionSubtaskMetaEntry(**data)

action = fields.Str() class-attribute instance-attribute

answer = fields.Str() class-attribute instance-attribute

thought = fields.Str() class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/memory/meta/action_subtask_meta_entry_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.memory.meta import ActionSubtaskMetaEntry

    return ActionSubtaskMetaEntry(**data)

BaseActionSubtaskEventSchema

Bases: BaseTaskEventSchema

Source code in griptape/griptape/schemas/events/base_action_subtask_event_schema.py
class BaseActionSubtaskEventSchema(BaseTaskEventSchema):
    subtask_parent_task_id = fields.Str()
    subtask_thought = fields.Str()
    subtask_action_name = fields.Str()
    subtask_action_path = fields.Str()
    subtask_action_input = fields.Dict()

subtask_action_input = fields.Dict() class-attribute instance-attribute

subtask_action_name = fields.Str() class-attribute instance-attribute

subtask_action_path = fields.Str() class-attribute instance-attribute

subtask_parent_task_id = fields.Str() class-attribute instance-attribute

subtask_thought = fields.Str() class-attribute instance-attribute

BaseArtifactSchema

Bases: BaseSchema

Source code in griptape/griptape/schemas/artifacts/artifact_schema.py
class BaseArtifactSchema(BaseSchema):
    id = fields.Str()
    name = fields.Str()
    meta = fields.Dict(keys=fields.Str())
    type = fields.Str()

    @abstractmethod
    def make_obj(self, data, **kwargs):
        ...

id = fields.Str() class-attribute instance-attribute

meta = fields.Dict(keys=fields.Str()) class-attribute instance-attribute

name = fields.Str() class-attribute instance-attribute

type = fields.Str() class-attribute instance-attribute

make_obj(data, **kwargs) abstractmethod

Source code in griptape/griptape/schemas/artifacts/artifact_schema.py
@abstractmethod
def make_obj(self, data, **kwargs):
    ...

BaseEventSchema

Bases: BaseSchema

Source code in griptape/griptape/schemas/events/base_event_schema.py
class BaseEventSchema(BaseSchema):
    timestamp = fields.Float()
    type = fields.Str()

    @abstractmethod
    def make_obj(self, data, **kwargs):
        ...

timestamp = fields.Float() class-attribute instance-attribute

type = fields.Str() class-attribute instance-attribute

make_obj(data, **kwargs) abstractmethod

Source code in griptape/griptape/schemas/events/base_event_schema.py
@abstractmethod
def make_obj(self, data, **kwargs):
    ...

BasePromptEventSchema

Bases: BaseEventSchema

Source code in griptape/griptape/schemas/events/base_prompt_event_schema.py
class BasePromptEventSchema(BaseEventSchema):
    token_count = fields.Int()

    @abstractmethod
    def make_obj(self, data, **kwargs):
        ...

token_count = fields.Int() class-attribute instance-attribute

make_obj(data, **kwargs) abstractmethod

Source code in griptape/griptape/schemas/events/base_prompt_event_schema.py
@abstractmethod
def make_obj(self, data, **kwargs):
    ...

BaseSchema

Bases: Schema

Source code in griptape/griptape/schemas/base_schema.py
class BaseSchema(Schema):
    schema_namespace = fields.Str(allow_none=True)

schema_namespace = fields.Str(allow_none=True) class-attribute instance-attribute

BaseTaskEventSchema

Bases: BaseEventSchema

Source code in griptape/griptape/schemas/events/base_task_event_schema.py
class BaseTaskEventSchema(BaseEventSchema):
    task_id = fields.Str()
    task_parent_ids = fields.List(fields.Str())
    task_child_ids = fields.List(fields.Str())
    task_input = fields.Nested(PolymorphicSchema())
    task_output = fields.Nested(PolymorphicSchema())

task_child_ids = fields.List(fields.Str()) class-attribute instance-attribute

task_id = fields.Str() class-attribute instance-attribute

task_input = fields.Nested(PolymorphicSchema()) class-attribute instance-attribute

task_output = fields.Nested(PolymorphicSchema()) class-attribute instance-attribute

task_parent_ids = fields.List(fields.Str()) class-attribute instance-attribute

BlobArtifactSchema

Bases: BaseArtifactSchema

Source code in griptape/griptape/schemas/artifacts/blob_artifact_schema.py
class BlobArtifactSchema(BaseArtifactSchema):
    name = fields.Str()
    dir_name = fields.Str(allow_none=True)
    value = Bytes()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.artifacts import BlobArtifact

        return BlobArtifact(**data)

dir_name = fields.Str(allow_none=True) class-attribute instance-attribute

name = fields.Str() class-attribute instance-attribute

value = Bytes() class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/artifacts/blob_artifact_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.artifacts import BlobArtifact

    return BlobArtifact(**data)

Bytes

Bases: Field

Source code in griptape/griptape/schemas/bytes_field.py
class Bytes(fields.Field):
    def _serialize(self, value, attr, obj, **kwargs):
        return base64.b64encode(value).decode()

    def _deserialize(self, value, attr, data, **kwargs):
        return base64.b64decode(value)

    def _validate(self, value):
        if not isinstance(value, bytes):
            raise ValidationError("Invalid input type.")

CompletionChunkEventSchema

Bases: BaseEventSchema

Source code in griptape/griptape/schemas/events/completion_chunk_event_schema.py
class CompletionChunkEventSchema(BaseEventSchema):
    token = fields.Str()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.events import CompletionChunkEvent

        return CompletionChunkEvent(**data)

token = fields.Str() class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/events/completion_chunk_event_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.events import CompletionChunkEvent

    return CompletionChunkEvent(**data)

ConversationMemorySchema

Bases: BaseSchema

Source code in griptape/griptape/schemas/memory/structure/conversation_memory_schema.py
class ConversationMemorySchema(BaseSchema):
    type = fields.Str()
    runs = fields.List(fields.Nested(RunSchema()))
    max_runs = fields.Int(allow_none=True)

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.memory.structure import ConversationMemory

        return ConversationMemory(**data)

max_runs = fields.Int(allow_none=True) class-attribute instance-attribute

runs = fields.List(fields.Nested(RunSchema())) class-attribute instance-attribute

type = fields.Str() class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/memory/structure/conversation_memory_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.memory.structure import ConversationMemory

    return ConversationMemory(**data)

CsvRowArtifactSchema

Bases: BaseArtifactSchema

Source code in griptape/griptape/schemas/artifacts/csv_row_artifact_schema.py
class CsvRowArtifactSchema(BaseArtifactSchema):
    value = fields.Dict(keys=fields.Str(), values=fields.Str(allow_none=True))
    separator = fields.Str()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.artifacts import CsvRowArtifact

        return CsvRowArtifact(**data)

separator = fields.Str() class-attribute instance-attribute

value = fields.Dict(keys=fields.Str(), values=fields.Str(allow_none=True)) class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/artifacts/csv_row_artifact_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.artifacts import CsvRowArtifact

    return CsvRowArtifact(**data)

ErrorArtifactSchema

Bases: BaseArtifactSchema

Source code in griptape/griptape/schemas/artifacts/error_artifact_schema.py
class ErrorArtifactSchema(BaseArtifactSchema):
    value = fields.Str()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.artifacts import ErrorArtifact

        return ErrorArtifact(**data)

value = fields.Str() class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/artifacts/error_artifact_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.artifacts import ErrorArtifact

    return ErrorArtifact(**data)

FinishActionSubtaskEventSchema

Bases: BaseActionSubtaskEventSchema

Source code in griptape/griptape/schemas/events/finish_action_subtask_event_schema.py
class FinishActionSubtaskEventSchema(BaseActionSubtaskEventSchema):
    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.events import FinishActionSubtaskEvent

        return FinishActionSubtaskEvent(**data)

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/events/finish_action_subtask_event_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.events import FinishActionSubtaskEvent

    return FinishActionSubtaskEvent(**data)

FinishImageGenerationEventSchema

Bases: BaseImageGenerationEventSchema

Source code in griptape/griptape/schemas/events/finish_image_generation_event_schema.py
class FinishImageGenerationEventSchema(BaseImageGenerationEventSchema):
    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.events import FinishImageGenerationEvent

        return FinishImageGenerationEvent(**data)

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/events/finish_image_generation_event_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.events import FinishImageGenerationEvent

    return FinishImageGenerationEvent(**data)

FinishPromptEventSchema

Bases: BasePromptEventSchema

Source code in griptape/griptape/schemas/events/finish_prompt_event_schema.py
class FinishPromptEventSchema(BasePromptEventSchema):
    result = fields.Str()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.events import FinishPromptEvent

        return FinishPromptEvent(**data)

result = fields.Str() class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/events/finish_prompt_event_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.events import FinishPromptEvent

    return FinishPromptEvent(**data)

FinishStructureRunEventSchema

Bases: BaseEventSchema

Source code in griptape/griptape/schemas/events/finish_structure_run_event_schema.py
class FinishStructureRunEventSchema(BaseEventSchema):
    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.events import FinishStructureRunEvent

        return FinishStructureRunEvent(**data)

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/events/finish_structure_run_event_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.events import FinishStructureRunEvent

    return FinishStructureRunEvent(**data)

FinishTaskEventSchema

Bases: BaseTaskEventSchema

Source code in griptape/griptape/schemas/events/finish_task_event_schema.py
class FinishTaskEventSchema(BaseTaskEventSchema):
    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.events import FinishTaskEvent

        return FinishTaskEvent(**data)

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/events/finish_task_event_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.events import FinishTaskEvent

    return FinishTaskEvent(**data)

ImageArtifactSchema

Bases: BaseArtifactSchema

Source code in griptape/griptape/schemas/artifacts/image_artifact_schema.py
class ImageArtifactSchema(BaseArtifactSchema):
    base64 = fields.Str()
    mime_type = fields.Str()
    width = fields.Int()
    height = fields.Int()
    model = fields.Str()
    prompt = fields.Str()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.artifacts import ImageArtifact

        if "base64" in data:
            import base64

            image_bytes = base64.b64decode(data["base64"])
            data["value"] = image_bytes
            del data["base64"]

        return ImageArtifact(**data)

base64 = fields.Str() class-attribute instance-attribute

height = fields.Int() class-attribute instance-attribute

mime_type = fields.Str() class-attribute instance-attribute

model = fields.Str() class-attribute instance-attribute

prompt = fields.Str() class-attribute instance-attribute

width = fields.Int() class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/artifacts/image_artifact_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.artifacts import ImageArtifact

    if "base64" in data:
        import base64

        image_bytes = base64.b64decode(data["base64"])
        data["value"] = image_bytes
        del data["base64"]

    return ImageArtifact(**data)

InfoArtifactSchema

Bases: BaseArtifactSchema

Source code in griptape/griptape/schemas/artifacts/info_artifact_schema.py
class InfoArtifactSchema(BaseArtifactSchema):
    value = fields.Str()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.artifacts import InfoArtifact

        return InfoArtifact(**data)

value = fields.Str() class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/artifacts/info_artifact_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.artifacts import InfoArtifact

    return InfoArtifact(**data)

ListArtifactSchema

Bases: BaseArtifactSchema

Source code in griptape/griptape/schemas/artifacts/list_artifact_schema.py
class ListArtifactSchema(BaseArtifactSchema):
    value = fields.List(fields.Nested(PolymorphicSchema()))

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.artifacts import ListArtifact

        return ListArtifact(**data)

value = fields.List(fields.Nested(PolymorphicSchema())) class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/artifacts/list_artifact_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.artifacts import ListArtifact

    return ListArtifact(**data)

PolymorphicSchema

Bases: BaseSchema

PolymorphicSchema is based on https://github.com/marshmallow-code/marshmallow-oneofschema

Source code in griptape/griptape/schemas/polymorphic_schema.py
class PolymorphicSchema(BaseSchema):
    """
    PolymorphicSchema is based on https://github.com/marshmallow-code/marshmallow-oneofschema
    """

    def get_schema(self, class_name: str, obj: Optional[object], schema_namespace: Optional[str]):
        if schema_namespace:
            namespace = schema_namespace
        elif obj is not None and hasattr(obj, "schema_namespace"):
            if locate(f"griptape.schemas.{class_name}Schema"):
                namespace = "griptape.schemas"
            elif obj.schema_namespace is None:
                namespace = obj.schema_namespace = f"{obj.__module__}_schema"
            else:
                namespace = obj.schema_namespace
        else:
            namespace = "griptape.schemas"

        klass = locate(f"{namespace}.{class_name}Schema")

        if klass:
            return klass
        else:
            raise ValidationError(f"Missing schema for '{class_name}'")

    type_field = "type"
    type_field_remove = True

    def get_obj_type(self, obj):
        """Returns name of the schema during dump() calls, given the object
        being dumped."""
        return obj.__class__.__name__

    def get_data_type(self, data):
        """Returns name of the schema during load() calls, given the data being
        loaded. Defaults to looking up `type_field` in the data."""
        data_type = data.get(self.type_field)
        if self.type_field in data and self.type_field_remove:
            data.pop(self.type_field)
        return data_type

    def dump(self, obj, *, many=None, **kwargs):
        errors = {}
        result_data = []
        result_errors = {}
        many = self.many if many is None else bool(many)
        if not many:
            result = result_data = self._dump(obj, **kwargs)
        else:
            for idx, o in enumerate(obj):
                try:
                    result = self._dump(o, **kwargs)
                    result_data.append(result)
                except ValidationError as error:
                    result_errors[idx] = error.normalized_messages()
                    result_data.append(error.valid_data)

        result = result_data
        errors = result_errors

        if not errors:
            return result
        else:
            exc = ValidationError(errors, data=obj, valid_data=result)
            raise exc

    def _dump(self, obj, *, update_fields=True, **kwargs):
        obj_type = self.get_obj_type(obj)

        if not obj_type:
            return (None, {"_schema": "Unknown object class: %s" % obj.__class__.__name__})

        type_schema = self.get_schema(obj_type, obj, None)

        if not type_schema:
            return None, {"_schema": "Unsupported object type: %s" % obj_type}

        schema = type_schema if isinstance(type_schema, Schema) else type_schema()

        schema.context.update(getattr(self, "context", {}))

        result = schema.dump(obj, many=False, **kwargs)

        if result is not None:
            result[self.type_field] = obj_type

        return result

    def load(self, data, *, many=None, partial=None, unknown=None, **kwargs):
        errors = {}
        result_data = []
        result_errors = {}
        many = self.many if many is None else bool(many)
        if partial is None:
            partial = self.partial
        if not many:
            try:
                result = result_data = self._load(data, partial=partial, unknown=unknown, **kwargs)
                #  result_data.append(result)
            except ValidationError as error:
                result_errors = error.normalized_messages()
                result_data.append(error.valid_data)
        else:
            for idx, item in enumerate(data):
                try:
                    result = self._load(item, partial=partial, **kwargs)
                    result_data.append(result)
                except ValidationError as error:
                    result_errors[idx] = error.normalized_messages()
                    result_data.append(error.valid_data)

        result = result_data
        errors = result_errors

        if not errors:
            return result
        else:
            exc = ValidationError(errors, data=data, valid_data=result)
            raise exc

    def _load(self, data, *, partial=None, unknown=None, **kwargs):
        if not isinstance(data, dict):
            raise ValidationError({"_schema": "Invalid data type: %s" % data})

        data = dict(data)
        unknown = unknown or self.unknown
        data_type = self.get_data_type(data)

        if data_type is None:
            raise ValidationError({self.type_field: ["Missing data for required field."]})

        schema_namespace = data.get("schema_namespace")

        try:
            type_schema = self.get_schema(data_type, None, schema_namespace)
        except TypeError:
            # data_type could be unhashable
            raise ValidationError({self.type_field: ["Invalid value: %s" % data_type]})
        if not type_schema:
            raise ValidationError({self.type_field: ["Unsupported value: %s" % data_type]})

        schema = type_schema if isinstance(type_schema, Schema) else type_schema()

        schema.context.update(getattr(self, "context", {}))

        return schema.load(data, many=False, partial=partial, unknown=unknown, **kwargs)

    def validate(self, data, *, many=None, partial=None):
        try:
            self.load(data, many=many, partial=partial)
        except ValidationError as ve:
            return ve.messages
        return {}

type_field = 'type' class-attribute instance-attribute

type_field_remove = True class-attribute instance-attribute

dump(obj, *, many=None, **kwargs)

Source code in griptape/griptape/schemas/polymorphic_schema.py
def dump(self, obj, *, many=None, **kwargs):
    errors = {}
    result_data = []
    result_errors = {}
    many = self.many if many is None else bool(many)
    if not many:
        result = result_data = self._dump(obj, **kwargs)
    else:
        for idx, o in enumerate(obj):
            try:
                result = self._dump(o, **kwargs)
                result_data.append(result)
            except ValidationError as error:
                result_errors[idx] = error.normalized_messages()
                result_data.append(error.valid_data)

    result = result_data
    errors = result_errors

    if not errors:
        return result
    else:
        exc = ValidationError(errors, data=obj, valid_data=result)
        raise exc

get_data_type(data)

Returns name of the schema during load() calls, given the data being loaded. Defaults to looking up type_field in the data.

Source code in griptape/griptape/schemas/polymorphic_schema.py
def get_data_type(self, data):
    """Returns name of the schema during load() calls, given the data being
    loaded. Defaults to looking up `type_field` in the data."""
    data_type = data.get(self.type_field)
    if self.type_field in data and self.type_field_remove:
        data.pop(self.type_field)
    return data_type

get_obj_type(obj)

Returns name of the schema during dump() calls, given the object being dumped.

Source code in griptape/griptape/schemas/polymorphic_schema.py
def get_obj_type(self, obj):
    """Returns name of the schema during dump() calls, given the object
    being dumped."""
    return obj.__class__.__name__

get_schema(class_name, obj, schema_namespace)

Source code in griptape/griptape/schemas/polymorphic_schema.py
def get_schema(self, class_name: str, obj: Optional[object], schema_namespace: Optional[str]):
    if schema_namespace:
        namespace = schema_namespace
    elif obj is not None and hasattr(obj, "schema_namespace"):
        if locate(f"griptape.schemas.{class_name}Schema"):
            namespace = "griptape.schemas"
        elif obj.schema_namespace is None:
            namespace = obj.schema_namespace = f"{obj.__module__}_schema"
        else:
            namespace = obj.schema_namespace
    else:
        namespace = "griptape.schemas"

    klass = locate(f"{namespace}.{class_name}Schema")

    if klass:
        return klass
    else:
        raise ValidationError(f"Missing schema for '{class_name}'")

load(data, *, many=None, partial=None, unknown=None, **kwargs)

Source code in griptape/griptape/schemas/polymorphic_schema.py
def load(self, data, *, many=None, partial=None, unknown=None, **kwargs):
    errors = {}
    result_data = []
    result_errors = {}
    many = self.many if many is None else bool(many)
    if partial is None:
        partial = self.partial
    if not many:
        try:
            result = result_data = self._load(data, partial=partial, unknown=unknown, **kwargs)
            #  result_data.append(result)
        except ValidationError as error:
            result_errors = error.normalized_messages()
            result_data.append(error.valid_data)
    else:
        for idx, item in enumerate(data):
            try:
                result = self._load(item, partial=partial, **kwargs)
                result_data.append(result)
            except ValidationError as error:
                result_errors[idx] = error.normalized_messages()
                result_data.append(error.valid_data)

    result = result_data
    errors = result_errors

    if not errors:
        return result
    else:
        exc = ValidationError(errors, data=data, valid_data=result)
        raise exc

validate(data, *, many=None, partial=None)

Source code in griptape/griptape/schemas/polymorphic_schema.py
def validate(self, data, *, many=None, partial=None):
    try:
        self.load(data, many=many, partial=partial)
    except ValidationError as ve:
        return ve.messages
    return {}

PromptStackInputSchema

Bases: BaseSchema

Source code in griptape/griptape/schemas/utils/prompt_stack_input_schema.py
class PromptStackInputSchema(BaseSchema):
    content = fields.Str()
    role = fields.Str()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.utils.prompt_stack import PromptStack

        return PromptStack.Input(**data)

content = fields.Str() class-attribute instance-attribute

role = fields.Str() class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/utils/prompt_stack_input_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.utils.prompt_stack import PromptStack

    return PromptStack.Input(**data)

PromptStackSchema

Bases: BaseSchema

Source code in griptape/griptape/schemas/utils/prompt_stack_schema.py
class PromptStackSchema(BaseSchema):
    inputs = fields.List(fields.Nested(PromptStackInputSchema()))

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.utils.prompt_stack import PromptStack

        return PromptStack(**data)

inputs = fields.List(fields.Nested(PromptStackInputSchema())) class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/utils/prompt_stack_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.utils.prompt_stack import PromptStack

    return PromptStack(**data)

RunSchema

Bases: BaseSchema

Source code in griptape/griptape/schemas/memory/structure/run_schema.py
class RunSchema(BaseSchema):
    id = fields.Str()
    input = fields.Str()
    output = fields.Str()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.memory.structure import Run

        return Run(**data)

id = fields.Str() class-attribute instance-attribute

input = fields.Str() class-attribute instance-attribute

output = fields.Str() class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/memory/structure/run_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.memory.structure import Run

    return Run(**data)

StartActionSubtaskEventSchema

Bases: BaseActionSubtaskEventSchema

Source code in griptape/griptape/schemas/events/start_action_event_schema.py
class StartActionSubtaskEventSchema(BaseActionSubtaskEventSchema):
    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.events import StartActionSubtaskEvent

        return StartActionSubtaskEvent(**data)

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/events/start_action_event_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.events import StartActionSubtaskEvent

    return StartActionSubtaskEvent(**data)

StartImageGenerationEventSchema

Bases: BaseImageGenerationEventSchema

Source code in griptape/griptape/schemas/events/start_image_generation_event_schema.py
class StartImageGenerationEventSchema(BaseImageGenerationEventSchema):
    prompts = fields.List(fields.Str())
    negative_prompts = fields.List(fields.Str())

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.events import StartImageGenerationEvent

        return StartImageGenerationEvent(**data)

negative_prompts = fields.List(fields.Str()) class-attribute instance-attribute

prompts = fields.List(fields.Str()) class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/events/start_image_generation_event_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.events import StartImageGenerationEvent

    return StartImageGenerationEvent(**data)

StartPromptEventSchema

Bases: BasePromptEventSchema

Source code in griptape/griptape/schemas/events/start_prompt_event_schema.py
class StartPromptEventSchema(BasePromptEventSchema):
    prompt_stack = fields.Nested(PromptStackSchema())
    prompt = fields.Str()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.events import StartPromptEvent

        return StartPromptEvent(**data)

prompt = fields.Str() class-attribute instance-attribute

prompt_stack = fields.Nested(PromptStackSchema()) class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/events/start_prompt_event_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.events import StartPromptEvent

    return StartPromptEvent(**data)

StartStructureRunEventSchema

Bases: BaseEventSchema

Source code in griptape/griptape/schemas/events/start_structure_run_event_schema.py
class StartStructureRunEventSchema(BaseEventSchema):
    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.events import StartStructureRunEvent

        return StartStructureRunEvent(**data)

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/events/start_structure_run_event_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.events import StartStructureRunEvent

    return StartStructureRunEvent(**data)

StartTaskEventSchema

Bases: BaseTaskEventSchema

Source code in griptape/griptape/schemas/events/start_task_event_schema.py
class StartTaskEventSchema(BaseTaskEventSchema):
    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.events import StartTaskEvent

        return StartTaskEvent(**data)

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/events/start_task_event_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.events import StartTaskEvent

    return StartTaskEvent(**data)

SummaryConversationMemorySchema

Bases: ConversationMemorySchema

Source code in griptape/griptape/schemas/memory/structure/summary_conversation_memory_schema.py
class SummaryConversationMemorySchema(ConversationMemorySchema):
    offset = fields.Int()
    summary = fields.Str(allow_none=True)
    summary_index = fields.Int()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.memory.structure import SummaryConversationMemory

        return SummaryConversationMemory(**data)

offset = fields.Int() class-attribute instance-attribute

summary = fields.Str(allow_none=True) class-attribute instance-attribute

summary_index = fields.Int() class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/memory/structure/summary_conversation_memory_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.memory.structure import SummaryConversationMemory

    return SummaryConversationMemory(**data)

TextArtifactSchema

Bases: BaseArtifactSchema

Source code in griptape/griptape/schemas/artifacts/text_artifact_schema.py
class TextArtifactSchema(BaseArtifactSchema):
    value = fields.Str()

    @post_load
    def make_obj(self, data, **kwargs):
        from griptape.artifacts import TextArtifact

        return TextArtifact(**data)

value = fields.Str() class-attribute instance-attribute

make_obj(data, **kwargs)

Source code in griptape/griptape/schemas/artifacts/text_artifact_schema.py
@post_load
def make_obj(self, data, **kwargs):
    from griptape.artifacts import TextArtifact

    return TextArtifact(**data)