aws-sdk-context 1.0.0

AWS SDK for AWS Context
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>Answers a natural-language question against an agent context and streams the work as it happens. The response is an event stream that contains progress events while AWS Context searches the agent context, the answer in chunks as it is generated, and a final result. The final result contains the answer and the ranked retrieved context.</p>
///
/// [`AgenticRetrieveStreamOutput`](crate::operation::agentic_retrieve_stream::AgenticRetrieveStreamOutput) contains an event stream field as well as one or more non-event stream fields.
/// Due to its current implementation, the non-event stream fields are not fully deserialized
/// until the [`send`](Self::send) method completes. As a result, accessing these fields of the operation
/// output struct within an interceptor may return uninitialized values.
///
#[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
    }
    /// <p>The agent context to retrieve from, by its ID or ARN.</p>
    pub fn agent_context_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.agent_context_id(input.into());
        self
    }
    /// <p>The agent context to retrieve from, by its ID or ARN.</p>
    pub fn set_agent_context_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_agent_context_id(input);
        self
    }
    /// <p>The agent context to retrieve from, by its ID or ARN.</p>
    pub fn get_agent_context_id(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_agent_context_id()
    }
    ///
    /// Appends an item to `messages`.
    ///
    /// To override the contents of this collection use [`set_messages`](Self::set_messages).
    ///
    /// <p>The conversation, as an ordered list of turns. A single-question caller sends one user message. The list carries multi-turn history so a follow-up resolves against earlier turns.</p>
    pub fn messages(mut self, input: crate::types::Message) -> Self {
        self.inner = self.inner.messages(input);
        self
    }
    /// <p>The conversation, as an ordered list of turns. A single-question caller sends one user message. The list carries multi-turn history so a follow-up resolves against earlier turns.</p>
    pub fn set_messages(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Message>>) -> Self {
        self.inner = self.inner.set_messages(input);
        self
    }
    /// <p>The conversation, as an ordered list of turns. A single-question caller sends one user message. The list carries multi-turn history so a follow-up resolves against earlier turns.</p>
    pub fn get_messages(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Message>> {
        self.inner.get_messages()
    }
    /// <p>Optional. A key that you supply to group related calls, for example the turns of one conversation, for trace storage and analysis. Grouping is per account, across agent contexts, so use a value that is unique to each conversation.</p>
    pub fn session_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.session_id(input.into());
        self
    }
    /// <p>Optional. A key that you supply to group related calls, for example the turns of one conversation, for trace storage and analysis. Grouping is per account, across agent contexts, so use a value that is unique to each conversation.</p>
    pub fn set_session_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_session_id(input);
        self
    }
    /// <p>Optional. A key that you supply to group related calls, for example the turns of one conversation, for trace storage and analysis. Grouping is per account, across agent contexts, so use a value that is unique to each conversation.</p>
    pub fn get_session_id(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_session_id()
    }
    /// <p>Optional controls for post-call analysis of the retrieval: whether its trace is stored for analysis. Trace events are streamed either way.</p>
    pub fn analysis_configuration(mut self, input: crate::types::AnalysisConfiguration) -> Self {
        self.inner = self.inner.analysis_configuration(input);
        self
    }
    /// <p>Optional controls for post-call analysis of the retrieval: whether its trace is stored for analysis. Trace events are streamed either way.</p>
    pub fn set_analysis_configuration(mut self, input: ::std::option::Option<crate::types::AnalysisConfiguration>) -> Self {
        self.inner = self.inner.set_analysis_configuration(input);
        self
    }
    /// <p>Optional controls for post-call analysis of the retrieval: whether its trace is stored for analysis. Trace events are streamed either way.</p>
    pub fn get_analysis_configuration(&self) -> &::std::option::Option<crate::types::AnalysisConfiguration> {
        self.inner.get_analysis_configuration()
    }
    /// <p>Optional bounds and configuration for the agent loop.</p>
    pub fn retrieval_configuration(mut self, input: crate::types::StreamRetrievalConfiguration) -> Self {
        self.inner = self.inner.retrieval_configuration(input);
        self
    }
    /// <p>Optional bounds and configuration for the agent loop.</p>
    pub fn set_retrieval_configuration(mut self, input: ::std::option::Option<crate::types::StreamRetrievalConfiguration>) -> Self {
        self.inner = self.inner.set_retrieval_configuration(input);
        self
    }
    /// <p>Optional bounds and configuration for the agent loop.</p>
    pub fn get_retrieval_configuration(&self) -> &::std::option::Option<crate::types::StreamRetrievalConfiguration> {
        self.inner.get_retrieval_configuration()
    }
}