We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3e47ade commit ada1e73Copy full SHA for ada1e73
backend/src/util/token-counter.ts
@@ -11,7 +11,10 @@ export function countTokens(text: string): number {
11
if (cached !== undefined) {
12
return cached
13
}
14
- const count = Math.floor(encode(text).length * ANTHROPIC_TOKEN_FUDGE_FACTOR)
+ const count = Math.floor(
15
+ encode(text, { allowedSpecial: 'all' }).length *
16
+ ANTHROPIC_TOKEN_FUDGE_FACTOR,
17
+ )
18
19
if (text.length > 100) {
20
// Cache only if the text is long enough to be worth it.
0 commit comments