Middleware for LangChain AWS integrations.
Prompt Caching Middleware for ChatBedrock and ChatBedrockConverse.
Optimizes API usage by caching conversation prefixes for supported models on AWS Bedrock. Supports Anthropic Claude and Amazon Nova models.
For ChatBedrock (InvokeModel API), adds cache_control to the last
message's content block. For ChatBedrockConverse (Converse API), appends
cachePoint blocks to the system prompt and last message.
Requires both 'langchain' and 'langchain-aws' packages to be installed.
Learn more about prompt caching at:
Anthropic <https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching>AWS Bedrock <https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html>