ContextClip (Python)
Ported line-for-line from the TypeScript implementation. See the root README for the pitch, the prior-art table, and the scope decisions — this file only covers what's specific to running the Python code.
Install
pip install -e ".[dev]"
Quickstart
PYTHONPATH=src python3 examples/quickstart.py
from contextclip import ContextClipper
clipper = ContextClipper(budget_tokens=200, tail_messages=2)
status = clipper.check(messages)
if status.action == "over_hard_limit":
result = await clipper.recover(messages)
# result.action is "drained" or "summarized" — result.messages never
# touches the last `tail_messages` of the original list.
Test
pytest
Status
Budget tracking, threshold checks, and staged drain-then-summarize
recovery with tail preservation are real and tested. Not yet published to
PyPI — contextclip is unclaimed there.
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 contextclip-0.0.1.tar.gz.
File metadata
- Download URL: contextclip-0.0.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dbaa5cb4a05777010799e6a6e1d1473814410d54313dc7b4c452aecbf8df70b
|
|
| MD5 |
3b30fdf3796fc5356259ae8742fc653c
|
|
| BLAKE2b-256 |
460433ba7fd26a02291c736090b001000a23a74eab04b1e3ca8eff2863fb5865
|
File details
Details for the file contextclip-0.0.1-py3-none-any.whl.
File metadata
- Download URL: contextclip-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a27e561eb91c7d04843488c7644358c0ff95183c4ac74a9011bdb742296a7338
|
|
| MD5 |
cbd81e0e6c7accc92b0eac684bd236b2
|
|
| BLAKE2b-256 |
9275563a3979f89fde9af07d3472a1c593630665c84b1a6363eabd58c072d76c
|