( content: Array<Anthropic.Messages.ContentBlockParam>, apiHandler: ApiHandler, )
| 33 | * @returns {Promise<number>} A promise resolving to the token count |
| 34 | */ |
| 35 | export async function estimateTokenCount( |
| 36 | content: Array<Anthropic.Messages.ContentBlockParam>, |
| 37 | apiHandler: ApiHandler, |
| 38 | ): Promise<number> { |
| 39 | if (!content || content.length === 0) return 0 |
| 40 | return apiHandler.countTokens(content) |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Computes the percentage of the context budget consumed by the prior context. |
no test coverage detected