aws-sdk-bedrockagentruntime 1.131.0

AWS SDK for Agents for Amazon Bedrock Runtime
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub use crate::operation::agentic_retrieve_stream::_agentic_retrieve_stream_input::AgenticRetrieveStreamInputBuilder;

pub use crate::operation::agentic_retrieve_stream::_agentic_retrieve_stream_output::AgenticRetrieveStreamOutputBuilder;

impl crate::operation::agentic_retrieve_stream::builders::AgenticRetrieveStreamInputBuilder {
    /// Sends a request with this input using the given client.
    pub async fn send_with(
        self,
        client: &crate::Client,
    ) -> ::std::result::Result<
        crate::operation::agentic_retrieve_stream::AgenticRetrieveStreamOutput,
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::agentic_retrieve_stream::AgenticRetrieveStreamError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        >,
    > {
        let mut fluent_builder = client.agentic_retrieve_stream();
        fluent_builder.inner = self;
        fluent_builder.send().await
    }
}
/// Fluent builder constructing a request to `AgenticRetrieveStream`.
///
/// <p>Retrieves information from one or more knowledge bases using an agentic approach. Agentic retrieval uses a foundation model to intelligently decompose complex queries into sub-queries and iteratively retrieve relevant information from your knowledge bases. This approach improves retrieval accuracy for complex, multi-step questions that a single retrieval pass might not fully address.</p>
/// <p>The operation returns results through a stream that includes retrieval results, trace events for visibility into the process, and a generated response synthesized from the results by default, which can be turned off.</p>
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
pub struct AgenticRetrieveStreamFluentBuilder {
    handle: ::std::sync::Arc<crate::client::Handle>,
    inner: crate::operation::agentic_retrieve_stream::builders::AgenticRetrieveStreamInputBuilder,
    config_override: ::std::option::Option<crate::config::Builder>,
}
impl
    crate::client::customize::internal::CustomizableSend<
        crate::operation::agentic_retrieve_stream::AgenticRetrieveStreamOutput,
        crate::operation::agentic_retrieve_stream::AgenticRetrieveStreamError,
    > for AgenticRetrieveStreamFluentBuilder
{
    fn send(
        self,
        config_override: crate::config::Builder,
    ) -> crate::client::customize::internal::BoxFuture<
        crate::client::customize::internal::SendResult<
            crate::operation::agentic_retrieve_stream::AgenticRetrieveStreamOutput,
            crate::operation::agentic_retrieve_stream::AgenticRetrieveStreamError,
        >,
    > {
        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
    }
}
impl AgenticRetrieveStreamFluentBuilder {
    /// Creates a new `AgenticRetrieveStreamFluentBuilder`.
    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
        Self {
            handle,
            inner: ::std::default::Default::default(),
            config_override: ::std::option::Option::None,
        }
    }
    /// Access the AgenticRetrieveStream as a reference.
    pub fn as_input(&self) -> &crate::operation::agentic_retrieve_stream::builders::AgenticRetrieveStreamInputBuilder {
        &self.inner
    }
    /// Sends the request and returns the response.
    ///
    /// If an error occurs, an `SdkError` will be returned with additional details that
    /// can be matched against.
    ///
    /// By default, any retryable failures will be retried twice. Retry behavior
    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
    /// set when configuring the client.
    pub async fn send(
        self,
    ) -> ::std::result::Result<
        crate::operation::agentic_retrieve_stream::AgenticRetrieveStreamOutput,
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::agentic_retrieve_stream::AgenticRetrieveStreamError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        >,
    > {
        let input = self
            .inner
            .build()
            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
        let runtime_plugins = crate::operation::agentic_retrieve_stream::AgenticRetrieveStream::operation_runtime_plugins(
            self.handle.runtime_plugins.clone(),
            &self.handle.conf,
            self.config_override,
        );
        let mut output = crate::operation::agentic_retrieve_stream::AgenticRetrieveStream::orchestrate(&runtime_plugins, input).await?;

        // Converts any error encountered beyond this point into an `SdkError` response error
        // with an `HttpResponse`. However, since we have already exited the `orchestrate`
        // function, the original `HttpResponse` is no longer available and cannot be restored.
        // This means that header information from the original response has been lost.
        //
        // Note that the response body would have been consumed by the deserializer
        // regardless, even if the initial message was hypothetically processed during
        // the orchestrator's deserialization phase but later resulted in an error.
        fn response_error(
            err: impl ::std::convert::Into<::aws_smithy_runtime_api::box_error::BoxError>,
        ) -> ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::agentic_retrieve_stream::AgenticRetrieveStreamError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        > {
            ::aws_smithy_runtime_api::client::result::SdkError::response_error(
                err,
                ::aws_smithy_runtime_api::client::orchestrator::HttpResponse::new(
                    ::aws_smithy_runtime_api::http::StatusCode::try_from(200).expect("valid successful code"),
                    ::aws_smithy_types::body::SdkBody::empty(),
                ),
            )
        }

        let message = output.stream.try_recv_initial_response().await.map_err(response_error)?;

        match message {
            ::std::option::Option::Some(_message) => ::std::result::Result::Ok(output),
            ::std::option::Option::None => ::std::result::Result::Ok(output),
        }
    }

    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
    pub fn customize(
        self,
    ) -> crate::client::customize::CustomizableOperation<
        crate::operation::agentic_retrieve_stream::AgenticRetrieveStreamOutput,
        crate::operation::agentic_retrieve_stream::AgenticRetrieveStreamError,
        Self,
    > {
        crate::client::customize::CustomizableOperation::new(self)
    }
    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
        self.set_config_override(::std::option::Option::Some(config_override.into()));
        self
    }

    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
        self.config_override = config_override;
        self
    }
    ///
    /// Appends an item to `messages`.
    ///
    /// To override the contents of this collection use [`set_messages`](Self::set_messages).
    ///
    /// <p>The list of messages for the agentic retrieval conversation.</p>
    pub fn messages(mut self, input: crate::types::AgenticRetrieveMessage) -> Self {
        self.inner = self.inner.messages(input);
        self
    }
    /// <p>The list of messages for the agentic retrieval conversation.</p>
    pub fn set_messages(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::AgenticRetrieveMessage>>) -> Self {
        self.inner = self.inner.set_messages(input);
        self
    }
    /// <p>The list of messages for the agentic retrieval conversation.</p>
    pub fn get_messages(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::AgenticRetrieveMessage>> {
        self.inner.get_messages()
    }
    ///
    /// Appends an item to `retrievers`.
    ///
    /// To override the contents of this collection use [`set_retrievers`](Self::set_retrievers).
    ///
    /// <p>The list of retrievers to use for agentic retrieval.</p>
    pub fn retrievers(mut self, input: crate::types::AgenticRetriever) -> Self {
        self.inner = self.inner.retrievers(input);
        self
    }
    /// <p>The list of retrievers to use for agentic retrieval.</p>
    pub fn set_retrievers(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::AgenticRetriever>>) -> Self {
        self.inner = self.inner.set_retrievers(input);
        self
    }
    /// <p>The list of retrievers to use for agentic retrieval.</p>
    pub fn get_retrievers(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::AgenticRetriever>> {
        self.inner.get_retrievers()
    }
    /// <p>Configuration settings for the agentic retrieval operation.</p>
    pub fn agentic_retrieve_configuration(mut self, input: crate::types::AgenticRetrieveConfiguration) -> Self {
        self.inner = self.inner.agentic_retrieve_configuration(input);
        self
    }
    /// <p>Configuration settings for the agentic retrieval operation.</p>
    pub fn set_agentic_retrieve_configuration(mut self, input: ::std::option::Option<crate::types::AgenticRetrieveConfiguration>) -> Self {
        self.inner = self.inner.set_agentic_retrieve_configuration(input);
        self
    }
    /// <p>Configuration settings for the agentic retrieval operation.</p>
    pub fn get_agentic_retrieve_configuration(&self) -> &::std::option::Option<crate::types::AgenticRetrieveConfiguration> {
        self.inner.get_agentic_retrieve_configuration()
    }
    /// <p>Policy configuration for guardrails and content filtering.</p>
    pub fn policy_configuration(mut self, input: crate::types::AgenticRetrievePolicyConfiguration) -> Self {
        self.inner = self.inner.policy_configuration(input);
        self
    }
    /// <p>Policy configuration for guardrails and content filtering.</p>
    pub fn set_policy_configuration(mut self, input: ::std::option::Option<crate::types::AgenticRetrievePolicyConfiguration>) -> Self {
        self.inner = self.inner.set_policy_configuration(input);
        self
    }
    /// <p>Policy configuration for guardrails and content filtering.</p>
    pub fn get_policy_configuration(&self) -> &::std::option::Option<crate::types::AgenticRetrievePolicyConfiguration> {
        self.inner.get_policy_configuration()
    }
    /// <p>Opaque continuation token for paginated results.</p>
    pub fn next_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.next_token(input.into());
        self
    }
    /// <p>Opaque continuation token for paginated results.</p>
    pub fn set_next_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_next_token(input);
        self
    }
    /// <p>Opaque continuation token for paginated results.</p>
    pub fn get_next_token(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_next_token()
    }
    /// <p>Contains information about the user making the request. This is used for access control filtering to ensure that retrieval results only include documents the user is authorized to access.</p>
    pub fn user_context(mut self, input: crate::types::UserContext) -> Self {
        self.inner = self.inner.user_context(input);
        self
    }
    /// <p>Contains information about the user making the request. This is used for access control filtering to ensure that retrieval results only include documents the user is authorized to access.</p>
    pub fn set_user_context(mut self, input: ::std::option::Option<crate::types::UserContext>) -> Self {
        self.inner = self.inner.set_user_context(input);
        self
    }
    /// <p>Contains information about the user making the request. This is used for access control filtering to ensure that retrieval results only include documents the user is authorized to access.</p>
    pub fn get_user_context(&self) -> &::std::option::Option<crate::types::UserContext> {
        self.inner.get_user_context()
    }
    /// <p>Whether to generate a response based on the retrieved results.</p>
    pub fn generate_response(mut self, input: bool) -> Self {
        self.inner = self.inner.generate_response(input);
        self
    }
    /// <p>Whether to generate a response based on the retrieved results.</p>
    pub fn set_generate_response(mut self, input: ::std::option::Option<bool>) -> Self {
        self.inner = self.inner.set_generate_response(input);
        self
    }
    /// <p>Whether to generate a response based on the retrieved results.</p>
    pub fn get_generate_response(&self) -> &::std::option::Option<bool> {
        self.inner.get_generate_response()
    }
}