Skip to content

GuardrailOutputContent dataclass

The output content produced by the guardrail.

Source code in src/aws_sdk_bedrock_runtime/models.py
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
@dataclass(kw_only=True)
class GuardrailOutputContent:
    """The output content produced by the guardrail."""

    text: str | None = None
    """The specific text for the output content produced by the guardrail."""

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

    def serialize_members(self, serializer: ShapeSerializer):
        if self.text is not None:
            serializer.write_string(
                _SCHEMA_GUARDRAIL_OUTPUT_CONTENT.members["text"], self.text
            )

    @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["text"] = de.read_string(
                        _SCHEMA_GUARDRAIL_OUTPUT_CONTENT.members["text"]
                    )

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

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

Attributes

text class-attribute instance-attribute

text: str | None = None

The specific text for the output content produced by the guardrail.