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

Function countTokens

src/workers/countTokens.ts:9–19  ·  view source on GitHub ↗
(content: Anthropic.Messages.ContentBlockParam[])

Source from the content-addressed store, hash-verified

7import { type CountTokensResult } from "./types"
8
9async function countTokens(content: Anthropic.Messages.ContentBlockParam[]): Promise<CountTokensResult> {
10 try {
11 const count = await tiktoken(content)
12 return { success: true, count }
13 } catch (error) {
14 return {
15 success: false,
16 error: error instanceof Error ? error.message : "Unknown error",
17 }
18 }
19}
20
21workerpool.worker({ countTokens })

Callers

nothing calls this directly

Calls 1

tiktokenFunction · 0.90

Tested by

no test coverage detected