#[non_exhaustive]pub struct Citation {
pub source: CitationSource,
pub span: Option<Range<usize>>,
pub cited_text: Option<String>,
pub provider_data: ProviderData,
}Expand description
A link from generated text to a source that supports it.
Citations annotate Text blocks of model output (see ADR 0007). They
are read-only views: adapters replay the provider’s own annotations, kept
in the block’s provider data, rather than re-encoding this list.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.source: CitationSourceWhat is cited.
span: Option<Range<usize>>The supported part of the text, as a byte range into
Text::text. None means the whole block.
cited_text: Option<String>The quoted passage from the source, when the provider reports it.
provider_data: ProviderDataProvider-specific details (page numbers, indexes, confidence).
Implementations§
Source§impl Citation
impl Citation
Sourcepub fn new(source: CitationSource) -> Self
pub fn new(source: CitationSource) -> Self
Cite source for the whole text block.
Sourcepub fn with_span(self, span: Range<usize>) -> Self
pub fn with_span(self, span: Range<usize>) -> Self
Limit the citation to a byte range of the text.
Sourcepub fn with_cited_text(self, cited_text: impl Into<String>) -> Self
pub fn with_cited_text(self, cited_text: impl Into<String>) -> Self
Set the quoted source passage.
Sourcepub fn with_provider_data(self, provider_data: ProviderData) -> Self
pub fn with_provider_data(self, provider_data: ProviderData) -> Self
Attach provider data.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Citation
impl<'de> Deserialize<'de> for Citation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Citation
impl StructuralPartialEq for Citation
Auto Trait Implementations§
impl Freeze for Citation
impl RefUnwindSafe for Citation
impl Send for Citation
impl Sync for Citation
impl Unpin for Citation
impl UnsafeUnpin for Citation
impl UnwindSafe for Citation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more