1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// <p>Contains information about a citation that references a specific source document. Citations provide traceability between the model's generated response and the source documents that informed that response.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Citation {
/// <p>The title or identifier of the source document being cited.</p>
pub title: ::std::option::Option<::std::string::String>,
/// <p>The source from the original search result that provided the cited content.</p>
pub source: ::std::option::Option<::std::string::String>,
/// <p>The specific content from the source document that was referenced or cited in the generated response.</p>
pub source_content: ::std::option::Option<::std::vec::Vec<crate::types::CitationSourceContent>>,
/// <p>The precise location within the source document where the cited content can be found, including character positions, page numbers, or chunk identifiers.</p>
pub location: ::std::option::Option<crate::types::CitationLocation>,
}
impl Citation {
/// <p>The title or identifier of the source document being cited.</p>
pub fn title(&self) -> ::std::option::Option<&str> {
self.title.as_deref()
}
/// <p>The source from the original search result that provided the cited content.</p>
pub fn source(&self) -> ::std::option::Option<&str> {
self.source.as_deref()
}
/// <p>The specific content from the source document that was referenced or cited in 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 `.source_content.is_none()`.
pub fn source_content(&self) -> &[crate::types::CitationSourceContent] {
self.source_content.as_deref().unwrap_or_default()
}
/// <p>The precise location within the source document where the cited content can be found, including character positions, page numbers, or chunk identifiers.</p>
pub fn location(&self) -> ::std::option::Option<&crate::types::CitationLocation> {
self.location.as_ref()
}
}
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) title: ::std::option::Option<::std::string::String>,
pub(crate) source: ::std::option::Option<::std::string::String>,
pub(crate) source_content: ::std::option::Option<::std::vec::Vec<crate::types::CitationSourceContent>>,
pub(crate) location: ::std::option::Option<crate::types::CitationLocation>,
}
impl CitationBuilder {
/// <p>The title or identifier of the source document being cited.</p>
pub fn title(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.title = ::std::option::Option::Some(input.into());
self
}
/// <p>The title or identifier of the source document being cited.</p>
pub fn set_title(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.title = input;
self
}
/// <p>The title or identifier of the source document being cited.</p>
pub fn get_title(&self) -> &::std::option::Option<::std::string::String> {
&self.title
}
/// <p>The source from the original search result that provided the cited content.</p>
pub fn source(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.source = ::std::option::Option::Some(input.into());
self
}
/// <p>The source from the original search result that provided the cited content.</p>
pub fn set_source(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.source = input;
self
}
/// <p>The source from the original search result that provided the cited content.</p>
pub fn get_source(&self) -> &::std::option::Option<::std::string::String> {
&self.source
}
/// Appends an item to `source_content`.
///
/// To override the contents of this collection use [`set_source_content`](Self::set_source_content).
///
/// <p>The specific content from the source document that was referenced or cited in the generated response.</p>
pub fn source_content(mut self, input: crate::types::CitationSourceContent) -> Self {
let mut v = self.source_content.unwrap_or_default();
v.push(input);
self.source_content = ::std::option::Option::Some(v);
self
}
/// <p>The specific content from the source document that was referenced or cited in the generated response.</p>
pub fn set_source_content(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::CitationSourceContent>>) -> Self {
self.source_content = input;
self
}
/// <p>The specific content from the source document that was referenced or cited in the generated response.</p>
pub fn get_source_content(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::CitationSourceContent>> {
&self.source_content
}
/// <p>The precise location within the source document where the cited content can be found, including character positions, page numbers, or chunk identifiers.</p>
pub fn location(mut self, input: crate::types::CitationLocation) -> Self {
self.location = ::std::option::Option::Some(input);
self
}
/// <p>The precise location within the source document where the cited content can be found, including character positions, page numbers, or chunk identifiers.</p>
pub fn set_location(mut self, input: ::std::option::Option<crate::types::CitationLocation>) -> Self {
self.location = input;
self
}
/// <p>The precise location within the source document where the cited content can be found, including character positions, page numbers, or chunk identifiers.</p>
pub fn get_location(&self) -> &::std::option::Option<crate::types::CitationLocation> {
&self.location
}
/// Consumes the builder and constructs a [`Citation`](crate::types::Citation).
pub fn build(self) -> crate::types::Citation {
crate::types::Citation {
title: self.title,
source: self.source,
source_content: self.source_content,
location: self.location,
}
}
}