(content: Anthropic.Messages.ContentBlockParam[])
| 7 | import { type CountTokensResult } from "./types" |
| 8 | |
| 9 | async 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 | |
| 21 | workerpool.worker({ countTokens }) |
nothing calls this directly
no test coverage detected