aws_sdk_bedrockagentruntime/operation/retrieve_and_generate_stream/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::retrieve_and_generate_stream::_retrieve_and_generate_stream_output::RetrieveAndGenerateStreamOutputBuilder;
3
4pub use crate::operation::retrieve_and_generate_stream::_retrieve_and_generate_stream_input::RetrieveAndGenerateStreamInputBuilder;
5
6impl crate::operation::retrieve_and_generate_stream::builders::RetrieveAndGenerateStreamInputBuilder {
7    /// Sends a request with this input using the given client.
8    pub async fn send_with(
9        self,
10        client: &crate::Client,
11    ) -> ::std::result::Result<
12        crate::operation::retrieve_and_generate_stream::RetrieveAndGenerateStreamOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::retrieve_and_generate_stream::RetrieveAndGenerateStreamError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.retrieve_and_generate_stream();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `RetrieveAndGenerateStream`.
24///
25/// <p>Queries a knowledge base and generates responses based on the retrieved results, with output in streaming format.</p><note>
26/// <p>The CLI doesn't support streaming operations in Amazon Bedrock, including <code>InvokeModelWithResponseStream</code>.</p>
27/// </note>
28/// <p>This operation requires permission for the <code> bedrock:RetrieveAndGenerate</code> action.</p>
29#[derive(::std::clone::Clone, ::std::fmt::Debug)]
30pub struct RetrieveAndGenerateStreamFluentBuilder {
31    handle: ::std::sync::Arc<crate::client::Handle>,
32    inner: crate::operation::retrieve_and_generate_stream::builders::RetrieveAndGenerateStreamInputBuilder,
33    config_override: ::std::option::Option<crate::config::Builder>,
34}
35impl
36    crate::client::customize::internal::CustomizableSend<
37        crate::operation::retrieve_and_generate_stream::RetrieveAndGenerateStreamOutput,
38        crate::operation::retrieve_and_generate_stream::RetrieveAndGenerateStreamError,
39    > for RetrieveAndGenerateStreamFluentBuilder
40{
41    fn send(
42        self,
43        config_override: crate::config::Builder,
44    ) -> crate::client::customize::internal::BoxFuture<
45        crate::client::customize::internal::SendResult<
46            crate::operation::retrieve_and_generate_stream::RetrieveAndGenerateStreamOutput,
47            crate::operation::retrieve_and_generate_stream::RetrieveAndGenerateStreamError,
48        >,
49    > {
50        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
51    }
52}
53impl RetrieveAndGenerateStreamFluentBuilder {
54    /// Creates a new `RetrieveAndGenerateStreamFluentBuilder`.
55    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
56        Self {
57            handle,
58            inner: ::std::default::Default::default(),
59            config_override: ::std::option::Option::None,
60        }
61    }
62    /// Access the RetrieveAndGenerateStream as a reference.
63    pub fn as_input(&self) -> &crate::operation::retrieve_and_generate_stream::builders::RetrieveAndGenerateStreamInputBuilder {
64        &self.inner
65    }
66    /// Sends the request and returns the response.
67    ///
68    /// If an error occurs, an `SdkError` will be returned with additional details that
69    /// can be matched against.
70    ///
71    /// By default, any retryable failures will be retried twice. Retry behavior
72    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
73    /// set when configuring the client.
74    pub async fn send(
75        self,
76    ) -> ::std::result::Result<
77        crate::operation::retrieve_and_generate_stream::RetrieveAndGenerateStreamOutput,
78        ::aws_smithy_runtime_api::client::result::SdkError<
79            crate::operation::retrieve_and_generate_stream::RetrieveAndGenerateStreamError,
80            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
81        >,
82    > {
83        let input = self
84            .inner
85            .build()
86            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
87        let runtime_plugins = crate::operation::retrieve_and_generate_stream::RetrieveAndGenerateStream::operation_runtime_plugins(
88            self.handle.runtime_plugins.clone(),
89            &self.handle.conf,
90            self.config_override,
91        );
92        crate::operation::retrieve_and_generate_stream::RetrieveAndGenerateStream::orchestrate(&runtime_plugins, input).await
93    }
94
95    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
96    pub fn customize(
97        self,
98    ) -> crate::client::customize::CustomizableOperation<
99        crate::operation::retrieve_and_generate_stream::RetrieveAndGenerateStreamOutput,
100        crate::operation::retrieve_and_generate_stream::RetrieveAndGenerateStreamError,
101        Self,
102    > {
103        crate::client::customize::CustomizableOperation::new(self)
104    }
105    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
106        self.set_config_override(::std::option::Option::Some(config_override.into()));
107        self
108    }
109
110    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
111        self.config_override = config_override;
112        self
113    }
114    /// <p>The unique identifier of the session. When you first make a <code>RetrieveAndGenerate</code> request, Amazon Bedrock automatically generates this value. You must reuse this value for all subsequent requests in the same conversational session. This value allows Amazon Bedrock to maintain context and knowledge from previous interactions. You can't explicitly set the <code>sessionId</code> yourself.</p>
115    pub fn session_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
116        self.inner = self.inner.session_id(input.into());
117        self
118    }
119    /// <p>The unique identifier of the session. When you first make a <code>RetrieveAndGenerate</code> request, Amazon Bedrock automatically generates this value. You must reuse this value for all subsequent requests in the same conversational session. This value allows Amazon Bedrock to maintain context and knowledge from previous interactions. You can't explicitly set the <code>sessionId</code> yourself.</p>
120    pub fn set_session_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
121        self.inner = self.inner.set_session_id(input);
122        self
123    }
124    /// <p>The unique identifier of the session. When you first make a <code>RetrieveAndGenerate</code> request, Amazon Bedrock automatically generates this value. You must reuse this value for all subsequent requests in the same conversational session. This value allows Amazon Bedrock to maintain context and knowledge from previous interactions. You can't explicitly set the <code>sessionId</code> yourself.</p>
125    pub fn get_session_id(&self) -> &::std::option::Option<::std::string::String> {
126        self.inner.get_session_id()
127    }
128    /// <p>Contains the query to be made to the knowledge base.</p>
129    pub fn input(mut self, input: crate::types::RetrieveAndGenerateInput) -> Self {
130        self.inner = self.inner.input(input);
131        self
132    }
133    /// <p>Contains the query to be made to the knowledge base.</p>
134    pub fn set_input(mut self, input: ::std::option::Option<crate::types::RetrieveAndGenerateInput>) -> Self {
135        self.inner = self.inner.set_input(input);
136        self
137    }
138    /// <p>Contains the query to be made to the knowledge base.</p>
139    pub fn get_input(&self) -> &::std::option::Option<crate::types::RetrieveAndGenerateInput> {
140        self.inner.get_input()
141    }
142    /// <p>Contains configurations for the knowledge base query and retrieval process. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html">Query configurations</a>.</p>
143    pub fn retrieve_and_generate_configuration(mut self, input: crate::types::RetrieveAndGenerateConfiguration) -> Self {
144        self.inner = self.inner.retrieve_and_generate_configuration(input);
145        self
146    }
147    /// <p>Contains configurations for the knowledge base query and retrieval process. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html">Query configurations</a>.</p>
148    pub fn set_retrieve_and_generate_configuration(mut self, input: ::std::option::Option<crate::types::RetrieveAndGenerateConfiguration>) -> Self {
149        self.inner = self.inner.set_retrieve_and_generate_configuration(input);
150        self
151    }
152    /// <p>Contains configurations for the knowledge base query and retrieval process. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html">Query configurations</a>.</p>
153    pub fn get_retrieve_and_generate_configuration(&self) -> &::std::option::Option<crate::types::RetrieveAndGenerateConfiguration> {
154        self.inner.get_retrieve_and_generate_configuration()
155    }
156    /// <p>Contains details about the session with the knowledge base.</p>
157    pub fn session_configuration(mut self, input: crate::types::RetrieveAndGenerateSessionConfiguration) -> Self {
158        self.inner = self.inner.session_configuration(input);
159        self
160    }
161    /// <p>Contains details about the session with the knowledge base.</p>
162    pub fn set_session_configuration(mut self, input: ::std::option::Option<crate::types::RetrieveAndGenerateSessionConfiguration>) -> Self {
163        self.inner = self.inner.set_session_configuration(input);
164        self
165    }
166    /// <p>Contains details about the session with the knowledge base.</p>
167    pub fn get_session_configuration(&self) -> &::std::option::Option<crate::types::RetrieveAndGenerateSessionConfiguration> {
168        self.inner.get_session_configuration()
169    }
170}