aws_sdk_bedrockruntime/operation/count_tokens/_count_tokens_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 CountTokensOutput {
6 /// <p>The number of tokens in the provided input according to the specified model's tokenization rules. This count represents the number of input tokens that would be processed if the same input were sent to the model in an inference request. Use this value to estimate costs and ensure your inputs stay within model token limits.</p>
7 pub input_tokens: i32,
8 _request_id: Option<String>,
9}
10impl CountTokensOutput {
11 /// <p>The number of tokens in the provided input according to the specified model's tokenization rules. This count represents the number of input tokens that would be processed if the same input were sent to the model in an inference request. Use this value to estimate costs and ensure your inputs stay within model token limits.</p>
12 pub fn input_tokens(&self) -> i32 {
13 self.input_tokens
14 }
15}
16impl ::aws_types::request_id::RequestId for CountTokensOutput {
17 fn request_id(&self) -> Option<&str> {
18 self._request_id.as_deref()
19 }
20}
21impl CountTokensOutput {
22 /// Creates a new builder-style object to manufacture [`CountTokensOutput`](crate::operation::count_tokens::CountTokensOutput).
23 pub fn builder() -> crate::operation::count_tokens::builders::CountTokensOutputBuilder {
24 crate::operation::count_tokens::builders::CountTokensOutputBuilder::default()
25 }
26}
27
28/// A builder for [`CountTokensOutput`](crate::operation::count_tokens::CountTokensOutput).
29#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
30#[non_exhaustive]
31pub struct CountTokensOutputBuilder {
32 pub(crate) input_tokens: ::std::option::Option<i32>,
33 _request_id: Option<String>,
34}
35impl CountTokensOutputBuilder {
36 /// <p>The number of tokens in the provided input according to the specified model's tokenization rules. This count represents the number of input tokens that would be processed if the same input were sent to the model in an inference request. Use this value to estimate costs and ensure your inputs stay within model token limits.</p>
37 /// This field is required.
38 pub fn input_tokens(mut self, input: i32) -> Self {
39 self.input_tokens = ::std::option::Option::Some(input);
40 self
41 }
42 /// <p>The number of tokens in the provided input according to the specified model's tokenization rules. This count represents the number of input tokens that would be processed if the same input were sent to the model in an inference request. Use this value to estimate costs and ensure your inputs stay within model token limits.</p>
43 pub fn set_input_tokens(mut self, input: ::std::option::Option<i32>) -> Self {
44 self.input_tokens = input;
45 self
46 }
47 /// <p>The number of tokens in the provided input according to the specified model's tokenization rules. This count represents the number of input tokens that would be processed if the same input were sent to the model in an inference request. Use this value to estimate costs and ensure your inputs stay within model token limits.</p>
48 pub fn get_input_tokens(&self) -> &::std::option::Option<i32> {
49 &self.input_tokens
50 }
51 pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
52 self._request_id = Some(request_id.into());
53 self
54 }
55
56 pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
57 self._request_id = request_id;
58 self
59 }
60 /// Consumes the builder and constructs a [`CountTokensOutput`](crate::operation::count_tokens::CountTokensOutput).
61 /// This method will fail if any of the following fields are not set:
62 /// - [`input_tokens`](crate::operation::count_tokens::builders::CountTokensOutputBuilder::input_tokens)
63 pub fn build(self) -> ::std::result::Result<crate::operation::count_tokens::CountTokensOutput, ::aws_smithy_types::error::operation::BuildError> {
64 ::std::result::Result::Ok(crate::operation::count_tokens::CountTokensOutput {
65 input_tokens: self.input_tokens.ok_or_else(|| {
66 ::aws_smithy_types::error::operation::BuildError::missing_field(
67 "input_tokens",
68 "input_tokens was not specified but it is required when building CountTokensOutput",
69 )
70 })?,
71 _request_id: self._request_id,
72 })
73 }
74}