aws_sdk_bedrockruntime/operation/count_tokens/
_count_tokens_input.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 CountTokensInput {
6    /// <p>The unique identifier or ARN of the foundation model to use for token counting. Each model processes tokens differently, so the token count is specific to the model you specify.</p>
7    pub model_id: ::std::option::Option<::std::string::String>,
8    /// <p>The input for which to count tokens. The structure of this parameter depends on whether you're counting tokens for an <code>InvokeModel</code> or <code>Converse</code> request:</p>
9    /// <ul>
10    /// <li>
11    /// <p>For <code>InvokeModel</code> requests, provide the request body in the <code>invokeModel</code> field</p></li>
12    /// <li>
13    /// <p>For <code>Converse</code> requests, provide the messages and system content in the <code>converse</code> field</p></li>
14    /// </ul>
15    /// <p>The input format must be compatible with the model specified in the <code>modelId</code> parameter.</p>
16    pub input: ::std::option::Option<crate::types::CountTokensInput>,
17}
18impl CountTokensInput {
19    /// <p>The unique identifier or ARN of the foundation model to use for token counting. Each model processes tokens differently, so the token count is specific to the model you specify.</p>
20    pub fn model_id(&self) -> ::std::option::Option<&str> {
21        self.model_id.as_deref()
22    }
23    /// <p>The input for which to count tokens. The structure of this parameter depends on whether you're counting tokens for an <code>InvokeModel</code> or <code>Converse</code> request:</p>
24    /// <ul>
25    /// <li>
26    /// <p>For <code>InvokeModel</code> requests, provide the request body in the <code>invokeModel</code> field</p></li>
27    /// <li>
28    /// <p>For <code>Converse</code> requests, provide the messages and system content in the <code>converse</code> field</p></li>
29    /// </ul>
30    /// <p>The input format must be compatible with the model specified in the <code>modelId</code> parameter.</p>
31    pub fn input(&self) -> ::std::option::Option<&crate::types::CountTokensInput> {
32        self.input.as_ref()
33    }
34}
35impl CountTokensInput {
36    /// Creates a new builder-style object to manufacture [`CountTokensInput`](crate::operation::count_tokens::CountTokensInput).
37    pub fn builder() -> crate::operation::count_tokens::builders::CountTokensInputBuilder {
38        crate::operation::count_tokens::builders::CountTokensInputBuilder::default()
39    }
40}
41
42/// A builder for [`CountTokensInput`](crate::operation::count_tokens::CountTokensInput).
43#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
44#[non_exhaustive]
45pub struct CountTokensInputBuilder {
46    pub(crate) model_id: ::std::option::Option<::std::string::String>,
47    pub(crate) input: ::std::option::Option<crate::types::CountTokensInput>,
48}
49impl CountTokensInputBuilder {
50    /// <p>The unique identifier or ARN of the foundation model to use for token counting. Each model processes tokens differently, so the token count is specific to the model you specify.</p>
51    /// This field is required.
52    pub fn model_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
53        self.model_id = ::std::option::Option::Some(input.into());
54        self
55    }
56    /// <p>The unique identifier or ARN of the foundation model to use for token counting. Each model processes tokens differently, so the token count is specific to the model you specify.</p>
57    pub fn set_model_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
58        self.model_id = input;
59        self
60    }
61    /// <p>The unique identifier or ARN of the foundation model to use for token counting. Each model processes tokens differently, so the token count is specific to the model you specify.</p>
62    pub fn get_model_id(&self) -> &::std::option::Option<::std::string::String> {
63        &self.model_id
64    }
65    /// <p>The input for which to count tokens. The structure of this parameter depends on whether you're counting tokens for an <code>InvokeModel</code> or <code>Converse</code> request:</p>
66    /// <ul>
67    /// <li>
68    /// <p>For <code>InvokeModel</code> requests, provide the request body in the <code>invokeModel</code> field</p></li>
69    /// <li>
70    /// <p>For <code>Converse</code> requests, provide the messages and system content in the <code>converse</code> field</p></li>
71    /// </ul>
72    /// <p>The input format must be compatible with the model specified in the <code>modelId</code> parameter.</p>
73    /// This field is required.
74    pub fn input(mut self, input: crate::types::CountTokensInput) -> Self {
75        self.input = ::std::option::Option::Some(input);
76        self
77    }
78    /// <p>The input for which to count tokens. The structure of this parameter depends on whether you're counting tokens for an <code>InvokeModel</code> or <code>Converse</code> request:</p>
79    /// <ul>
80    /// <li>
81    /// <p>For <code>InvokeModel</code> requests, provide the request body in the <code>invokeModel</code> field</p></li>
82    /// <li>
83    /// <p>For <code>Converse</code> requests, provide the messages and system content in the <code>converse</code> field</p></li>
84    /// </ul>
85    /// <p>The input format must be compatible with the model specified in the <code>modelId</code> parameter.</p>
86    pub fn set_input(mut self, input: ::std::option::Option<crate::types::CountTokensInput>) -> Self {
87        self.input = input;
88        self
89    }
90    /// <p>The input for which to count tokens. The structure of this parameter depends on whether you're counting tokens for an <code>InvokeModel</code> or <code>Converse</code> request:</p>
91    /// <ul>
92    /// <li>
93    /// <p>For <code>InvokeModel</code> requests, provide the request body in the <code>invokeModel</code> field</p></li>
94    /// <li>
95    /// <p>For <code>Converse</code> requests, provide the messages and system content in the <code>converse</code> field</p></li>
96    /// </ul>
97    /// <p>The input format must be compatible with the model specified in the <code>modelId</code> parameter.</p>
98    pub fn get_input(&self) -> &::std::option::Option<crate::types::CountTokensInput> {
99        &self.input
100    }
101    /// Consumes the builder and constructs a [`CountTokensInput`](crate::operation::count_tokens::CountTokensInput).
102    pub fn build(self) -> ::std::result::Result<crate::operation::count_tokens::CountTokensInput, ::aws_smithy_types::error::operation::BuildError> {
103        ::std::result::Result::Ok(crate::operation::count_tokens::CountTokensInput {
104            model_id: self.model_id,
105            input: self.input,
106        })
107    }
108}