Skip to content

DocumentPageLocation dataclass

Specifies a page-level location within a document, providing positioning information for cited content using page numbers.

Source code in src/aws_sdk_bedrock_runtime/models.py
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
@dataclass(kw_only=True)
class DocumentPageLocation:
    """Specifies a page-level location within a document, providing positioning
    information for cited content using page numbers.
    """

    document_index: int | None = None
    """The index of the document within the array of documents provided in the
    request.
    """

    start: int | None = None
    """The starting page number of the cited content within the document."""

    end: int | None = None
    """The ending page number of the cited content within the document."""

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

    def serialize_members(self, serializer: ShapeSerializer):
        if self.document_index is not None:
            serializer.write_integer(
                _SCHEMA_DOCUMENT_PAGE_LOCATION.members["documentIndex"],
                self.document_index,
            )

        if self.start is not None:
            serializer.write_integer(
                _SCHEMA_DOCUMENT_PAGE_LOCATION.members["start"], self.start
            )

        if self.end is not None:
            serializer.write_integer(
                _SCHEMA_DOCUMENT_PAGE_LOCATION.members["end"], self.end
            )

    @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["document_index"] = de.read_integer(
                        _SCHEMA_DOCUMENT_PAGE_LOCATION.members["documentIndex"]
                    )

                case 1:
                    kwargs["start"] = de.read_integer(
                        _SCHEMA_DOCUMENT_PAGE_LOCATION.members["start"]
                    )

                case 2:
                    kwargs["end"] = de.read_integer(
                        _SCHEMA_DOCUMENT_PAGE_LOCATION.members["end"]
                    )

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

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

Attributes

document_index class-attribute instance-attribute

document_index: int | None = None

The index of the document within the array of documents provided in the request.

end class-attribute instance-attribute

end: int | None = None

The ending page number of the cited content within the document.

start class-attribute instance-attribute

start: int | None = None

The starting page number of the cited content within the document.