1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// <p>A message input, or returned from, a call to <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html">Converse</a> or <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ConverseStream.html">ConverseStream</a>.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Message {
/// <p>The role that the message plays in the message.</p>
pub role: crate::types::ConversationRole,
/// <p>The message content. Note the following restrictions:</p>
/// <ul>
/// <li>
/// <p>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.</p></li>
/// <li>
/// <p>You can include up to five documents. Each document's size must be no more than 4.5 MB.</p></li>
/// <li>
/// <p>If you include a <code>ContentBlock</code> with a <code>document</code> field in the array, you must also include a <code>ContentBlock</code> with a <code>text</code> field.</p></li>
/// <li>
/// <p>You can only include images and documents if the <code>role</code> is <code>user</code>.</p></li>
/// </ul>
pub content: ::std::vec::Vec<crate::types::ContentBlock>,
}
impl Message {
/// <p>The role that the message plays in the message.</p>
pub fn role(&self) -> &crate::types::ConversationRole {
&self.role
}
/// <p>The message content. Note the following restrictions:</p>
/// <ul>
/// <li>
/// <p>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.</p></li>
/// <li>
/// <p>You can include up to five documents. Each document's size must be no more than 4.5 MB.</p></li>
/// <li>
/// <p>If you include a <code>ContentBlock</code> with a <code>document</code> field in the array, you must also include a <code>ContentBlock</code> with a <code>text</code> field.</p></li>
/// <li>
/// <p>You can only include images and documents if the <code>role</code> is <code>user</code>.</p></li>
/// </ul>
pub fn content(&self) -> &[crate::types::ContentBlock] {
use std::ops::Deref;
self.content.deref()
}
}
impl Message {
/// Creates a new builder-style object to manufacture [`Message`](crate::types::Message).
pub fn builder() -> crate::types::builders::MessageBuilder {
crate::types::builders::MessageBuilder::default()
}
}
/// A builder for [`Message`](crate::types::Message).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct MessageBuilder {
pub(crate) role: ::std::option::Option<crate::types::ConversationRole>,
pub(crate) content: ::std::option::Option<::std::vec::Vec<crate::types::ContentBlock>>,
}
impl MessageBuilder {
/// <p>The role that the message plays in the message.</p>
/// This field is required.
pub fn role(mut self, input: crate::types::ConversationRole) -> Self {
self.role = ::std::option::Option::Some(input);
self
}
/// <p>The role that the message plays in the message.</p>
pub fn set_role(mut self, input: ::std::option::Option<crate::types::ConversationRole>) -> Self {
self.role = input;
self
}
/// <p>The role that the message plays in the message.</p>
pub fn get_role(&self) -> &::std::option::Option<crate::types::ConversationRole> {
&self.role
}
/// Appends an item to `content`.
///
/// To override the contents of this collection use [`set_content`](Self::set_content).
///
/// <p>The message content. Note the following restrictions:</p>
/// <ul>
/// <li>
/// <p>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.</p></li>
/// <li>
/// <p>You can include up to five documents. Each document's size must be no more than 4.5 MB.</p></li>
/// <li>
/// <p>If you include a <code>ContentBlock</code> with a <code>document</code> field in the array, you must also include a <code>ContentBlock</code> with a <code>text</code> field.</p></li>
/// <li>
/// <p>You can only include images and documents if the <code>role</code> is <code>user</code>.</p></li>
/// </ul>
pub fn content(mut self, input: crate::types::ContentBlock) -> Self {
let mut v = self.content.unwrap_or_default();
v.push(input);
self.content = ::std::option::Option::Some(v);
self
}
/// <p>The message content. Note the following restrictions:</p>
/// <ul>
/// <li>
/// <p>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.</p></li>
/// <li>
/// <p>You can include up to five documents. Each document's size must be no more than 4.5 MB.</p></li>
/// <li>
/// <p>If you include a <code>ContentBlock</code> with a <code>document</code> field in the array, you must also include a <code>ContentBlock</code> with a <code>text</code> field.</p></li>
/// <li>
/// <p>You can only include images and documents if the <code>role</code> is <code>user</code>.</p></li>
/// </ul>
pub fn set_content(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::ContentBlock>>) -> Self {
self.content = input;
self
}
/// <p>The message content. Note the following restrictions:</p>
/// <ul>
/// <li>
/// <p>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.</p></li>
/// <li>
/// <p>You can include up to five documents. Each document's size must be no more than 4.5 MB.</p></li>
/// <li>
/// <p>If you include a <code>ContentBlock</code> with a <code>document</code> field in the array, you must also include a <code>ContentBlock</code> with a <code>text</code> field.</p></li>
/// <li>
/// <p>You can only include images and documents if the <code>role</code> is <code>user</code>.</p></li>
/// </ul>
pub fn get_content(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::ContentBlock>> {
&self.content
}
/// Consumes the builder and constructs a [`Message`](crate::types::Message).
/// This method will fail if any of the following fields are not set:
/// - [`role`](crate::types::builders::MessageBuilder::role)
/// - [`content`](crate::types::builders::MessageBuilder::content)
pub fn build(self) -> ::std::result::Result<crate::types::Message, ::aws_smithy_types::error::operation::BuildError> {
::std::result::Result::Ok(crate::types::Message {
role: self.role.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field(
"role",
"role was not specified but it is required when building Message",
)
})?,
content: self.content.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field(
"content",
"content was not specified but it is required when building Message",
)
})?,
})
}
}