Skip to content

ReasoningTextBlock dataclass

Contains the reasoning that the model used to return the output.

Source code in src/aws_sdk_bedrock_runtime/models.py
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
@dataclass(kw_only=True)
class ReasoningTextBlock:
    """Contains the reasoning that the model used to return the output."""

    text: str
    """The reasoning that the model used to return the output."""

    signature: str | None = None
    """A token that verifies that the reasoning text was generated by the
    model. If you pass a reasoning block back to the API in a multi-turn
    conversation, include the text and its signature unmodified.
    """

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

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

    @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_REASONING_TEXT_BLOCK.members["text"]
                    )

                case 1:
                    kwargs["signature"] = de.read_string(
                        _SCHEMA_REASONING_TEXT_BLOCK.members["signature"]
                    )

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

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

Attributes

signature class-attribute instance-attribute

signature: str | None = None

A token that verifies that the reasoning text was generated by the model. If you pass a reasoning block back to the API in a multi-turn conversation, include the text and its signature unmodified.

text instance-attribute

text: str

The reasoning that the model used to return the output.