Skip to main content

aws_sdk_context/operation/agentic_retrieve/
_agentic_retrieve_output.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// The result of a retrieval. `retrievedContext` is always present. A response that only asks for authorization carries `authorizationRequired` beside an empty `retrievedContext`.
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
6pub struct AgenticRetrieveOutput {
7    /// The ranked, structured context that the agent assembled across all iterations, without duplicates. Always present. Each entry is a graph node, a graph edge, or a document.
8    pub retrieved_context: ::std::vec::Vec<crate::types::RetrievedContext>,
9    /// The synthesized natural-language answer, when one was generated.
10    pub answer: ::std::option::Option<::std::string::String>,
11    /// Maps spans of answer to the supporting entities, when an answer was generated.
12    pub citations: ::std::option::Option<::std::vec::Vec<crate::types::Citation>>,
13    /// Present when you must authorize access to a third-party resource. If `retrievedContext` is empty, no result was retrieved. Otherwise, the result leaves out one or more resources that you have not authorized. Show `authorizationUrl` to the user and retry after they consent.
14    pub authorization_required: ::std::option::Option<crate::types::AuthorizationRequired>,
15    _request_id: Option<String>,
16}
17impl AgenticRetrieveOutput {
18    /// The ranked, structured context that the agent assembled across all iterations, without duplicates. Always present. Each entry is a graph node, a graph edge, or a document.
19    pub fn retrieved_context(&self) -> &[crate::types::RetrievedContext] {
20        use std::ops::Deref;
21        self.retrieved_context.deref()
22    }
23    /// The synthesized natural-language answer, when one was generated.
24    pub fn answer(&self) -> ::std::option::Option<&str> {
25        self.answer.as_deref()
26    }
27    /// Maps spans of answer to the supporting entities, when an answer was generated.
28    ///
29    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.citations.is_none()`.
30    pub fn citations(&self) -> &[crate::types::Citation] {
31        self.citations.as_deref().unwrap_or_default()
32    }
33    /// Present when you must authorize access to a third-party resource. If `retrievedContext` is empty, no result was retrieved. Otherwise, the result leaves out one or more resources that you have not authorized. Show `authorizationUrl` to the user and retry after they consent.
34    pub fn authorization_required(&self) -> ::std::option::Option<&crate::types::AuthorizationRequired> {
35        self.authorization_required.as_ref()
36    }
37}
38impl ::std::fmt::Debug for AgenticRetrieveOutput {
39    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
40        let mut formatter = f.debug_struct("AgenticRetrieveOutput");
41        formatter.field("retrieved_context", &self.retrieved_context);
42        formatter.field("answer", &"*** Sensitive Data Redacted ***");
43        formatter.field("citations", &self.citations);
44        formatter.field("authorization_required", &self.authorization_required);
45        formatter.field("_request_id", &self._request_id);
46        formatter.finish()
47    }
48}
49impl ::aws_types::request_id::RequestId for AgenticRetrieveOutput {
50    fn request_id(&self) -> Option<&str> {
51        self._request_id.as_deref()
52    }
53}
54impl AgenticRetrieveOutput {
55    /// Creates a new builder-style object to manufacture [`AgenticRetrieveOutput`](crate::operation::agentic_retrieve::AgenticRetrieveOutput).
56    pub fn builder() -> crate::operation::agentic_retrieve::builders::AgenticRetrieveOutputBuilder {
57        crate::operation::agentic_retrieve::builders::AgenticRetrieveOutputBuilder::default()
58    }
59}
60
61/// A builder for [`AgenticRetrieveOutput`](crate::operation::agentic_retrieve::AgenticRetrieveOutput).
62#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default)]
63#[non_exhaustive]
64pub struct AgenticRetrieveOutputBuilder {
65    pub(crate) retrieved_context: ::std::option::Option<::std::vec::Vec<crate::types::RetrievedContext>>,
66    pub(crate) answer: ::std::option::Option<::std::string::String>,
67    pub(crate) citations: ::std::option::Option<::std::vec::Vec<crate::types::Citation>>,
68    pub(crate) authorization_required: ::std::option::Option<crate::types::AuthorizationRequired>,
69    _request_id: Option<String>,
70}
71impl AgenticRetrieveOutputBuilder {
72    /// Appends an item to `retrieved_context`.
73    ///
74    /// To override the contents of this collection use [`set_retrieved_context`](Self::set_retrieved_context).
75    ///
76    /// The ranked, structured context that the agent assembled across all iterations, without duplicates. Always present. Each entry is a graph node, a graph edge, or a document.
77    pub fn retrieved_context(mut self, input: crate::types::RetrievedContext) -> Self {
78        let mut v = self.retrieved_context.unwrap_or_default();
79        v.push(input);
80        self.retrieved_context = ::std::option::Option::Some(v);
81        self
82    }
83    /// The ranked, structured context that the agent assembled across all iterations, without duplicates. Always present. Each entry is a graph node, a graph edge, or a document.
84    pub fn set_retrieved_context(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::RetrievedContext>>) -> Self {
85        self.retrieved_context = input;
86        self
87    }
88    /// The ranked, structured context that the agent assembled across all iterations, without duplicates. Always present. Each entry is a graph node, a graph edge, or a document.
89    pub fn get_retrieved_context(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::RetrievedContext>> {
90        &self.retrieved_context
91    }
92    /// The synthesized natural-language answer, when one was generated.
93    pub fn answer(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
94        self.answer = ::std::option::Option::Some(input.into());
95        self
96    }
97    /// The synthesized natural-language answer, when one was generated.
98    pub fn set_answer(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
99        self.answer = input;
100        self
101    }
102    /// The synthesized natural-language answer, when one was generated.
103    pub fn get_answer(&self) -> &::std::option::Option<::std::string::String> {
104        &self.answer
105    }
106    /// Appends an item to `citations`.
107    ///
108    /// To override the contents of this collection use [`set_citations`](Self::set_citations).
109    ///
110    /// Maps spans of answer to the supporting entities, when an answer was generated.
111    pub fn citations(mut self, input: crate::types::Citation) -> Self {
112        let mut v = self.citations.unwrap_or_default();
113        v.push(input);
114        self.citations = ::std::option::Option::Some(v);
115        self
116    }
117    /// Maps spans of answer to the supporting entities, when an answer was generated.
118    pub fn set_citations(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Citation>>) -> Self {
119        self.citations = input;
120        self
121    }
122    /// Maps spans of answer to the supporting entities, when an answer was generated.
123    pub fn get_citations(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Citation>> {
124        &self.citations
125    }
126    /// Present when you must authorize access to a third-party resource. If `retrievedContext` is empty, no result was retrieved. Otherwise, the result leaves out one or more resources that you have not authorized. Show `authorizationUrl` to the user and retry after they consent.
127    pub fn authorization_required(mut self, input: crate::types::AuthorizationRequired) -> Self {
128        self.authorization_required = ::std::option::Option::Some(input);
129        self
130    }
131    /// Present when you must authorize access to a third-party resource. If `retrievedContext` is empty, no result was retrieved. Otherwise, the result leaves out one or more resources that you have not authorized. Show `authorizationUrl` to the user and retry after they consent.
132    pub fn set_authorization_required(mut self, input: ::std::option::Option<crate::types::AuthorizationRequired>) -> Self {
133        self.authorization_required = input;
134        self
135    }
136    /// Present when you must authorize access to a third-party resource. If `retrievedContext` is empty, no result was retrieved. Otherwise, the result leaves out one or more resources that you have not authorized. Show `authorizationUrl` to the user and retry after they consent.
137    pub fn get_authorization_required(&self) -> &::std::option::Option<crate::types::AuthorizationRequired> {
138        &self.authorization_required
139    }
140    pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
141        self._request_id = Some(request_id.into());
142        self
143    }
144
145    pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
146        self._request_id = request_id;
147        self
148    }
149    /// Consumes the builder and constructs a [`AgenticRetrieveOutput`](crate::operation::agentic_retrieve::AgenticRetrieveOutput).
150    /// This method will fail if any of the following fields are not set:
151    /// - [`retrieved_context`](crate::operation::agentic_retrieve::builders::AgenticRetrieveOutputBuilder::retrieved_context)
152    pub fn build(
153        self,
154    ) -> ::std::result::Result<crate::operation::agentic_retrieve::AgenticRetrieveOutput, ::aws_smithy_types::error::operation::BuildError> {
155        ::std::result::Result::Ok(crate::operation::agentic_retrieve::AgenticRetrieveOutput {
156            retrieved_context: self.retrieved_context.ok_or_else(|| {
157                ::aws_smithy_types::error::operation::BuildError::missing_field(
158                    "retrieved_context",
159                    "retrieved_context was not specified but it is required when building AgenticRetrieveOutput",
160                )
161            })?,
162            answer: self.answer,
163            citations: self.citations,
164            authorization_required: self.authorization_required,
165            _request_id: self._request_id,
166        })
167    }
168}
169impl ::std::fmt::Debug for AgenticRetrieveOutputBuilder {
170    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
171        let mut formatter = f.debug_struct("AgenticRetrieveOutputBuilder");
172        formatter.field("retrieved_context", &self.retrieved_context);
173        formatter.field("answer", &"*** Sensitive Data Redacted ***");
174        formatter.field("citations", &self.citations);
175        formatter.field("authorization_required", &self.authorization_required);
176        formatter.field("_request_id", &self._request_id);
177        formatter.finish()
178    }
179}