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.</p>
|
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>
|
4 4 | #[non_exhaustive]
|
5 - | #[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
|
5 + | #[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
|
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),
|
7 16 | /// <p>Image to include in the message.</p><note>
|
8 17 | /// <p>This field is only supported by Anthropic Claude 3 models.</p>
|
9 18 | /// </note>
|
10 19 | 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),
|
11 22 | /// <p>Text to include in the message.</p>
|
12 23 | Text(::std::string::String),
|
13 24 | /// <p>The result for a tool request that a model makes.</p>
|
14 25 | ToolResult(crate::types::ToolResultBlock),
|
15 26 | /// <p>Information about a tool use request from a model.</p>
|
16 27 | ToolUse(crate::types::ToolUseBlock),
|
28 + | /// <p>Video to include in the message.</p>
|
29 + | Video(crate::types::VideoBlock),
|
17 30 | /// The `Unknown` variant represents cases where new union variant was received. Consider upgrading the SDK to the latest available version.
|
18 31 | /// An unknown enum variant
|
19 32 | ///
|
20 33 | /// _Note: If you encounter this error, consider upgrading your SDK to the latest version._
|
21 34 | /// The `Unknown` variant represents cases where the server sent a value that wasn't recognized
|
22 35 | /// by the client. This can happen when the server adds new functionality, but the client has not been updated.
|
23 36 | /// To investigate this, consider turning on debug logging to print the raw HTTP response.
|
24 37 | #[non_exhaustive]
|
25 38 | Unknown,
|
26 39 | }
|
27 40 | 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 + | }
|
28 93 | /// Tries to convert the enum instance into [`Image`](crate::types::ContentBlock::Image), extracting the inner [`ImageBlock`](crate::types::ImageBlock).
|
29 94 | /// Returns `Err(&Self)` if it can't be converted.
|
30 95 | pub fn as_image(&self) -> ::std::result::Result<&crate::types::ImageBlock, &Self> {
|
31 96 | if let ContentBlock::Image(val) = &self {
|
32 97 | ::std::result::Result::Ok(val)
|
33 98 | } else {
|
34 99 | ::std::result::Result::Err(self)
|
35 100 | }
|
36 101 | }
|
37 102 | /// Returns true if this is a [`Image`](crate::types::ContentBlock::Image).
|
38 103 | pub fn is_image(&self) -> bool {
|
39 104 | self.as_image().is_ok()
|
40 105 | }
|
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 + | }
|
41 119 | /// Tries to convert the enum instance into [`Text`](crate::types::ContentBlock::Text), extracting the inner [`String`](::std::string::String).
|
42 120 | /// Returns `Err(&Self)` if it can't be converted.
|
43 121 | pub fn as_text(&self) -> ::std::result::Result<&::std::string::String, &Self> {
|
44 122 | if let ContentBlock::Text(val) = &self {
|
45 123 | ::std::result::Result::Ok(val)
|
46 124 | } else {
|
47 125 | ::std::result::Result::Err(self)
|
48 126 | }
|
49 127 | }
|
50 128 | /// Returns true if this is a [`Text`](crate::types::ContentBlock::Text).
|
51 129 | pub fn is_text(&self) -> bool {
|
52 130 | self.as_text().is_ok()
|
53 131 | }
|
54 132 | /// Tries to convert the enum instance into [`ToolResult`](crate::types::ContentBlock::ToolResult), extracting the inner [`ToolResultBlock`](crate::types::ToolResultBlock).
|
55 133 | /// Returns `Err(&Self)` if it can't be converted.
|
56 134 | pub fn as_tool_result(&self) -> ::std::result::Result<&crate::types::ToolResultBlock, &Self> {
|
57 135 | if let ContentBlock::ToolResult(val) = &self {
|
58 136 | ::std::result::Result::Ok(val)
|
59 137 | } else {
|
60 138 | ::std::result::Result::Err(self)
|
61 139 | }
|
62 140 | }
|
63 141 | /// Returns true if this is a [`ToolResult`](crate::types::ContentBlock::ToolResult).
|
64 142 | pub fn is_tool_result(&self) -> bool {
|
65 143 | self.as_tool_result().is_ok()
|
66 144 | }
|
67 145 | /// Tries to convert the enum instance into [`ToolUse`](crate::types::ContentBlock::ToolUse), extracting the inner [`ToolUseBlock`](crate::types::ToolUseBlock).
|
68 146 | /// Returns `Err(&Self)` if it can't be converted.
|
69 147 | pub fn as_tool_use(&self) -> ::std::result::Result<&crate::types::ToolUseBlock, &Self> {
|
70 148 | if let ContentBlock::ToolUse(val) = &self {
|
71 149 | ::std::result::Result::Ok(val)
|
72 150 | } else {
|
73 151 | ::std::result::Result::Err(self)
|
74 152 | }
|
75 153 | }
|
76 154 | /// Returns true if this is a [`ToolUse`](crate::types::ContentBlock::ToolUse).
|
77 155 | pub fn is_tool_use(&self) -> bool {
|
78 156 | self.as_tool_use().is_ok()
|
79 157 | }
|
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 + | }
|
80 171 | /// Returns true if the enum instance is the `Unknown` variant.
|
81 172 | pub fn is_unknown(&self) -> bool {
|
82 173 | matches!(self, Self::Unknown)
|
83 174 | }
|
84 175 | }
|
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 + | }
|