estimateTokens function

int estimateTokens(
  1. String text
)

Quick heuristic token estimate: roughly 1 token per 4 characters for English text.

Implementation

int estimateTokens(String text) => math.max(1, (text.length / 4).ceil());