aws_sdk_bedrockruntime/operation/converse/
_converse_output.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(missing_docs)] // documentation missing in model
3#[non_exhaustive]
4#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
5pub struct ConverseOutput {
6    /// <p>The result from the call to <code>Converse</code>.</p>
7    pub output: ::std::option::Option<crate::types::ConverseOutput>,
8    /// <p>The reason why the model stopped generating output.</p>
9    pub stop_reason: crate::types::StopReason,
10    /// <p>The total number of tokens used in the call to <code>Converse</code>. The total includes the tokens input to the model and the tokens generated by the model.</p>
11    pub usage: ::std::option::Option<crate::types::TokenUsage>,
12    /// <p>Metrics for the call to <code>Converse</code>.</p>
13    pub metrics: ::std::option::Option<crate::types::ConverseMetrics>,
14    /// <p>Additional fields in the response that are unique to the model.</p>
15    pub additional_model_response_fields: ::std::option::Option<::aws_smithy_types::Document>,
16    /// <p>A trace object that contains information about the Guardrail behavior.</p>
17    pub trace: ::std::option::Option<crate::types::ConverseTrace>,
18    /// <p>Model performance settings for the request.</p>
19    pub performance_config: ::std::option::Option<crate::types::PerformanceConfiguration>,
20    /// <p>Specifies the processing tier configuration used for serving the request.</p>
21    pub service_tier: ::std::option::Option<crate::types::ServiceTier>,
22    _request_id: Option<String>,
23}
24impl ConverseOutput {
25    /// <p>The result from the call to <code>Converse</code>.</p>
26    pub fn output(&self) -> ::std::option::Option<&crate::types::ConverseOutput> {
27        self.output.as_ref()
28    }
29    /// <p>The reason why the model stopped generating output.</p>
30    pub fn stop_reason(&self) -> &crate::types::StopReason {
31        &self.stop_reason
32    }
33    /// <p>The total number of tokens used in the call to <code>Converse</code>. The total includes the tokens input to the model and the tokens generated by the model.</p>
34    pub fn usage(&self) -> ::std::option::Option<&crate::types::TokenUsage> {
35        self.usage.as_ref()
36    }
37    /// <p>Metrics for the call to <code>Converse</code>.</p>
38    pub fn metrics(&self) -> ::std::option::Option<&crate::types::ConverseMetrics> {
39        self.metrics.as_ref()
40    }
41    /// <p>Additional fields in the response that are unique to the model.</p>
42    pub fn additional_model_response_fields(&self) -> ::std::option::Option<&::aws_smithy_types::Document> {
43        self.additional_model_response_fields.as_ref()
44    }
45    /// <p>A trace object that contains information about the Guardrail behavior.</p>
46    pub fn trace(&self) -> ::std::option::Option<&crate::types::ConverseTrace> {
47        self.trace.as_ref()
48    }
49    /// <p>Model performance settings for the request.</p>
50    pub fn performance_config(&self) -> ::std::option::Option<&crate::types::PerformanceConfiguration> {
51        self.performance_config.as_ref()
52    }
53    /// <p>Specifies the processing tier configuration used for serving the request.</p>
54    pub fn service_tier(&self) -> ::std::option::Option<&crate::types::ServiceTier> {
55        self.service_tier.as_ref()
56    }
57}
58impl ::aws_types::request_id::RequestId for ConverseOutput {
59    fn request_id(&self) -> Option<&str> {
60        self._request_id.as_deref()
61    }
62}
63impl ConverseOutput {
64    /// Creates a new builder-style object to manufacture [`ConverseOutput`](crate::operation::converse::ConverseOutput).
65    pub fn builder() -> crate::operation::converse::builders::ConverseOutputBuilder {
66        crate::operation::converse::builders::ConverseOutputBuilder::default()
67    }
68}
69
70/// A builder for [`ConverseOutput`](crate::operation::converse::ConverseOutput).
71#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
72#[non_exhaustive]
73pub struct ConverseOutputBuilder {
74    pub(crate) output: ::std::option::Option<crate::types::ConverseOutput>,
75    pub(crate) stop_reason: ::std::option::Option<crate::types::StopReason>,
76    pub(crate) usage: ::std::option::Option<crate::types::TokenUsage>,
77    pub(crate) metrics: ::std::option::Option<crate::types::ConverseMetrics>,
78    pub(crate) additional_model_response_fields: ::std::option::Option<::aws_smithy_types::Document>,
79    pub(crate) trace: ::std::option::Option<crate::types::ConverseTrace>,
80    pub(crate) performance_config: ::std::option::Option<crate::types::PerformanceConfiguration>,
81    pub(crate) service_tier: ::std::option::Option<crate::types::ServiceTier>,
82    _request_id: Option<String>,
83}
84impl ConverseOutputBuilder {
85    /// <p>The result from the call to <code>Converse</code>.</p>
86    /// This field is required.
87    pub fn output(mut self, input: crate::types::ConverseOutput) -> Self {
88        self.output = ::std::option::Option::Some(input);
89        self
90    }
91    /// <p>The result from the call to <code>Converse</code>.</p>
92    pub fn set_output(mut self, input: ::std::option::Option<crate::types::ConverseOutput>) -> Self {
93        self.output = input;
94        self
95    }
96    /// <p>The result from the call to <code>Converse</code>.</p>
97    pub fn get_output(&self) -> &::std::option::Option<crate::types::ConverseOutput> {
98        &self.output
99    }
100    /// <p>The reason why the model stopped generating output.</p>
101    /// This field is required.
102    pub fn stop_reason(mut self, input: crate::types::StopReason) -> Self {
103        self.stop_reason = ::std::option::Option::Some(input);
104        self
105    }
106    /// <p>The reason why the model stopped generating output.</p>
107    pub fn set_stop_reason(mut self, input: ::std::option::Option<crate::types::StopReason>) -> Self {
108        self.stop_reason = input;
109        self
110    }
111    /// <p>The reason why the model stopped generating output.</p>
112    pub fn get_stop_reason(&self) -> &::std::option::Option<crate::types::StopReason> {
113        &self.stop_reason
114    }
115    /// <p>The total number of tokens used in the call to <code>Converse</code>. The total includes the tokens input to the model and the tokens generated by the model.</p>
116    /// This field is required.
117    pub fn usage(mut self, input: crate::types::TokenUsage) -> Self {
118        self.usage = ::std::option::Option::Some(input);
119        self
120    }
121    /// <p>The total number of tokens used in the call to <code>Converse</code>. The total includes the tokens input to the model and the tokens generated by the model.</p>
122    pub fn set_usage(mut self, input: ::std::option::Option<crate::types::TokenUsage>) -> Self {
123        self.usage = input;
124        self
125    }
126    /// <p>The total number of tokens used in the call to <code>Converse</code>. The total includes the tokens input to the model and the tokens generated by the model.</p>
127    pub fn get_usage(&self) -> &::std::option::Option<crate::types::TokenUsage> {
128        &self.usage
129    }
130    /// <p>Metrics for the call to <code>Converse</code>.</p>
131    /// This field is required.
132    pub fn metrics(mut self, input: crate::types::ConverseMetrics) -> Self {
133        self.metrics = ::std::option::Option::Some(input);
134        self
135    }
136    /// <p>Metrics for the call to <code>Converse</code>.</p>
137    pub fn set_metrics(mut self, input: ::std::option::Option<crate::types::ConverseMetrics>) -> Self {
138        self.metrics = input;
139        self
140    }
141    /// <p>Metrics for the call to <code>Converse</code>.</p>
142    pub fn get_metrics(&self) -> &::std::option::Option<crate::types::ConverseMetrics> {
143        &self.metrics
144    }
145    /// <p>Additional fields in the response that are unique to the model.</p>
146    pub fn additional_model_response_fields(mut self, input: ::aws_smithy_types::Document) -> Self {
147        self.additional_model_response_fields = ::std::option::Option::Some(input);
148        self
149    }
150    /// <p>Additional fields in the response that are unique to the model.</p>
151    pub fn set_additional_model_response_fields(mut self, input: ::std::option::Option<::aws_smithy_types::Document>) -> Self {
152        self.additional_model_response_fields = input;
153        self
154    }
155    /// <p>Additional fields in the response that are unique to the model.</p>
156    pub fn get_additional_model_response_fields(&self) -> &::std::option::Option<::aws_smithy_types::Document> {
157        &self.additional_model_response_fields
158    }
159    /// <p>A trace object that contains information about the Guardrail behavior.</p>
160    pub fn trace(mut self, input: crate::types::ConverseTrace) -> Self {
161        self.trace = ::std::option::Option::Some(input);
162        self
163    }
164    /// <p>A trace object that contains information about the Guardrail behavior.</p>
165    pub fn set_trace(mut self, input: ::std::option::Option<crate::types::ConverseTrace>) -> Self {
166        self.trace = input;
167        self
168    }
169    /// <p>A trace object that contains information about the Guardrail behavior.</p>
170    pub fn get_trace(&self) -> &::std::option::Option<crate::types::ConverseTrace> {
171        &self.trace
172    }
173    /// <p>Model performance settings for the request.</p>
174    pub fn performance_config(mut self, input: crate::types::PerformanceConfiguration) -> Self {
175        self.performance_config = ::std::option::Option::Some(input);
176        self
177    }
178    /// <p>Model performance settings for the request.</p>
179    pub fn set_performance_config(mut self, input: ::std::option::Option<crate::types::PerformanceConfiguration>) -> Self {
180        self.performance_config = input;
181        self
182    }
183    /// <p>Model performance settings for the request.</p>
184    pub fn get_performance_config(&self) -> &::std::option::Option<crate::types::PerformanceConfiguration> {
185        &self.performance_config
186    }
187    /// <p>Specifies the processing tier configuration used for serving the request.</p>
188    pub fn service_tier(mut self, input: crate::types::ServiceTier) -> Self {
189        self.service_tier = ::std::option::Option::Some(input);
190        self
191    }
192    /// <p>Specifies the processing tier configuration used for serving the request.</p>
193    pub fn set_service_tier(mut self, input: ::std::option::Option<crate::types::ServiceTier>) -> Self {
194        self.service_tier = input;
195        self
196    }
197    /// <p>Specifies the processing tier configuration used for serving the request.</p>
198    pub fn get_service_tier(&self) -> &::std::option::Option<crate::types::ServiceTier> {
199        &self.service_tier
200    }
201    pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
202        self._request_id = Some(request_id.into());
203        self
204    }
205
206    pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
207        self._request_id = request_id;
208        self
209    }
210    /// Consumes the builder and constructs a [`ConverseOutput`](crate::operation::converse::ConverseOutput).
211    /// This method will fail if any of the following fields are not set:
212    /// - [`stop_reason`](crate::operation::converse::builders::ConverseOutputBuilder::stop_reason)
213    pub fn build(self) -> ::std::result::Result<crate::operation::converse::ConverseOutput, ::aws_smithy_types::error::operation::BuildError> {
214        ::std::result::Result::Ok(crate::operation::converse::ConverseOutput {
215            output: self.output,
216            stop_reason: self.stop_reason.ok_or_else(|| {
217                ::aws_smithy_types::error::operation::BuildError::missing_field(
218                    "stop_reason",
219                    "stop_reason was not specified but it is required when building ConverseOutput",
220                )
221            })?,
222            usage: self.usage,
223            metrics: self.metrics,
224            additional_model_response_fields: self.additional_model_response_fields,
225            trace: self.trace,
226            performance_config: self.performance_config,
227            service_tier: self.service_tier,
228            _request_id: self._request_id,
229        })
230    }
231}