Skip to main content

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

contextclip-0.0.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

contextclip-0.0.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

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

Hashes for contextclip-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7dbaa5cb4a05777010799e6a6e1d1473814410d54313dc7b4c452aecbf8df70b
MD5 3b30fdf3796fc5356259ae8742fc653c
BLAKE2b-256 460433ba7fd26a02291c736090b001000a23a74eab04b1e3ca8eff2863fb5865

See more details on using hashes here.

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

Hashes for contextclip-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a27e561eb91c7d04843488c7644358c0ff95183c4ac74a9011bdb742296a7338
MD5 cbd81e0e6c7accc92b0eac684bd236b2
BLAKE2b-256 9275563a3979f89fde9af07d3472a1c593630665c84b1a6363eabd58c072d76c

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