Metadata-Version: 2.4
Name: caio-atharva
Version: 1.0.11
Summary: Minify LLM prompts to reduce API token costs
Home-page: https://github.com/oasis-parzival/Cost-Aware-Inference-Orchestration
Author: Atharva Matale
Author-email: atharvamatale2907@gmail.com
License: MIT
Project-URL: Source, https://github.com/oasis-parzival/Cost-Aware-Inference-Orchestration
Project-URL: Tracker, https://github.com/oasis-parzival/Cost-Aware-Inference-Orchestration/issues
Keywords: llm,prompt,minify,cost,token-savings,optimizer
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.25.1
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# CAIO (Cost-Aware Inference Orchestration)

[![PyPI version](https://badge.fury.io/py/caio-atharva.svg)](https://badge.fury.io/py/caio-atharva) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

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

```bash
pip install caio-atharva
```

---

## Usage

Import `CAIO`, initialize it, and call `optimize()` to transform verbose prompts into compact instructions.

### Example â€” Fibonacci (tested locally)

```python
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):

```text
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; `prod` is safer for production workloads.

---

## Project Structure

```text
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.
