Package org.springframework.ai.anthropic
Enum Class AnthropicCacheStrategy
- All Implemented Interfaces:
Serializable,Comparable<AnthropicCacheStrategy>,Constable
Defines the caching strategy for Anthropic prompt caching. Anthropic allows up to 4
cache breakpoints per request, and the cache hierarchy follows the order: tools ->
system -> messages.
- Since:
- 1.1.0
- Author:
- Mark Pollack, Soby Chacko
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionCache the entire conversation history up to (but not including) the current user question.No caching (default behavior).Cache system instructions and tool definitions.Cache system instructions only.Cache tool definitions only. -
Method Summary
Modifier and TypeMethodDescriptionstatic AnthropicCacheStrategyReturns the enum constant of this class with the specified name.static AnthropicCacheStrategy[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NONE
No caching (default behavior). All content is processed fresh on each request. -
TOOLS_ONLY
Cache tool definitions only. Places a cache breakpoint on the last tool, while system messages and conversation history remain uncached. -
SYSTEM_ONLY
Cache system instructions only. Places a cache breakpoint on the system message content. Tools are cached implicitly via Anthropic's automatic lookback mechanism. -
SYSTEM_AND_TOOLS
Cache system instructions and tool definitions. Places cache breakpoints on the last tool (breakpoint 1) and system message content (breakpoint 2). -
CONVERSATION_HISTORY
Cache the entire conversation history up to (but not including) the current user question. Places a cache breakpoint on the last user message in the conversation history, enabling incremental caching as the conversation grows.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-