Skip to content

ContentBlock module-attribute

A block of content for a message that you pass to, or receive from, a model with the Converse or ConverseStream API operations.

Union Members

ContentBlockText dataclass

Text to include in the message.

Source code in src/aws_sdk_bedrock_runtime/models.py
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
@dataclass
class ContentBlockText:
    """Text to include in the message."""

    value: str

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

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_string(_SCHEMA_CONTENT_BLOCK.members["text"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(
            value=deserializer.read_string(_SCHEMA_CONTENT_BLOCK.members["text"])
        )

ContentBlockImage dataclass

Image to include in the message.

Note

This field is only supported by Anthropic Claude 3 models.

Source code in src/aws_sdk_bedrock_runtime/models.py
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
@dataclass
class ContentBlockImage:
    """Image to include in the message.

    Note:
        This field is only supported by Anthropic Claude 3 models.
    """

    value: ImageBlock

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

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_CONTENT_BLOCK.members["image"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=ImageBlock.deserialize(deserializer))

ContentBlockDocument dataclass

A document to include in the message.

Source code in src/aws_sdk_bedrock_runtime/models.py
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
@dataclass
class ContentBlockDocument:
    """A document to include in the message."""

    value: DocumentBlock

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

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_CONTENT_BLOCK.members["document"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=DocumentBlock.deserialize(deserializer))

ContentBlockVideo dataclass

Video to include in the message.

Source code in src/aws_sdk_bedrock_runtime/models.py
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
@dataclass
class ContentBlockVideo:
    """Video to include in the message."""

    value: VideoBlock

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

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_CONTENT_BLOCK.members["video"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=VideoBlock.deserialize(deserializer))

ContentBlockToolUse dataclass

Information about a tool use request from a model.

Source code in src/aws_sdk_bedrock_runtime/models.py
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
@dataclass
class ContentBlockToolUse:
    """Information about a tool use request from a model."""

    value: ToolUseBlock

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

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_CONTENT_BLOCK.members["toolUse"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=ToolUseBlock.deserialize(deserializer))

ContentBlockToolResult dataclass

The result for a tool request that a model makes.

Source code in src/aws_sdk_bedrock_runtime/models.py
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
@dataclass
class ContentBlockToolResult:
    """The result for a tool request that a model makes."""

    value: ToolResultBlock

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

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_CONTENT_BLOCK.members["toolResult"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=ToolResultBlock.deserialize(deserializer))

ContentBlockGuardContent dataclass

Contains the content to assess with the guardrail. If you don't specify guardContent in a call to the Converse API, the guardrail (if passed in the Converse API) assesses the entire message.

For more information, see Use a guardrail with the Converse API in the Amazon Bedrock User Guide.

Source code in src/aws_sdk_bedrock_runtime/models.py
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
@dataclass
class ContentBlockGuardContent:
    """Contains the content to assess with the guardrail. If you don't specify
    `guardContent` in a call to the Converse API, the guardrail (if passed
    in the Converse API) assesses the entire message.

    For more information, see *Use a guardrail with the Converse API* in the
    *Amazon Bedrock User Guide*.
    """

    value: GuardrailConverseContentBlock

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

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_struct(
            _SCHEMA_CONTENT_BLOCK.members["guardContent"], self.value
        )

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(
            value=_GuardrailConverseContentBlockDeserializer().deserialize(deserializer)
        )

ContentBlockCachePoint dataclass

CachePoint to include in the message.

Source code in src/aws_sdk_bedrock_runtime/models.py
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
@dataclass
class ContentBlockCachePoint:
    """CachePoint to include in the message."""

    value: CachePointBlock

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

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_CONTENT_BLOCK.members["cachePoint"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=CachePointBlock.deserialize(deserializer))

ContentBlockReasoningContent dataclass

Contains content regarding the reasoning that is carried out by the model. Reasoning refers to a Chain of Thought (CoT) that the model generates to enhance the accuracy of its final response.

Source code in src/aws_sdk_bedrock_runtime/models.py
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
@dataclass
class ContentBlockReasoningContent:
    """Contains content regarding the reasoning that is carried out by the
    model. Reasoning refers to a Chain of Thought (CoT) that the model
    generates to enhance the accuracy of its final response.
    """

    value: ReasoningContentBlock

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

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_struct(
            _SCHEMA_CONTENT_BLOCK.members["reasoningContent"], self.value
        )

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=_ReasoningContentBlockDeserializer().deserialize(deserializer))

ContentBlockCitationsContent dataclass

A content block that contains both generated text and associated citation information, providing traceability between the response and source documents.

Source code in src/aws_sdk_bedrock_runtime/models.py
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
@dataclass
class ContentBlockCitationsContent:
    """A content block that contains both generated text and associated
    citation information, providing traceability between the response and
    source documents.
    """

    value: CitationsContentBlock

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

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_struct(
            _SCHEMA_CONTENT_BLOCK.members["citationsContent"], self.value
        )

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=CitationsContentBlock.deserialize(deserializer))

ContentBlockUnknown dataclass

Represents an unknown variant.

If you receive this value, you will need to update your library to receive the parsed value.

This value may not be deliberately sent.

Source code in src/aws_sdk_bedrock_runtime/models.py
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
@dataclass
class ContentBlockUnknown:
    """Represents an unknown variant.

    If you receive this value, you will need to update your library to receive the
    parsed value.

    This value may not be deliberately sent.
    """

    tag: str

    def serialize(self, serializer: ShapeSerializer):
        raise SerializationError("Unknown union variants may not be serialized.")

    def serialize_members(self, serializer: ShapeSerializer):
        raise SerializationError("Unknown union variants may not be serialized.")

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        raise NotImplementedError()