Added support for Prompt Caching for Anthropic when using InvokeModel API #356
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using langchain's example for creating SystemMessage and HumanMessage for prompt caching:
https://js.langchain.com/docs/integrations/chat/anthropic/#prompt-caching
Looks like SystemMessage's content could be non-string, added support for that.
Using AWS Bedrock's InvokeModel API prompt caching example on what message is supposed to structure:
https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching#large-context-caching-example
Doesn't look like
SystemMessage
supports prompt caching, so ignore thecache_control
.But preserve that for
HumanMessage
Added tests for the change