Module Chatoyant_tokens.Token_estimateSource

Heuristic token estimation.

These functions intentionally mirror the current TypeScript package's zero-dependency token estimates. They are fast approximations, not provider tokenizer bindings.

Sourcetype content_kind =
  1. | English
  2. | Code
  3. | Cjk
  4. | Mixed
Sourcetype prompt_estimate = {
  1. input : int;
  2. output : int;
  3. total : int;
}
Sourceval chars_per_token : content_kind -> float
Sourceval classify : string -> content_kind
Sourceval estimate : string -> int
Sourceval estimate_prompt : ?response:string -> string -> prompt_estimate
Sourceval estimate_many : string list -> int
Sourceval estimate_with_ratio : chars_per_token:float -> string -> int