MCPcopy
hub / github.com/di-sukharev/opencommit / tokenCount

Function tokenCount

src/utils/tokenCount.ts:4–13  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

2import { Tiktoken } from '@dqbd/tiktoken/lite';
3
4export 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}

Callers 10

splitDiffFunction · 0.90
mergeDiffsFunction · 0.90
OpenAiEngineClass · 0.90
MistralAiEngineClass · 0.90
DeepseekEngineClass · 0.90
AnthropicEngineClass · 0.90
AzureEngineClass · 0.90

Calls 2

encodeMethod · 0.80
freeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…