aws-sdk-bedrockagentruntime 1.126.0

AWS SDK for Agents for Amazon Bedrock Runtime
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>An object containing a segment of the generated response that is based on a source in the knowledge base, alongside information about the source.</p>
/// <p>This data type is used in the following API operations:</p>
/// <ul>
/// <li>
/// <p><a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html#API_agent-runtime_InvokeAgent_ResponseSyntax">InvokeAgent response</a> – in the <code>citations</code> field</p></li>
/// <li>
/// <p><a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RetrieveAndGenerate.html#API_agent-runtime_RetrieveAndGenerate_ResponseSyntax">RetrieveAndGenerate response</a> – in the <code>citations</code> field</p></li>
/// </ul>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Citation {
    /// <p>Contains the generated response and metadata</p>
    pub generated_response_part: ::std::option::Option<crate::types::GeneratedResponsePart>,
    /// <p>Contains metadata about the sources cited for the generated response.</p>
    pub retrieved_references: ::std::option::Option<::std::vec::Vec<crate::types::RetrievedReference>>,
}
impl Citation {
    /// <p>Contains the generated response and metadata</p>
    pub fn generated_response_part(&self) -> ::std::option::Option<&crate::types::GeneratedResponsePart> {
        self.generated_response_part.as_ref()
    }
    /// <p>Contains metadata about the sources cited for the generated response.</p>
    ///
    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.retrieved_references.is_none()`.
    pub fn retrieved_references(&self) -> &[crate::types::RetrievedReference] {
        self.retrieved_references.as_deref().unwrap_or_default()
    }
}
impl Citation {
    /// Creates a new builder-style object to manufacture [`Citation`](crate::types::Citation).
    pub fn builder() -> crate::types::builders::CitationBuilder {
        crate::types::builders::CitationBuilder::default()
    }
}

/// A builder for [`Citation`](crate::types::Citation).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct CitationBuilder {
    pub(crate) generated_response_part: ::std::option::Option<crate::types::GeneratedResponsePart>,
    pub(crate) retrieved_references: ::std::option::Option<::std::vec::Vec<crate::types::RetrievedReference>>,
}
impl CitationBuilder {
    /// <p>Contains the generated response and metadata</p>
    pub fn generated_response_part(mut self, input: crate::types::GeneratedResponsePart) -> Self {
        self.generated_response_part = ::std::option::Option::Some(input);
        self
    }
    /// <p>Contains the generated response and metadata</p>
    pub fn set_generated_response_part(mut self, input: ::std::option::Option<crate::types::GeneratedResponsePart>) -> Self {
        self.generated_response_part = input;
        self
    }
    /// <p>Contains the generated response and metadata</p>
    pub fn get_generated_response_part(&self) -> &::std::option::Option<crate::types::GeneratedResponsePart> {
        &self.generated_response_part
    }
    /// Appends an item to `retrieved_references`.
    ///
    /// To override the contents of this collection use [`set_retrieved_references`](Self::set_retrieved_references).
    ///
    /// <p>Contains metadata about the sources cited for the generated response.</p>
    pub fn retrieved_references(mut self, input: crate::types::RetrievedReference) -> Self {
        let mut v = self.retrieved_references.unwrap_or_default();
        v.push(input);
        self.retrieved_references = ::std::option::Option::Some(v);
        self
    }
    /// <p>Contains metadata about the sources cited for the generated response.</p>
    pub fn set_retrieved_references(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::RetrievedReference>>) -> Self {
        self.retrieved_references = input;
        self
    }
    /// <p>Contains metadata about the sources cited for the generated response.</p>
    pub fn get_retrieved_references(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::RetrievedReference>> {
        &self.retrieved_references
    }
    /// Consumes the builder and constructs a [`Citation`](crate::types::Citation).
    pub fn build(self) -> crate::types::Citation {
        crate::types::Citation {
            generated_response_part: self.generated_response_part,
            retrieved_references: self.retrieved_references,
        }
    }
}