llm-id-compressor
Shrinks LLM prompt/response token counts when you're sending a list of UUID-keyed items (transcript lines, database rows, log entries) to a model. Swaps each UUID for a short numeric ID before the request, and restores the original UUIDs from the model's response afterward.
Install
pip install llm-id-compressor
Usage
from llm_id_compressor import create_id_mapping, replace_uuids_with_nums, restore_uuids_in_response
items = [{"id": "550e8400-e29b-41d4-a716-446655440000", "text": "..."}, ...]
mapping = create_id_mapping(items)
compact_items = replace_uuids_with_nums(items, mapping["uuid_to_num"])
# send compact_items to the LLM, get back a list of {"id": "<num>", ...} lines
response_lines = call_llm(compact_items)
restored = restore_uuids_in_response(response_lines, mapping["num_to_uuid"])
replace_uuids_with_nums expects each item to have exactly id and text
keys - any other fields are dropped, and an item missing text raises a
KeyError. restore_uuids_in_response has no such restriction: it preserves
every field on each response line, only rewriting id.
restore_uuids_in_response silently drops any line whose numeric id wasn't
in the original mapping (a hallucinated id) rather than raising - callers
that insert results by a global primary key would otherwise have one bad
line abort the whole batch.
Why this exists
Sending a list of UUID-keyed items to an LLM burns tokens twice over: once in the prompt, once in the response, on 36-character identifiers the model never actually reasons about. There's no other package on PyPI doing this specific swap - it's a five-minute fix once you know to look for it, but easy to miss.
Contributing
Issues and PRs welcome - see CONTRIBUTING.md.
License
MIT
Metadata
Release files for llm-id-compressor 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llm_id_compressor-0.1.0.tar.gz | 4.5 kB | Without provenance | Details for llm_id_compressor-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_id_compressor-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for llm_id_compressor-0.1.0-py3-none-any.whl |
Total release size: 9.1 kB
Release files / llm_id_compressor-0.1.0.tar.gz
| Download URL | llm_id_compressor-0.1.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81b5ecf83b1b9598cc1ff10c44db7f5d969b8373fa5b43b66f150b1db07ed154
|
|
BLAKE2b-256 checksum How to use checksums |
93650486a74b4263240cca33edcc89deca4f31b0636e81ec189f31121a9dc15b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Release files / llm_id_compressor-0.1.0-py3-none-any.whl
| Download URL | llm_id_compressor-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f82862f2d6a5d6e979ef4e18a101e65b511128040f852074687d7b36272b38c
|
|
BLAKE2b-256 checksum How to use checksums |
7445e06e67c8ae3de238a8c202fcdaa544345b334de2950340d462cccab1a34e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Security for llm-id-compressor 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.