Scoria.PromptRegistry.Tokenizer (scoria v0.1.0)

Copy Markdown View Source

Stateless utility module for accurately estimating token usage of prompt templates. Uses Tiktoken under the hood to ensure operators are warned before hitting context limits.

Summary

Functions

Estimates token usage for a given prompt map or string.

Functions

estimate_tokens(text)

Estimates token usage for a given prompt map or string.

Returns the integer count of estimated tokens. Returns 0 on error or empty/nil inputs.