estimateTokenCount method

int estimateTokenCount(
  1. String text
)

Estimate token count for a prompt (rough estimation)

Implementation

int estimateTokenCount(String text) {
  // Rough estimation: ~4 characters per token for English text
  return (text.length / 4).ceil();
}