refactor(rust): align tokenizer docs and lint

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Yujong Lee 2026-09-20 21:21:52 +00:00
parent 84c26978a3
commit 9b2b3d0b90
2 changed files with 9 additions and 2 deletions

View file

@ -2,7 +2,7 @@
`Tokenizer` is the text-counting interface. `TokenCounter` applies LiteLLM request, message, and tool accounting using any implementation of that interface
The `fast` feature provides `fast::FastTokenizer` from `litellm-token-counter-fast`. `TokenCounter::from_json_fast`, `TokenCounter::from_cl100k_ranks`, and `TokenCounter::from_o200k_ranks` use this implementation
The `fast` feature provides `fast::FastTokenizer` from `litellm-token-counter-fast`. `TokenCounter::from_json_fast` uses this implementation
The `huggingface` feature provides `huggingface::HuggingFaceTokenizer` through the upstream `tokenizers` library. `TokenCounter::from_json` uses this implementation

View file

@ -77,7 +77,14 @@ def rust_tokenizer(model: str) -> RustTokenizer | None:
if kind is not None or uses_legacy_message_accounting(model):
return None
encoding: Final = openai_tokenizer_encoding(model).name
if encoding in {"cl100k_base", "o200k_base", "o200k_harmony", "p50k_base", "p50k_edit", "r50k_base"}:
if encoding in (
"cl100k_base",
"o200k_base",
"o200k_harmony",
"p50k_base",
"p50k_edit",
"r50k_base",
):
return cast(RustTokenizer, encoding)
return None