A message input, or returned from, a call to
Converse
or
ConverseStream.
Source code in src/aws_sdk_bedrock_runtime/models.py
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483 | @dataclass(kw_only=True)
class Message:
"""A message input, or returned from, a call to
[Converse](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html)
or
[ConverseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ConverseStream.html).
"""
role: str
"""The role that the message plays in the message."""
content: list[ContentBlock]
"""The message content. Note the following restrictions:
- You can include up to 20 images. Each image's size, height, and width
must be no more than 3.75 MB, 8000 px, and 8000 px, respectively.
- You can include up to five documents. Each document's size must be no
more than 4.5 MB.
- If you include a `ContentBlock` with a `document` field in the array,
you must also include a `ContentBlock` with a `text` field.
- You can only include images and documents if the `role` is `user`.
"""
def serialize(self, serializer: ShapeSerializer):
serializer.write_struct(_SCHEMA_MESSAGE, self)
def serialize_members(self, serializer: ShapeSerializer):
serializer.write_string(_SCHEMA_MESSAGE.members["role"], self.role)
_serialize_content_blocks(
serializer, _SCHEMA_MESSAGE.members["content"], self.content
)
@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["role"] = de.read_string(_SCHEMA_MESSAGE.members["role"])
case 1:
kwargs["content"] = _deserialize_content_blocks(
de, _SCHEMA_MESSAGE.members["content"]
)
case _:
logger.debug("Unexpected member schema: %s", schema)
deserializer.read_struct(_SCHEMA_MESSAGE, consumer=_consumer)
return kwargs
|
Attributes
content
instance-attribute
The message content. Note the following restrictions:
-
You can include up to 20 images. Each image's size, height, and width
must be no more than 3.75 MB, 8000 px, and 8000 px, respectively.
-
You can include up to five documents. Each document's size must be no
more than 4.5 MB.
-
If you include a ContentBlock with a document field in the array,
you must also include a ContentBlock with a text field.
-
You can only include images and documents if the role is user.
role
instance-attribute
The role that the message plays in the message.