litellm/litellm-rust/crates
devin-ai-integration[bot] 05d7fb24bd
feat(rust): add python-compat crate for Python data formats (#42510)
* feat(rust): add python-compat crate for Python data formats

Add litellm-python-compat, a PyO3-free crate that reproduces the Python
data formats LiteLLM persists, so Rust readers and writers can interoperate
with state written by the Python proxy:

- literal::literal_eval: a linear recursive-descent port of
  ast.literal_eval (prefixes, escapes, implicit concatenation, numeric
  underscores and radixes, single unary sign, real +/- complex with 3.14
  mixed-mode rules, set(), Python-equality key dedup)
- repr::{repr, to_str}: byte-exact repr()/str(), with a printable table
  generated from CPython's str.isprintable (Unicode 16.0.0)
- json::{dumps, from_json, to_json}: json.dumps defaults and the
  json.loads mapping
- pickle::{loads, dumps}: plain-data pickles via serde-pickle's serde
  interface, which keeps dict insertion order
- truthy::truthy: bool() for plain data

Tests replay fixtures generated by CPython 3.14 (values across every
format and pickle protocol 0-5, plus 154 literal_eval source texts).
Accepted divergences are pinned in a KNOWN table that fails once one
starts matching. A criterion bench covers each format and literal_eval
cost by nesting depth, guarding the linear parse: the py_literal grammar
doubled per nested bracket (105 ms at 16 nested dicts; 19 us at 128 now).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* refactor(rust): split python-compat modules and harden the pickle verifier

- Disable class resolution in scripts/verify_rust_pickles.py, and truncate
  the export file once instead of removing and appending to it, so the
  verifier cannot be pointed at a pre-created file whose rows execute code
  through pickle.loads
- Move Error to error.rs and Value to value.rs, leaving lib.rs as the crate
  overview, module list and MAX_DEPTH
- Move the generator and verifier to scripts/, beside the Unicode table
  generator, leaving tests/ to the Rust tests
- Group the bench by measured surface, give every case a Throughput so
  criterion reports bytes per second, and document baseline comparison

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Yujong Lee <yujong@berri.ai>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 12:16:56 -07:00
..
auth refactor(rust): split auth facade from shared types 2026-09-20 15:45:38 -07:00
auth-aws feat(rust-bridge): add cache and secret migration foundations (#42328) 2026-09-22 03:41:04 +00:00
auth-azure feat(rust-bridge): add cache and secret migration foundations (#42328) 2026-09-22 03:41:04 +00:00
auth-gcp feat(rust-bridge): add cache and secret migration foundations (#42328) 2026-09-22 03:41:04 +00:00
auth-types feat(rust-bridge): add cache and secret migration foundations (#42328) 2026-09-22 03:41:04 +00:00
cache Merge origin/main into litellm_rust_qdrant_semantic_cache 2026-09-22 00:19:34 +00:00
cache-azure-blob chore: merge main into litellm_native_azure_blob_cache 2026-09-21 21:43:08 +00:00
cache-disk fix(cache-disk): absolutize store directory and stamp async expiry at write time 2026-09-21 22:06:55 +00:00
cache-gcs test(rust): add GCS native cache parity fixtures 2026-09-21 20:38:20 +00:00
cache-memory refactor(rust): align cache foundation with Python backends 2026-09-21 12:50:21 -07:00
cache-qdrant-semantic Merge origin/main into litellm_rust_qdrant_semantic_cache 2026-09-22 00:19:34 +00:00
cache-redis Merge remote-tracking branch 'origin/main' into litellm_native_redis_semantic_cache 2026-09-21 23:51:16 +00:00
cache-redis-semantic Merge remote-tracking branch 'origin/main' into litellm_native_redis_semantic_cache 2026-09-21 23:51:16 +00:00
cache-response feat(rust-bridge): add cache and secret migration foundations (#42328) 2026-09-22 03:41:04 +00:00
cache-s3 fix(rust): isolate explicit s3 keys from env tokens and treat 403 misses 2026-09-21 22:17:11 +00:00
cache-valkey-semantic fix(cache): honor controls and tenant metadata in valkey semantic bridge 2026-09-21 22:33:11 +00:00
callbacks-legacy-python style(rust): format renamed callback adapter 2026-09-19 23:08:37 +00:00
core feat(rust-bridge): add cache and secret migration foundations (#42328) 2026-09-22 03:41:04 +00:00
core-utils feat(rust-bridge): add cache and secret migration foundations (#42328) 2026-09-22 03:41:04 +00:00
framer fix(rust): pin aws-sdk-s3 without relaxing eventstream pins 2026-09-21 20:39:17 +00:00
host refactor(rust): move RouteMachine out of core into litellm-host next to the Machine trait 2026-09-18 15:45:08 -07:00
host-python feat(tokenizer): preserve Python defaults with opt-in Rust dispatch (#42174) 2026-09-22 04:41:11 +00:00
http fix(rust): preserve HTTP host and TLS error context 2026-09-21 21:32:33 +00:00
llms feat(rust-bridge): add cache and secret migration foundations (#42328) 2026-09-22 03:41:04 +00:00
python-bridge feat(rust): align secret manager operation contexts (#42480) 2026-09-22 09:02:15 -07:00
python-compat feat(rust): add python-compat crate for Python data formats (#42510) 2026-09-22 12:16:56 -07:00
secrets feat(rust): align secret manager operation contexts (#42480) 2026-09-22 09:02:15 -07:00
secrets-aws feat(rust): align secret manager operation contexts (#42480) 2026-09-22 09:02:15 -07:00
secrets-azure feat(rust): align secret manager operation contexts (#42480) 2026-09-22 09:02:15 -07:00
secrets-cyberark feat(rust): align secret manager operation contexts (#42480) 2026-09-22 09:02:15 -07:00
secrets-google feat(rust): align secret manager operation contexts (#42480) 2026-09-22 09:02:15 -07:00
secrets-hashicorp feat(rust): align secret manager operation contexts (#42480) 2026-09-22 09:02:15 -07:00
secrets-types feat(rust): align secret manager operation contexts (#42480) 2026-09-22 09:02:15 -07:00
token-counter feat(tokenizer): preserve Python defaults with opt-in Rust dispatch (#42174) 2026-09-22 04:41:11 +00:00
token-counter-fast feat(tokenizer): preserve Python defaults with opt-in Rust dispatch (#42174) 2026-09-22 04:41:11 +00:00
token-counter-huggingface feat(tokenizer): preserve Python defaults with opt-in Rust dispatch (#42174) 2026-09-22 04:41:11 +00:00
token-counter-tiktoken feat(tokenizer): preserve Python defaults with opt-in Rust dispatch (#42174) 2026-09-22 04:41:11 +00:00
types refactor(rust): add types and core-utils crates, unify the provider error 2026-09-17 22:01:14 -07:00