The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(rust): align tokenizer docs and lint
Yujong Lee9b2b3d0b9034
diff --git a/litellm-rust/crates/token-counter/README.md b/litellm-rust/crates/token-counter/README.mdindex c8ed0737a7e..effa5324822 100644--- a/litellm-rust/crates/token-counter/README.md+++ b/litellm-rust/crates/token-counter/README.md@@ -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 implementationThe `huggingface` feature provides `huggingface::HuggingFaceTokenizer` through the upstream `tokenizers` library. `TokenCounter::from_json` uses this implementationdiff --git a/litellm/rust_bridge/token_counter.py b/litellm/rust_bridge/token_counter.pyindex e816f1ab388..d232db19a4a 100644--- a/litellm/rust_bridge/token_counter.py+++ b/litellm/rust_bridge/token_counter.py@@ -77,7 +77,14 @@ def rust_tokenizer(model: str) -> RustTokenizer | None:if kind is not None or uses_legacy_message_accounting(model):return Noneencoding: 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