Skip to main content

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's get_instance_fn. Use litellm_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_hookParitokEngine.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 any read_original / gateway_search_tools calls itself (re-requesting the model via litellm.acompletion until a plain turn returns), then rewrites any Edit whose old_string was 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

litellm_paritok-0.1.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litellm_paritok-0.1.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

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

Hashes for litellm_paritok-0.1.0.tar.gz
Algorithm Hash digest
SHA256 39d44b4220b82fa5848b42dc0ab33f5527580238ba68d3b155d038b6005baf59
MD5 fc57f4dbf4e45150aee65be986b655e7
BLAKE2b-256 e82ccf9a6bb42e1b9a8fb317d4ae4f7e5df5edf4b6b06dd770d472b188edfb93

See more details on using hashes here.

File details

Details for the file litellm_paritok-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for litellm_paritok-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e069d203b99f56fb2625ed7729eb32f113b02786ff8550e02712f7d3940247f
MD5 3e98ceff53f44f09d8ada0c0dd840524
BLAKE2b-256 5e3565c990ff765c3ebf22e1e06d03d5cb3cb174b561a7e90c0ec5d7fdd1de29

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page