(content: string)
| 2 | import { Tiktoken } from '@dqbd/tiktoken/lite'; |
| 3 | |
| 4 | export function tokenCount(content: string): number { |
| 5 | const encoding = new Tiktoken( |
| 6 | cl100k_base.bpe_ranks, |
| 7 | cl100k_base.special_tokens, |
| 8 | cl100k_base.pat_str |
| 9 | ); |
| 10 | const tokens = encoding.encode(content); |
| 11 | encoding.free(); |
| 12 | return tokens.length; |
| 13 | } |
no test coverage detected
searching dependent graphs…