3 3 | /// <p>The tokens used in a message API inference call.</p>
|
4 4 | #[non_exhaustive]
|
5 5 | #[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
|
6 6 | pub struct TokenUsage {
|
7 7 | /// <p>The number of tokens sent in the request to the model.</p>
|
8 8 | pub input_tokens: i32,
|
9 9 | /// <p>The number of tokens that the model generated for the request.</p>
|
10 10 | pub output_tokens: i32,
|
11 11 | /// <p>The total of input tokens and tokens generated by the model.</p>
|
12 12 | pub total_tokens: i32,
|
13 - | /// <p>The number of input tokens read from the cache for the request.</p>
|
14 - | pub cache_read_input_tokens: ::std::option::Option<i32>,
|
15 - | /// <p>The number of input tokens written to the cache for the request.</p>
|
16 - | pub cache_write_input_tokens: ::std::option::Option<i32>,
|
17 13 | }
|
18 14 | impl TokenUsage {
|
19 15 | /// <p>The number of tokens sent in the request to the model.</p>
|
20 16 | pub fn input_tokens(&self) -> i32 {
|
21 17 | self.input_tokens
|
22 18 | }
|
23 19 | /// <p>The number of tokens that the model generated for the request.</p>
|
24 20 | pub fn output_tokens(&self) -> i32 {
|
25 21 | self.output_tokens
|
26 22 | }
|
27 23 | /// <p>The total of input tokens and tokens generated by the model.</p>
|
28 24 | pub fn total_tokens(&self) -> i32 {
|
29 25 | self.total_tokens
|
30 26 | }
|
31 - | /// <p>The number of input tokens read from the cache for the request.</p>
|
32 - | pub fn cache_read_input_tokens(&self) -> ::std::option::Option<i32> {
|
33 - | self.cache_read_input_tokens
|
34 - | }
|
35 - | /// <p>The number of input tokens written to the cache for the request.</p>
|
36 - | pub fn cache_write_input_tokens(&self) -> ::std::option::Option<i32> {
|
37 - | self.cache_write_input_tokens
|
38 - | }
|
39 27 | }
|
40 28 | impl TokenUsage {
|
41 29 | /// Creates a new builder-style object to manufacture [`TokenUsage`](crate::types::TokenUsage).
|
42 30 | pub fn builder() -> crate::types::builders::TokenUsageBuilder {
|
43 31 | crate::types::builders::TokenUsageBuilder::default()
|
44 32 | }
|
45 33 | }
|
46 34 |
|
47 35 | /// A builder for [`TokenUsage`](crate::types::TokenUsage).
|
48 36 | #[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
|
49 37 | #[non_exhaustive]
|
50 38 | pub struct TokenUsageBuilder {
|
51 39 | pub(crate) input_tokens: ::std::option::Option<i32>,
|
52 40 | pub(crate) output_tokens: ::std::option::Option<i32>,
|
53 41 | pub(crate) total_tokens: ::std::option::Option<i32>,
|
54 - | pub(crate) cache_read_input_tokens: ::std::option::Option<i32>,
|
55 - | pub(crate) cache_write_input_tokens: ::std::option::Option<i32>,
|
56 42 | }
|
57 43 | impl TokenUsageBuilder {
|
58 44 | /// <p>The number of tokens sent in the request to the model.</p>
|
59 45 | /// This field is required.
|
60 46 | pub fn input_tokens(mut self, input: i32) -> Self {
|
61 47 | self.input_tokens = ::std::option::Option::Some(input);
|
62 48 | self
|
63 49 | }
|
64 50 | /// <p>The number of tokens sent in the request to the model.</p>
|
65 51 | pub fn set_input_tokens(mut self, input: ::std::option::Option<i32>) -> Self {
|
66 52 | self.input_tokens = input;
|
67 53 | self
|
68 54 | }
|
69 55 | /// <p>The number of tokens sent in the request to the model.</p>
|
70 56 | pub fn get_input_tokens(&self) -> &::std::option::Option<i32> {
|
71 57 | &self.input_tokens
|
72 58 | }
|
73 59 | /// <p>The number of tokens that the model generated for the request.</p>
|
74 60 | /// This field is required.
|
75 61 | pub fn output_tokens(mut self, input: i32) -> Self {
|
76 62 | self.output_tokens = ::std::option::Option::Some(input);
|
77 63 | self
|
78 64 | }
|
79 65 | /// <p>The number of tokens that the model generated for the request.</p>
|
80 66 | pub fn set_output_tokens(mut self, input: ::std::option::Option<i32>) -> Self {
|
81 67 | self.output_tokens = input;
|
82 68 | self
|
83 69 | }
|
84 70 | /// <p>The number of tokens that the model generated for the request.</p>
|
85 71 | pub fn get_output_tokens(&self) -> &::std::option::Option<i32> {
|
86 72 | &self.output_tokens
|
87 73 | }
|
88 74 | /// <p>The total of input tokens and tokens generated by the model.</p>
|
89 75 | /// This field is required.
|
90 76 | pub fn total_tokens(mut self, input: i32) -> Self {
|
91 77 | self.total_tokens = ::std::option::Option::Some(input);
|
92 78 | self
|
93 79 | }
|
94 80 | /// <p>The total of input tokens and tokens generated by the model.</p>
|
95 81 | pub fn set_total_tokens(mut self, input: ::std::option::Option<i32>) -> Self {
|
96 82 | self.total_tokens = input;
|
97 83 | self
|
98 84 | }
|
99 85 | /// <p>The total of input tokens and tokens generated by the model.</p>
|
100 86 | pub fn get_total_tokens(&self) -> &::std::option::Option<i32> {
|
101 87 | &self.total_tokens
|
102 88 | }
|
103 - | /// <p>The number of input tokens read from the cache for the request.</p>
|
104 - | pub fn cache_read_input_tokens(mut self, input: i32) -> Self {
|
105 - | self.cache_read_input_tokens = ::std::option::Option::Some(input);
|
106 - | self
|
107 - | }
|
108 - | /// <p>The number of input tokens read from the cache for the request.</p>
|
109 - | pub fn set_cache_read_input_tokens(mut self, input: ::std::option::Option<i32>) -> Self {
|
110 - | self.cache_read_input_tokens = input;
|
111 - | self
|
112 - | }
|
113 - | /// <p>The number of input tokens read from the cache for the request.</p>
|
114 - | pub fn get_cache_read_input_tokens(&self) -> &::std::option::Option<i32> {
|
115 - | &self.cache_read_input_tokens
|
116 - | }
|
117 - | /// <p>The number of input tokens written to the cache for the request.</p>
|
118 - | pub fn cache_write_input_tokens(mut self, input: i32) -> Self {
|
119 - | self.cache_write_input_tokens = ::std::option::Option::Some(input);
|
120 - | self
|
121 - | }
|
122 - | /// <p>The number of input tokens written to the cache for the request.</p>
|
123 - | pub fn set_cache_write_input_tokens(mut self, input: ::std::option::Option<i32>) -> Self {
|
124 - | self.cache_write_input_tokens = input;
|
125 - | self
|
126 - | }
|
127 - | /// <p>The number of input tokens written to the cache for the request.</p>
|
128 - | pub fn get_cache_write_input_tokens(&self) -> &::std::option::Option<i32> {
|
129 - | &self.cache_write_input_tokens
|
130 - | }
|
131 89 | /// Consumes the builder and constructs a [`TokenUsage`](crate::types::TokenUsage).
|
132 90 | /// This method will fail if any of the following fields are not set:
|
133 91 | /// - [`input_tokens`](crate::types::builders::TokenUsageBuilder::input_tokens)
|
134 92 | /// - [`output_tokens`](crate::types::builders::TokenUsageBuilder::output_tokens)
|
135 93 | /// - [`total_tokens`](crate::types::builders::TokenUsageBuilder::total_tokens)
|
136 94 | pub fn build(self) -> ::std::result::Result<crate::types::TokenUsage, ::aws_smithy_types::error::operation::BuildError> {
|
137 95 | ::std::result::Result::Ok(crate::types::TokenUsage {
|
138 96 | input_tokens: self.input_tokens.ok_or_else(|| {
|
139 97 | ::aws_smithy_types::error::operation::BuildError::missing_field(
|
140 98 | "input_tokens",
|
141 99 | "input_tokens was not specified but it is required when building TokenUsage",
|
142 100 | )
|
143 101 | })?,
|
144 102 | output_tokens: self.output_tokens.ok_or_else(|| {
|
145 103 | ::aws_smithy_types::error::operation::BuildError::missing_field(
|
146 104 | "output_tokens",
|
147 105 | "output_tokens was not specified but it is required when building TokenUsage",
|
148 106 | )
|
149 107 | })?,
|
150 108 | total_tokens: self.total_tokens.ok_or_else(|| {
|
151 109 | ::aws_smithy_types::error::operation::BuildError::missing_field(
|
152 110 | "total_tokens",
|
153 111 | "total_tokens was not specified but it is required when building TokenUsage",
|
154 112 | )
|
155 113 | })?,
|
156 - | cache_read_input_tokens: self.cache_read_input_tokens,
|
157 - | cache_write_input_tokens: self.cache_write_input_tokens,
|
158 114 | })
|
159 115 | }
|
160 116 | }
|