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