MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / countTokens

Function countTokens

src/api/providers/base-provider.ts:118–124  ·  view source on GitHub ↗

* Default token counting implementation using tiktoken. * Providers can override this to use their native token counting endpoints. * * @param content The content to count tokens for * @returns A promise resolving to the token count

(content: Anthropic.Messages.ContentBlockParam[])

Source from the content-addressed store, hash-verified

116 * @returns A promise resolving to the token count
117 */
118 async countTokens(content: Anthropic.Messages.ContentBlockParam[]): Promise<number> {
119 if (content.length === 0) {
120 return 0
121 }
122
123 return countTokens(content, { useWorker: true })
124 }
125}

Callers

nothing calls this directly

Calls 1

countTokensFunction · 0.90

Tested by

no test coverage detected