Commit a95075d 1 parent 9c5d051 commit a95075d Copy full SHA for a95075d
File tree 1 file changed +2
-2
lines changed
1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -624,13 +624,13 @@ export function placeCacheBreakpoints(messages: MessageParam[]): number {
624
624
const tokens = Math . floor ( lengthAcc / STR_CHARS_PER_TOKEN ) ;
625
625
626
626
// Anthropic allows for placing up to 4 cache control markers.
627
- // It will not cache anythign less than 1024 tokens for sonnet 3.5
627
+ // It will not cache anything less than 1024 tokens for sonnet 3.5
628
628
// https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
629
629
// this is pretty rough estimate, due to the conversion between string length and tokens.
630
630
// however, since we are not accounting for tools or the system prompt, and generally code and technical writing
631
631
// tend to have a lower coefficient of string length to tokens (about 3.5 average sting length per token), this means
632
632
// that the first cache control should be past the 1024 mark and should be cached.
633
- const powers = highestPowersOfTwo ( tokens , 4 ) . filter ( ( n ) => n >= 1024 ) ;
633
+ const powers = highestPowersOfTwo ( tokens , 3 ) . filter ( ( n ) => n >= 1024 ) ;
634
634
if ( powers . length ) {
635
635
for ( const power of powers ) {
636
636
const targetLength = power * STR_CHARS_PER_TOKEN ; // power is in tokens, but we want string chars instead
You can’t perform that action at this time.
0 commit comments