Skip to content

GuardrailConverseImageBlock dataclass

An image block that contains images that you want to assess with a guardrail.

Source code in src/aws_sdk_bedrock_runtime/models.py
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
@dataclass(kw_only=True)
class GuardrailConverseImageBlock:
    """An image block that contains images that you want to assess with a
    guardrail.
    """

    format: str
    """The format details for the image type of the guardrail converse image
    block.
    """

    source: GuardrailConverseImageSource = field(repr=False)
    """The image source (image bytes) of the guardrail converse image block."""

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_GUARDRAIL_CONVERSE_IMAGE_BLOCK, self)

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_string(
            _SCHEMA_GUARDRAIL_CONVERSE_IMAGE_BLOCK.members["format"], self.format
        )
        serializer.write_struct(
            _SCHEMA_GUARDRAIL_CONVERSE_IMAGE_BLOCK.members["source"], self.source
        )

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(**cls.deserialize_kwargs(deserializer))

    @classmethod
    def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]:
        kwargs: dict[str, Any] = {}

        def _consumer(schema: Schema, de: ShapeDeserializer) -> None:
            match schema.expect_member_index():
                case 0:
                    kwargs["format"] = de.read_string(
                        _SCHEMA_GUARDRAIL_CONVERSE_IMAGE_BLOCK.members["format"]
                    )

                case 1:
                    kwargs["source"] = (
                        _GuardrailConverseImageSourceDeserializer().deserialize(de)
                    )

                case _:
                    logger.debug("Unexpected member schema: %s", schema)

        deserializer.read_struct(
            _SCHEMA_GUARDRAIL_CONVERSE_IMAGE_BLOCK, consumer=_consumer
        )
        return kwargs

Attributes

format instance-attribute

format: str

The format details for the image type of the guardrail converse image block.

source class-attribute instance-attribute

source: GuardrailConverseImageSource = field(repr=False)

The image source (image bytes) of the guardrail converse image block.