litellm-paritok
Paritok context compression as a LiteLLM Proxy callback.
Drop one line in your LiteLLM Proxy config and every request through the proxy is
compressed before it hits the upstream provider — tool-schema filtering, file/tool-output
compression, history compression, non-destructive recall (read_original /
gateway_search_tools), and Edit-recovery — with zero changes to your agent or app.
Scope: this works under LiteLLM Proxy. The hooks it uses (
async_pre_call_hook/async_post_call_success_hook) are proxy-only, so the bare SDK path (import litellm; litellm.completion(...)) is not intercepted. See Limitations.
Install
pip install litellm-paritok # pulls in `paritok`
You also need a Paritok 4B compression backend (either one):
ollama pull paritok/paritok-4b-v1 # local Ollama, on your own machine
# or point Paritok at a hosted GPU server via an API key
Use
Add one line to your LiteLLM Proxy config.yaml:
litellm_settings:
callbacks: ["litellm_paritok.paritok_handler"]
Then run the proxy as usual; your app keeps pointing at LiteLLM:
litellm --config config.yaml
The callback string is a dotted path
module.instance, resolved by LiteLLM'sget_instance_fn. Uselitellm_paritok.paritok_handler(a ready-made instance this package exports) — not a bare"paritok", which LiteLLM would try to import as a module.
How it works
The package is a thin CustomLogger over the published paritok engine — the same
compression/recall/recovery algorithms that power the Paritok proxy, wired to LiteLLM's
hooks:
async_pre_call_hook→ParitokEngine.process_request(...): filters tool schemas, compresses file reads / tool outputs / old history, injects the virtual recall tools, and returns the modified request for the upstream call.async_post_call_success_hook→ recall resolve-loop + Edit recovery: answers anyread_original/gateway_search_toolscalls itself (re-requesting the model vialitellm.acompletionuntil a plain turn returns), then rewrites anyEditwhoseold_stringwas authored against a lossy summary so it matches the real file byte-for-byte.
Limitations
- Proxy-only. The bare LiteLLM SDK path does not trigger these hooks. SDK coverage would need a separate wrapper / custom provider.
- Requires a Paritok 4B backend (Ollama or hosted GPU) — the prerequisite for any Paritok deployment, not specific to this integration.
Development
pip install -e ".[dev]"
PYTHONPATH=. pytest tests/ -v
Licensed under Apache-2.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file litellm_paritok-0.1.0.tar.gz.
File metadata
- Download URL: litellm_paritok-0.1.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39d44b4220b82fa5848b42dc0ab33f5527580238ba68d3b155d038b6005baf59
|
|
| MD5 |
fc57f4dbf4e45150aee65be986b655e7
|
|
| BLAKE2b-256 |
e82ccf9a6bb42e1b9a8fb317d4ae4f7e5df5edf4b6b06dd770d472b188edfb93
|
File details
Details for the file litellm_paritok-0.1.0-py3-none-any.whl.
File metadata
- Download URL: litellm_paritok-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e069d203b99f56fb2625ed7729eb32f113b02786ff8550e02712f7d3940247f
|
|
| MD5 |
3e98ceff53f44f09d8ada0c0dd840524
|
|
| BLAKE2b-256 |
5e3565c990ff765c3ebf22e1e06d03d5cb3cb174b561a7e90c0ec5d7fdd1de29
|