MCPcopy Index your code
hub / github.com/simstudioai/sim / estimateTokens

Function estimateTokens

apps/sim/lib/chunkers/utils.ts:4–7  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

2
3/** 1 token ≈ 4 characters for English text */
4export function estimateTokens(text: string): number {
5 if (!text?.trim()) return 0
6 return Math.ceil(text.length / 4)
7}
8
9export function tokensToChars(tokens: number): number {
10 return tokens * 4

Callers 15

chunkMdxFileMethod · 0.90
enforceSizeLimitMethod · 0.90
chunkMethod · 0.90
splitRecursivelyMethod · 0.90
splitRecursivelyMethod · 0.90
utils.test.tsFile · 0.90
chunkMethod · 0.90
chunkStructuredDataMethod · 0.90
chunkArrayMethod · 0.90
chunkObjectMethod · 0.90
buildBatchChunkMethod · 0.90
chunkAsTextMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected