Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompt caching #30

Merged
merged 5 commits into from
Jan 12, 2025
Merged

Prompt caching #30

merged 5 commits into from
Jan 12, 2025

Conversation

dlants
Copy link
Owner

@dlants dlants commented Jan 12, 2025

implementing prompt caching for anthropic.

Anthropic provides up to 4 cache breakpoints. I'm basically using them to mark off as much of the prompt as I can, in powers of 2.

So if the prompt is 5000 tokens, we'll put cache markers at messages at the 4096, 2048 and 1024 mark. (1024 being the minimum that anthropic can cache).

(see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching for details)

I think this is a pretty decent strategy to make sure that we're reusing as much context as we can while allowing for things to change as files update and move up in the message stream (due to the smart context placement I implemented here: #24

@dlants dlants merged commit 793fcea into main Jan 12, 2025
1 check passed
@dlants dlants deleted the prompt-caching branch January 12, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant