(tools: ChatCompletionTool[])
| 279 | * @returns Estimated token count for all tool definitions |
| 280 | */ |
| 281 | export function countToolDefinitionTokens(tools: ChatCompletionTool[]): number { |
| 282 | if (!tools || tools.length === 0) { |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | // Base overhead for the tools array structure |
| 287 | let numTokens = 12; |
| 288 | |
| 289 | for (const tool of tools) { |
| 290 | numTokens += countSingleToolTokens(tool); |
| 291 | } |
| 292 | |
| 293 | // Additional overhead for the tools wrapper |
| 294 | return numTokens + 12; |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * Parameters for calculating total input tokens including all components |
no test coverage detected