Minify LLM prompts to reduce API token costs
Project description
CAIO (Cost-Aware Inference Orchestration)
CAIO (Cost-Aware Inference Orchestration) is a prompt-optimization library designed to reduce LLM API token usage while preserving developer intent and code semantics.
CAIO applies deterministic transformations and lightweight heuristics to:
- remove conversational noise (greetings, politeness, intros)
- strip long docstrings and comments
- normalize whitespace and punctuation
- abbreviate common stop-phrases and optionally vowel-strip long words
The output is a compact, instruction-focused prompt optimized for lower token counts and lower inference cost.
Key Features
- Generalized NLP Scrubber: identifies and removes non-essential conversational text while preserving code and intent.
- Code Minifier: strips comments, unnecessary whitespace and formatting overhead.
- Tiered Optimization: choose aggressive (
aggressive), development (dev) or conservative (prod) tiers. - Deterministic, Non-destructive: preserves code tokens and avoids changing program semantics.
- Fast and Local: runs locally with no external dependencies required for optimization itself.
Installation
pip install caio-atharva
Usage
Import CAIO, initialize it, and call optimize() to transform verbose prompts into compact instructions.
Example — Fibonacci (tested locally)
from caio import CAIO
optimizer = CAIO()
bloated_prompt = '''
Hello there! I hope you are having a great day.
I'm new to Python and I was wondering if you could please help me.
Could you write a function to calculate the fibonacci sequence?
Make sure it's recursive. Thanks so much!
'''
result = optimizer.optimize(bloated_prompt, tier="dev")
print("Original length:", len(bloated_prompt))
print("Optimized prompt:\n", result["optimized_prompt"])
print("Tokens before:", result.get("tokens_before"), "tokens after:", result.get("tokens_after"))
Expected optimized prompt (example):
CODE-ONLY;NO-CHAT;MINIFY-RESPONSE: write a function to calculate the fibonacci sequence; make it recursive
Notes:
- The optimizer preserves code-like tokens (
def,return,import,=) and prioritizes retaining program logic. - Use
tier='dev'for more aggressive reductions during development;prodis safer for production workloads.
Project Structure
CAIO-SDK/
├── caio/
│ ├── __init__.py
│ └── optimizer.py # Core logic: CAIO class & NLP scrubber
├── setup.py # Package configuration
└── README.md # Documentation
Metadata
- Developer: Atharva Matale
- License: MIT
- Version: 1.0.10
- Version: 1.0.11
Maximize efficient inference. Minimize costs. Use CAIO.
Project details
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 caio_atharva-1.0.11.tar.gz.
File metadata
- Download URL: caio_atharva-1.0.11.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71484d181d87c89f2436d53e29f8bf8ab6d71a7c762d10dd10bd1af1f80538e5
|
|
| MD5 |
1dca6daf614c9e10e0fa3d15f00b0481
|
|
| BLAKE2b-256 |
7507eb4685b949fcffcba9ca9ed54ba46fe1211bfedff44f3c3d998ac326dee4
|
File details
Details for the file caio_atharva-1.0.11-py3-none-any.whl.
File metadata
- Download URL: caio_atharva-1.0.11-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d234a5cc2d30c61d66a7a2c1416f592c4d1fef6471ec73773a0045bc48eee21
|
|
| MD5 |
ffe35525539da20ec3384115dfdfec97
|
|
| BLAKE2b-256 |
2ef37685a2f484cc05489cfde98bde0a02efb15c9614e2fa64f625d3d63a15a4
|