Package org.springframework.ai.anthropic
Class CacheEligibilityResolver
java.lang.Object
org.springframework.ai.anthropic.CacheEligibilityResolver
Resolves cache eligibility for messages based on the provided
AnthropicCacheOptions. Returns SDK CacheControlEphemeral instances
instead of raw cache control records.- Since:
- 1.1.0
- Author:
- Austin Dase, Soby Chacko
-
Constructor Summary
ConstructorsConstructorDescriptionCacheEligibilityResolver(AnthropicCacheStrategy cacheStrategy, Map<MessageType, AnthropicCacheTtl> messageTypeTtl, Map<MessageType, Integer> messageTypeMinContentLengths, Function<@Nullable String, Integer> contentLengthFunction, Set<MessageType> cacheEligibleMessageTypes) -
Method Summary
Modifier and TypeMethodDescriptionstatic CacheEligibilityResolverfrom(AnthropicCacheOptions cacheOptions) boolean@Nullable com.anthropic.models.messages.CacheControlEphemeralresolve(MessageType messageType, @Nullable String content) @Nullable com.anthropic.models.messages.CacheControlEphemeralResolves the cache control for citation documents.@Nullable com.anthropic.models.messages.CacheControlEphemeralvoid
-
Constructor Details
-
CacheEligibilityResolver
public CacheEligibilityResolver(AnthropicCacheStrategy cacheStrategy, Map<MessageType, AnthropicCacheTtl> messageTypeTtl, Map<MessageType, Integer> messageTypeMinContentLengths, Function<@Nullable String, Integer> contentLengthFunction, Set<MessageType> cacheEligibleMessageTypes)
-
-
Method Details
-
from
-
resolve
public @Nullable com.anthropic.models.messages.CacheControlEphemeral resolve(MessageType messageType, @Nullable String content) -
resolveToolCacheControl
public @Nullable com.anthropic.models.messages.CacheControlEphemeral resolveToolCacheControl() -
resolveCitationDocumentCacheControl
public @Nullable com.anthropic.models.messages.CacheControlEphemeral resolveCitationDocumentCacheControl()Resolves the cache control for citation documents. Documents are stable reference material in the same way as the system prompt, so they receive a breakpoint under every strategy that caches system content, using theSYSTEMTTL. UnderAnthropicCacheStrategy.TOOLS_ONLYdocuments are not cached, because a breakpoint on a document would also cache the system prompt that precedes it.- Returns:
- the cache control to apply to the last document block, or
nullif documents are not cached under the current strategy or all breakpoints are used - Since:
- 2.0.2
-
isCachingEnabled
public boolean isCachingEnabled() -
useCacheBlock
public void useCacheBlock()
-