Skip to content

GuardrailAutomatedReasoningInputTextReference dataclass

References a portion of the original input text that corresponds to logical elements.

Source code in src/aws_sdk_bedrock_runtime/models.py
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
@dataclass(kw_only=True)
class GuardrailAutomatedReasoningInputTextReference:
    """References a portion of the original input text that corresponds to
    logical elements.
    """

    text: str | None = field(repr=False, default=None)
    """The specific text from the original input that this reference points to."""

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

    def serialize_members(self, serializer: ShapeSerializer):
        if self.text is not None:
            serializer.write_string(
                _SCHEMA_GUARDRAIL_AUTOMATED_REASONING_INPUT_TEXT_REFERENCE.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_AUTOMATED_REASONING_INPUT_TEXT_REFERENCE.members[
                            "text"
                        ]
                    )

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

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

Attributes

text class-attribute instance-attribute

text: str | None = field(repr=False, default=None)

The specific text from the original input that this reference points to.