Skip to content

CitationsDelta dataclass

Contains incremental updates to citation information during streaming responses. This allows clients to build up citation data progressively as the response is generated.

Source code in src/aws_sdk_bedrock_runtime/models.py
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
@dataclass(kw_only=True)
class CitationsDelta:
    """Contains incremental updates to citation information during streaming
    responses. This allows clients to build up citation data progressively
    as the response is generated.
    """

    title: str | None = None
    """The title or identifier of the source document being cited."""

    source_content: list[CitationSourceContentDelta] | None = None
    """The specific content from the source document that was referenced or
    cited in the generated response.
    """

    location: CitationLocation | None = None
    """Specifies the precise location within a source document where cited
    content can be found. This can include character-level positions, page
    numbers, or document chunks depending on the document type and indexing
    method.
    """

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

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

        if self.source_content is not None:
            _serialize_citation_source_content_list_delta(
                serializer,
                _SCHEMA_CITATIONS_DELTA.members["sourceContent"],
                self.source_content,
            )

        if self.location is not None:
            serializer.write_struct(
                _SCHEMA_CITATIONS_DELTA.members["location"], self.location
            )

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

                case 1:
                    kwargs["source_content"] = (
                        _deserialize_citation_source_content_list_delta(
                            de, _SCHEMA_CITATIONS_DELTA.members["sourceContent"]
                        )
                    )

                case 2:
                    kwargs["location"] = _CitationLocationDeserializer().deserialize(de)

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

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

Attributes

location class-attribute instance-attribute

location: CitationLocation | None = None

Specifies the precise location within a source document where cited content can be found. This can include character-level positions, page numbers, or document chunks depending on the document type and indexing method.

source_content class-attribute instance-attribute

source_content: list[CitationSourceContentDelta] | None = None

The specific content from the source document that was referenced or cited in the generated response.

title class-attribute instance-attribute

title: str | None = None

The title or identifier of the source document being cited.