Class BedrockSystemTextContent
java.lang.Object
dev.langchain4j.model.bedrock.BedrockSystemTextContent
- All Implemented Interfaces:
BedrockSystemContent
Text content block for
BedrockSystemMessage with optional cache point.
Example usage:
// Without cache point
BedrockSystemTextContent.from("Instructions");
// With cache point (content will be cached)
BedrockSystemTextContent.withCachePoint("Large static context");
AWS Bedrock Caching Requirements:
- Minimum ~1,024 tokens required for caching to activate
- Cache has 5-minute TTL (resets on each hit)
- Only Claude 3.x and Amazon Nova models support caching
- Maximum 4 cache points per request (see
BedrockSystemMessage.MAX_CACHE_POINTS)
Thread Safety: Instances of this class are immutable and thread-safe.
- Since:
- 1.11.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMaximum allowed text length (1MB) to prevent resource exhaustion. -
Constructor Summary
ConstructorsConstructorDescriptionCreates text content without cache point.BedrockSystemTextContent(String text, boolean cachePoint) Creates text content with optional cache point. -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic BedrockSystemTextContentCreates text content without cache point.booleanReturns whether this content block has a cache point marker.inthashCode()text()Returns the text content.toString()type()Returns the content type.static BedrockSystemTextContentwithCachePoint(String text) Creates text content WITH cache point marker.
-
Field Details
-
MAX_TEXT_LENGTH
public static final int MAX_TEXT_LENGTHMaximum allowed text length (1MB) to prevent resource exhaustion.- See Also:
-
-
Constructor Details
-
BedrockSystemTextContent
Creates text content with optional cache point.- Parameters:
text- the text content (must not be blank, max 1MB)cachePoint- whether to add a cache point after this content- Throws:
IllegalArgumentException- if text is null, blank, or exceeds max length
-
BedrockSystemTextContent
Creates text content without cache point.- Parameters:
text- the text content (must not be blank)
-
-
Method Details
-
text
-
hasCachePoint
public boolean hasCachePoint()Description copied from interface:BedrockSystemContentReturns whether this content block has a cache point marker. When true, a cache point will be inserted AFTER this content block in the AWS Bedrock request.- Specified by:
hasCachePointin interfaceBedrockSystemContent- Returns:
- true if this content has a cache point
-
type
Description copied from interface:BedrockSystemContentReturns the content type.- Specified by:
typein interfaceBedrockSystemContent- Returns:
- the content type enum value
-
from
Creates text content without cache point.- Parameters:
text- the text content- Returns:
- new BedrockSystemTextContent
-
withCachePoint
Creates text content WITH cache point marker. A cache point will be inserted after this content in the Bedrock request.Note: For caching to activate, content should be at least ~1,024 tokens.
- Parameters:
text- the text content- Returns:
- new BedrockSystemTextContent with cache point
-
equals
-
hashCode
-
toString
-