Package org.springframework.ai.anthropic
Class AnthropicCitationDocument
java.lang.Object
org.springframework.ai.anthropic.AnthropicCitationDocument
Builder class for creating citation-enabled documents using the Anthropic Java SDK.
Produces SDK
DocumentBlockParam objects directly.
Citations allow Claude to reference specific parts of provided documents in its responses. When a citation document is included in a prompt, Claude can cite the source material, and citation metadata (character ranges, page numbers, or content blocks) is returned in the response.
Usage Examples
Plain Text Document:
AnthropicCitationDocument document = AnthropicCitationDocument.builder()
.plainText("The Eiffel Tower was completed in 1889 in Paris, France.")
.title("Eiffel Tower Facts")
.citationsEnabled(true)
.build();
PDF Document:
AnthropicCitationDocument document = AnthropicCitationDocument.builder()
.pdfFile("path/to/document.pdf")
.title("Technical Specification")
.citationsEnabled(true)
.build();
Custom Content Blocks:
AnthropicCitationDocument document = AnthropicCitationDocument.builder()
.customContent(
"Fact 1: The Great Wall spans 21,196 kilometers.",
"Fact 2: Construction began in the 7th century BC.",
"Fact 3: It was built to protect Chinese states."
)
.title("Great Wall Facts")
.citationsEnabled(true)
.build();
- Since:
- 1.1.0
- Author:
- Soby Chacko
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for AnthropicCitationDocument.static enumDocument types supported by Anthropic Citations API. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()booleancom.anthropic.models.messages.DocumentBlockParamConvert this citation document to an SDKDocumentBlockParam.
-
Method Details
-
builder
-
toDocumentBlockParam
public com.anthropic.models.messages.DocumentBlockParam toDocumentBlockParam()Convert this citation document to an SDKDocumentBlockParam.- Returns:
- configured DocumentBlockParam for the Anthropic API
-
isCitationsEnabled
public boolean isCitationsEnabled()
-