* Google Gemini-specific token estimation
(text: string)
| 279 | * Google Gemini-specific token estimation |
| 280 | */ |
| 281 | function estimateGoogleTokens(text: string): number { |
| 282 | const words = text.trim().split(/\s+/) |
| 283 | let tokenCount = 0 |
| 284 | |
| 285 | for (const word of words) { |
| 286 | if (word.length === 0) continue |
| 287 | |
| 288 | if (word.length <= 5) { |
| 289 | tokenCount += 1 |
| 290 | } else if (word.length <= 10) { |
| 291 | tokenCount += Math.ceil(word.length / 6) |
| 292 | } else { |
| 293 | tokenCount += Math.ceil(word.length / 5) |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | return tokenCount |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Generic token estimation fallback |
no outgoing calls
no test coverage detected