Metadata-Version: 2.4
Name: leanctx
Version: 0.0.0
Summary: Drop-in prompt compression for production LLM applications. Cut Anthropic / OpenAI / Gemini bills by 40-60%.
Project-URL: Homepage, https://github.com/jia-gao/leanctx
Project-URL: Repository, https://github.com/jia-gao/leanctx
Project-URL: Issues, https://github.com/jia-gao/leanctx/issues
Author-email: Jay Gao <gjz140103@gmail.com>
License: MIT
License-File: LICENSE
Keywords: anthropic,gemini,langchain,langgraph,llm,llmlingua,openai,prompt-compression,rag
Classifier: Development Status :: 1 - Planning
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Provides-Extra: all
Requires-Dist: anthropic>=0.40.0; extra == 'all'
Requires-Dist: google-genai>=0.3.0; extra == 'all'
Requires-Dist: llmlingua>=0.2.0; extra == 'all'
Requires-Dist: openai>=1.50.0; extra == 'all'
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.40.0; extra == 'anthropic'
Provides-Extra: dev
Requires-Dist: build>=1.0; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6.0; extra == 'dev'
Requires-Dist: twine>=5.0; extra == 'dev'
Provides-Extra: gemini
Requires-Dist: google-genai>=0.3.0; extra == 'gemini'
Provides-Extra: lingua
Requires-Dist: llmlingua>=0.2.0; extra == 'lingua'
Provides-Extra: openai
Requires-Dist: openai>=1.50.0; extra == 'openai'
Description-Content-Type: text/markdown

# leanctx

**Drop-in prompt compression for production LLM applications.**
Cut Anthropic / OpenAI / Gemini bills by 40–60% without changing your code.

```python
# before
from anthropic import Anthropic

# after
from leanctx import Anthropic  # same interface, compressed requests
```

Open-source models. No API keys to anyone but your existing provider.
Your prompts and user data never leave your infrastructure by default.

---

> **Status:** v0.0.0 — name reservation. v0.1 (working release) coming in ~4 weeks.
> [Watch the repo](https://github.com/jia-gao/leanctx/subscription) to be notified.

## Who this is for

You're building a production LLM app and your token bill is a line item:

- RAG apps with large retrieved documents
- Long-running conversational agents
- LangChain / LangGraph / CrewAI workflows with growing tool chains
- Document-processing pipelines
- Anything where input tokens accumulate and you pay for every one

If your code calls `anthropic.messages.create()` or `openai.chat.completions.create()` in production, this is for you.

## How it works (coming in v0.1)

Three compression modes, one config switch:

- **`local`** — runs Microsoft's open-source LLMLingua-2 locally. Free marginal cost.
- **`self_llm`** — lets your own configured LLM do the compression. Highest quality.
- **`hybrid`** (default) — routes by content type: code stays verbatim, prose goes through LLMLingua-2, long important spans fall back to self_llm.

Content-aware routing means code blocks, diffs, stack traces, and tool schemas are preserved verbatim — no corrupted syntax.

## Roadmap

- [ ] v0.1 — Python SDK, `local` mode (LLMLingua-2), Anthropic + OpenAI drop-in clients
- [ ] v0.2 — `self_llm` mode, Gemini client, LangChain / LlamaIndex integrations
- [ ] v0.3 — TypeScript SDK, Docker image, OTel observability
- [ ] v0.4 — Helm chart, Kubernetes sidecar deployment

## Install (placeholder)

```bash
pip install leanctx  # not yet functional — reservation only
```

## Credits

Architecturally inspired by [OpenCode DCP](https://github.com/Opencode-DCP/opencode-dynamic-context-pruning) (AGPL-3.0, not copied). leanctx is a clean-room implementation under MIT.

Ships Microsoft's [LLMLingua-2](https://huggingface.co/microsoft/llmlingua-2-xlm-roberta-large-meetingbank) (MIT).

## License

MIT. See [LICENSE](LICENSE).
