litellm/tests/test_litellm_rust
Jc X 8ad1670304
fix(tokenizer): match tiktoken on lone surrogates and out-of-u32 tokens (#51720)
* fix(tokenizer): match tiktoken on lone surrogates and out-of-u32 tokens

* fix(tokenizer): keep numpy ids in is_special_token and reject lone surrogates in encode_to_numpy

* fix(tokenizer): map only u32 range overflow in is_special_token to False

operator.index runs first, so a non-integer id or an __index__ that raises still raises like tiktoken. The tests compare against tiktoken directly and share a cl100k rstest fixture.

* fix(tokenizer): raise ValueError like tiktoken when the tokenizer regex fails

encode_to_numpy and encode with allowed special tokens raised PanicException and RuntimeError where tiktoken raises ValueError. Both strict and lenient encoders now share one helper.

* fix(tokenizer): take the fallible encoder in encode like tiktoken so a regex failure raises ValueError

---------

Co-authored-by: xinglan163 <250816997+xinglan163@users.noreply.github.com>
Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-18 01:29:55 +00:00
..
cache feat(messages): serve anthropic messages on rust only (#51119) 2026-11-12 00:07:20 +00:00
chat_completions feat(rust): one typed decline from core up to each host (#47772) 2026-10-28 09:22:11 -07:00
embeddings refactor(rust-bridge): decide native routing in the catalog, drop the bypass predicates (#46750) 2026-10-20 15:06:24 -07:00
messages feat(messages): serve bedrock invoke messages on rust only (#51330) 2026-11-15 16:58:31 -08:00
ocr fix(messages): log native messages success once, after the proxy releases it (#50420) 2026-11-09 16:06:53 -08:00
responses fix(messages): let proxy /v1/messages requests run on the rust path (#50335) 2026-11-09 16:06:52 -08:00
support feat(messages): serve anthropic messages on rust only (#51119) 2026-11-12 00:07:20 +00:00
tokenizer fix(tokenizer): match tiktoken on lone surrogates and out-of-u32 tokens (#51720) 2026-11-18 01:29:55 +00:00
AGENTS.md refactor(rust-bridge): detect Python-only features in the catalog instead of Rust declines (#46714) 2026-10-20 15:06:25 -07:00
conftest.py refactor(rust-bridge): require the native extension (#48852) 2026-10-28 13:16:56 -07:00
test_clickhouse_spend.py refactor(lens): connect LiteLLM to the independent Lens service (#45529) 2026-10-09 16:17:05 -07:00
test_dispatch.py feat(messages): serve anthropic messages on rust only (#51119) 2026-11-12 00:07:20 +00:00
test_fork_guard.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_public_entries.py fix(rust): run native async calls through python's async wrapper steps (#50423) 2026-11-10 00:24:20 +00:00