1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 2 |
|
3 - | /// <p>A block of content for a message that you pass to, or receive from, a model with the <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> API operations.</p>
|
3 + | /// <p>A block of content for a message.</p>
|
4 4 | #[non_exhaustive]
|
5 - | #[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
|
5 + | #[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
|
6 6 | pub enum ContentBlock {
|
7 - | /// <p>CachePoint to include in the message.</p>
|
8 - | CachePoint(crate::types::CachePointBlock),
|
9 - | /// <p>A content block that contains both generated text and associated citation information, providing traceability between the response and source documents.</p>
|
10 - | CitationsContent(crate::types::CitationsContentBlock),
|
11 - | /// <p>A document to include in the message.</p>
|
12 - | Document(crate::types::DocumentBlock),
|
13 - | /// <p>Contains the content to assess with the guardrail. If you don't specify <code>guardContent</code> in a call to the Converse API, the guardrail (if passed in the Converse API) assesses the entire message.</p>
|
14 - | /// <p>For more information, see <i>Use a guardrail with the Converse API</i> in the <i>Amazon Bedrock User Guide</i>.</p>
|
15 - | GuardContent(crate::types::GuardrailConverseContentBlock),
|
16 7 | /// <p>Image to include in the message.</p><note>
|
17 8 | /// <p>This field is only supported by Anthropic Claude 3 models.</p>
|
18 9 | /// </note>
|
19 10 | Image(crate::types::ImageBlock),
|
20 - | /// <p>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.</p>
|
21 - | ReasoningContent(crate::types::ReasoningContentBlock),
|
22 11 | /// <p>Text to include in the message.</p>
|
23 12 | Text(::std::string::String),
|
24 13 | /// <p>The result for a tool request that a model makes.</p>
|
25 14 | ToolResult(crate::types::ToolResultBlock),
|
26 15 | /// <p>Information about a tool use request from a model.</p>
|
27 16 | ToolUse(crate::types::ToolUseBlock),
|
28 - | /// <p>Video to include in the message.</p>
|
29 - | Video(crate::types::VideoBlock),
|
30 17 | /// The `Unknown` variant represents cases where new union variant was received. Consider upgrading the SDK to the latest available version.
|
31 18 | /// An unknown enum variant
|
32 19 | ///
|
33 20 | /// _Note: If you encounter this error, consider upgrading your SDK to the latest version._
|
34 21 | /// The `Unknown` variant represents cases where the server sent a value that wasn't recognized
|
35 22 | /// by the client. This can happen when the server adds new functionality, but the client has not been updated.
|
36 23 | /// To investigate this, consider turning on debug logging to print the raw HTTP response.
|
37 24 | #[non_exhaustive]
|
38 25 | Unknown,
|
39 26 | }
|
40 27 | impl ContentBlock {
|
41 - | /// Tries to convert the enum instance into [`CachePoint`](crate::types::ContentBlock::CachePoint), extracting the inner [`CachePointBlock`](crate::types::CachePointBlock).
|
42 - | /// Returns `Err(&Self)` if it can't be converted.
|
43 - | pub fn as_cache_point(&self) -> ::std::result::Result<&crate::types::CachePointBlock, &Self> {
|
44 - | if let ContentBlock::CachePoint(val) = &self {
|
45 - | ::std::result::Result::Ok(val)
|
46 - | } else {
|
47 - | ::std::result::Result::Err(self)
|
48 - | }
|
49 - | }
|
50 - | /// Returns true if this is a [`CachePoint`](crate::types::ContentBlock::CachePoint).
|
51 - | pub fn is_cache_point(&self) -> bool {
|
52 - | self.as_cache_point().is_ok()
|
53 - | }
|
54 - | /// Tries to convert the enum instance into [`CitationsContent`](crate::types::ContentBlock::CitationsContent), extracting the inner [`CitationsContentBlock`](crate::types::CitationsContentBlock).
|
55 - | /// Returns `Err(&Self)` if it can't be converted.
|
56 - | pub fn as_citations_content(&self) -> ::std::result::Result<&crate::types::CitationsContentBlock, &Self> {
|
57 - | if let ContentBlock::CitationsContent(val) = &self {
|
58 - | ::std::result::Result::Ok(val)
|
59 - | } else {
|
60 - | ::std::result::Result::Err(self)
|
61 - | }
|
62 - | }
|
63 - | /// Returns true if this is a [`CitationsContent`](crate::types::ContentBlock::CitationsContent).
|
64 - | pub fn is_citations_content(&self) -> bool {
|
65 - | self.as_citations_content().is_ok()
|
66 - | }
|
67 - | /// Tries to convert the enum instance into [`Document`](crate::types::ContentBlock::Document), extracting the inner [`DocumentBlock`](crate::types::DocumentBlock).
|
68 - | /// Returns `Err(&Self)` if it can't be converted.
|
69 - | pub fn as_document(&self) -> ::std::result::Result<&crate::types::DocumentBlock, &Self> {
|
70 - | if let ContentBlock::Document(val) = &self {
|
71 - | ::std::result::Result::Ok(val)
|
72 - | } else {
|
73 - | ::std::result::Result::Err(self)
|
74 - | }
|
75 - | }
|
76 - | /// Returns true if this is a [`Document`](crate::types::ContentBlock::Document).
|
77 - | pub fn is_document(&self) -> bool {
|
78 - | self.as_document().is_ok()
|
79 - | }
|
80 - | /// Tries to convert the enum instance into [`GuardContent`](crate::types::ContentBlock::GuardContent), extracting the inner [`GuardrailConverseContentBlock`](crate::types::GuardrailConverseContentBlock).
|
81 - | /// Returns `Err(&Self)` if it can't be converted.
|
82 - | pub fn as_guard_content(&self) -> ::std::result::Result<&crate::types::GuardrailConverseContentBlock, &Self> {
|
83 - | if let ContentBlock::GuardContent(val) = &self {
|
84 - | ::std::result::Result::Ok(val)
|
85 - | } else {
|
86 - | ::std::result::Result::Err(self)
|
87 - | }
|
88 - | }
|
89 - | /// Returns true if this is a [`GuardContent`](crate::types::ContentBlock::GuardContent).
|
90 - | pub fn is_guard_content(&self) -> bool {
|
91 - | self.as_guard_content().is_ok()
|
92 - | }
|
93 28 | /// Tries to convert the enum instance into [`Image`](crate::types::ContentBlock::Image), extracting the inner [`ImageBlock`](crate::types::ImageBlock).
|
94 29 | /// Returns `Err(&Self)` if it can't be converted.
|
95 30 | pub fn as_image(&self) -> ::std::result::Result<&crate::types::ImageBlock, &Self> {
|
96 31 | if let ContentBlock::Image(val) = &self {
|
97 32 | ::std::result::Result::Ok(val)
|
98 33 | } else {
|
99 34 | ::std::result::Result::Err(self)
|
100 35 | }
|
101 36 | }
|
102 37 | /// Returns true if this is a [`Image`](crate::types::ContentBlock::Image).
|
103 38 | pub fn is_image(&self) -> bool {
|
104 39 | self.as_image().is_ok()
|
105 40 | }
|
106 - | /// Tries to convert the enum instance into [`ReasoningContent`](crate::types::ContentBlock::ReasoningContent), extracting the inner [`ReasoningContentBlock`](crate::types::ReasoningContentBlock).
|
107 - | /// Returns `Err(&Self)` if it can't be converted.
|
108 - | pub fn as_reasoning_content(&self) -> ::std::result::Result<&crate::types::ReasoningContentBlock, &Self> {
|
109 - | if let ContentBlock::ReasoningContent(val) = &self {
|
110 - | ::std::result::Result::Ok(val)
|
111 - | } else {
|
112 - | ::std::result::Result::Err(self)
|
113 - | }
|
114 - | }
|
115 - | /// Returns true if this is a [`ReasoningContent`](crate::types::ContentBlock::ReasoningContent).
|
116 - | pub fn is_reasoning_content(&self) -> bool {
|
117 - | self.as_reasoning_content().is_ok()
|
118 - | }
|
119 41 | /// Tries to convert the enum instance into [`Text`](crate::types::ContentBlock::Text), extracting the inner [`String`](::std::string::String).
|
120 42 | /// Returns `Err(&Self)` if it can't be converted.
|
121 43 | pub fn as_text(&self) -> ::std::result::Result<&::std::string::String, &Self> {
|
122 44 | if let ContentBlock::Text(val) = &self {
|
123 45 | ::std::result::Result::Ok(val)
|
124 46 | } else {
|
125 47 | ::std::result::Result::Err(self)
|
126 48 | }
|
127 49 | }
|
128 50 | /// Returns true if this is a [`Text`](crate::types::ContentBlock::Text).
|
129 51 | pub fn is_text(&self) -> bool {
|
130 52 | self.as_text().is_ok()
|
131 53 | }
|
132 54 | /// Tries to convert the enum instance into [`ToolResult`](crate::types::ContentBlock::ToolResult), extracting the inner [`ToolResultBlock`](crate::types::ToolResultBlock).
|
133 55 | /// Returns `Err(&Self)` if it can't be converted.
|
134 56 | pub fn as_tool_result(&self) -> ::std::result::Result<&crate::types::ToolResultBlock, &Self> {
|
135 57 | if let ContentBlock::ToolResult(val) = &self {
|
136 58 | ::std::result::Result::Ok(val)
|
137 59 | } else {
|
138 60 | ::std::result::Result::Err(self)
|
139 61 | }
|
140 62 | }
|
141 63 | /// Returns true if this is a [`ToolResult`](crate::types::ContentBlock::ToolResult).
|
142 64 | pub fn is_tool_result(&self) -> bool {
|
143 65 | self.as_tool_result().is_ok()
|
144 66 | }
|
145 67 | /// Tries to convert the enum instance into [`ToolUse`](crate::types::ContentBlock::ToolUse), extracting the inner [`ToolUseBlock`](crate::types::ToolUseBlock).
|
146 68 | /// Returns `Err(&Self)` if it can't be converted.
|
147 69 | pub fn as_tool_use(&self) -> ::std::result::Result<&crate::types::ToolUseBlock, &Self> {
|
148 70 | if let ContentBlock::ToolUse(val) = &self {
|
149 71 | ::std::result::Result::Ok(val)
|
150 72 | } else {
|
151 73 | ::std::result::Result::Err(self)
|
152 74 | }
|
153 75 | }
|
154 76 | /// Returns true if this is a [`ToolUse`](crate::types::ContentBlock::ToolUse).
|
155 77 | pub fn is_tool_use(&self) -> bool {
|
156 78 | self.as_tool_use().is_ok()
|
157 79 | }
|
158 - | /// Tries to convert the enum instance into [`Video`](crate::types::ContentBlock::Video), extracting the inner [`VideoBlock`](crate::types::VideoBlock).
|
159 - | /// Returns `Err(&Self)` if it can't be converted.
|
160 - | pub fn as_video(&self) -> ::std::result::Result<&crate::types::VideoBlock, &Self> {
|
161 - | if let ContentBlock::Video(val) = &self {
|
162 - | ::std::result::Result::Ok(val)
|
163 - | } else {
|
164 - | ::std::result::Result::Err(self)
|
165 - | }
|
166 - | }
|
167 - | /// Returns true if this is a [`Video`](crate::types::ContentBlock::Video).
|
168 - | pub fn is_video(&self) -> bool {
|
169 - | self.as_video().is_ok()
|
170 - | }
|
171 80 | /// Returns true if the enum instance is the `Unknown` variant.
|
172 81 | pub fn is_unknown(&self) -> bool {
|
173 82 | matches!(self, Self::Unknown)
|
174 83 | }
|
175 84 | }
|
176 - | impl ::std::fmt::Debug for ContentBlock {
|
177 - | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
178 - | match self {
|
179 - | ContentBlock::CachePoint(val) => f.debug_tuple("CachePoint").field(&val).finish(),
|
180 - | ContentBlock::CitationsContent(val) => f.debug_tuple("CitationsContent").field(&val).finish(),
|
181 - | ContentBlock::Document(val) => f.debug_tuple("Document").field(&val).finish(),
|
182 - | ContentBlock::GuardContent(val) => f.debug_tuple("GuardContent").field(&val).finish(),
|
183 - | ContentBlock::Image(val) => f.debug_tuple("Image").field(&val).finish(),
|
184 - | ContentBlock::ReasoningContent(_) => f.debug_tuple("*** Sensitive Data Redacted ***").finish(),
|
185 - | ContentBlock::Text(val) => f.debug_tuple("Text").field(&val).finish(),
|
186 - | ContentBlock::ToolResult(val) => f.debug_tuple("ToolResult").field(&val).finish(),
|
187 - | ContentBlock::ToolUse(val) => f.debug_tuple("ToolUse").field(&val).finish(),
|
188 - | ContentBlock::Video(val) => f.debug_tuple("Video").field(&val).finish(),
|
189 - | ContentBlock::Unknown => f.debug_tuple("Unknown").finish(),
|
190 - | }
|
191 - | }
|
192 - | }
|