2026-01-06 23:16:58 -08:00
|
|
|
[build-system]
|
|
|
|
|
requires = ["hatchling"]
|
|
|
|
|
build-backend = "hatchling.build"
|
|
|
|
|
|
|
|
|
|
[project]
|
2026-01-10 14:51:08 -08:00
|
|
|
name = "headroom-ai"
|
2026-04-02 18:00:49 -07:00
|
|
|
version = "0.5.18"
|
2026-01-07 11:36:44 -08:00
|
|
|
description = "The Context Optimization Layer for LLM Applications - Cut costs by 50-90%"
|
2026-01-06 23:16:58 -08:00
|
|
|
readme = "README.md"
|
2026-01-07 11:36:44 -08:00
|
|
|
license = "Apache-2.0"
|
2026-01-06 23:16:58 -08:00
|
|
|
requires-python = ">=3.10"
|
|
|
|
|
authors = [
|
2026-01-07 11:36:44 -08:00
|
|
|
{ name = "Headroom Contributors" }
|
|
|
|
|
]
|
|
|
|
|
maintainers = [
|
|
|
|
|
{ name = "Headroom Contributors" }
|
2026-01-06 23:16:58 -08:00
|
|
|
]
|
|
|
|
|
keywords = [
|
|
|
|
|
"llm",
|
|
|
|
|
"openai",
|
2026-01-07 11:36:44 -08:00
|
|
|
"anthropic",
|
|
|
|
|
"claude",
|
|
|
|
|
"gpt",
|
2026-01-06 23:16:58 -08:00
|
|
|
"context",
|
|
|
|
|
"token",
|
|
|
|
|
"optimization",
|
2026-01-07 11:36:44 -08:00
|
|
|
"compression",
|
2026-01-06 23:16:58 -08:00
|
|
|
"caching",
|
2026-01-07 11:36:44 -08:00
|
|
|
"proxy",
|
|
|
|
|
"ai",
|
|
|
|
|
"machine-learning",
|
2026-01-06 23:16:58 -08:00
|
|
|
]
|
|
|
|
|
classifiers = [
|
2026-01-07 11:36:44 -08:00
|
|
|
"Development Status :: 4 - Beta",
|
2026-01-06 23:16:58 -08:00
|
|
|
"Intended Audience :: Developers",
|
2026-01-07 11:36:44 -08:00
|
|
|
"License :: OSI Approved :: Apache Software License",
|
|
|
|
|
"Operating System :: OS Independent",
|
2026-01-06 23:16:58 -08:00
|
|
|
"Programming Language :: Python :: 3",
|
|
|
|
|
"Programming Language :: Python :: 3.10",
|
|
|
|
|
"Programming Language :: Python :: 3.11",
|
|
|
|
|
"Programming Language :: Python :: 3.12",
|
2026-01-07 11:36:44 -08:00
|
|
|
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
2026-01-06 23:16:58 -08:00
|
|
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
2026-01-07 11:36:44 -08:00
|
|
|
"Typing :: Typed",
|
2026-01-06 23:16:58 -08:00
|
|
|
]
|
|
|
|
|
dependencies = [
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# Core: lightweight compression (SmartCrusher, ContentRouter, CCR, TOIN)
|
|
|
|
|
"tiktoken>=0.5.0", # Tokenizer for all compressors
|
|
|
|
|
"pydantic>=2.0.0", # Config and data models
|
2026-03-24 11:58:25 -07:00
|
|
|
"litellm==1.82.3", # Model registry, pricing, and provider support
|
Add Click-based CLI with memory management commands
Refactor CLI from argparse to Click for better extensibility:
- New headroom/cli/ package with modular command structure
- Memory commands: list, show, stats, edit, delete, prune, purge, export, import
- Rich terminal output with tables, colors, and formatted stats
- Duration parsing for --older-than and --since flags (7d, 2w, 1m)
- Comprehensive tests using Click's CliRunner (55 tests, no mocks)
CLI structure:
headroom proxy - Start optimization proxy (migrated from argparse)
headroom memory ... - Memory management (new)
headroom evals ... - Evaluation commands (migrated, now under evals group)
Backwards compatibility maintained via headroom/cli.py shim.
2026-01-29 21:19:27 -08:00
|
|
|
"click>=8.1.0", # CLI framework
|
|
|
|
|
"rich>=13.0.0", # Rich terminal output
|
2026-01-06 23:16:58 -08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[project.optional-dependencies]
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# Proxy server (most common install: pip install headroom-ai[proxy])
|
2026-01-07 11:36:44 -08:00
|
|
|
proxy = [
|
|
|
|
|
"fastapi>=0.100.0",
|
|
|
|
|
"uvicorn>=0.23.0",
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
"httpx[http2]>=0.24.0",
|
|
|
|
|
"openai>=2.14.0", # OpenAI API format support
|
2026-03-16 22:56:30 -07:00
|
|
|
"mcp>=1.0.0", # MCP server (headroom_compress, retrieve, stats)
|
2026-03-25 01:04:26 -07:00
|
|
|
"magika>=0.6.0", # ML content detection for ContentRouter
|
2026-03-30 16:01:51 -07:00
|
|
|
"zstandard>=0.20.0", # Decompress zstd request bodies (Codex, etc.)
|
2026-03-30 22:00:12 -07:00
|
|
|
"websockets>=13.0", # WebSocket proxy for /v1/responses (Codex gpt-5.4+)
|
2026-03-30 22:50:13 -07:00
|
|
|
"onnxruntime>=1.16.0", # Kompress ONNX INT8 text compression (no torch needed)
|
|
|
|
|
"transformers>=4.30.0", # Tokenizer only (for Kompress)
|
2026-01-07 11:36:44 -08:00
|
|
|
]
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# AST-based code compression (tree-sitter)
|
|
|
|
|
code = [
|
|
|
|
|
"tree-sitter-language-pack>=0.10.0",
|
2026-01-07 11:36:44 -08:00
|
|
|
]
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# ML-based compression with Kompress (ModernBERT)
|
|
|
|
|
ml = [
|
|
|
|
|
"torch>=2.0.0",
|
|
|
|
|
"transformers>=4.30.0",
|
|
|
|
|
]
|
|
|
|
|
# Legacy ML compression (LLMLingua-2 — use [ml] instead for Kompress)
|
Add LLMLingua-2 opt-in support to proxy server
Integrate Microsoft's LLMLingua-2 ML-based compression as an opt-in
feature for the proxy server, with excellent developer experience.
Features:
- New CLI flags: --llmlingua, --llmlingua-device, --llmlingua-rate
- ProxyConfig options: llmlingua_enabled, llmlingua_device, llmlingua_target_rate
- Smart startup hints when llmlingua is available but not enabled
- Helpful error messages when enabled but not installed
- LLMLinguaCompressor inserted before RollingWindow in pipeline
Why opt-in:
- Heavy dependencies (~2GB torch, transformers)
- 10-30s cold start for model loading
- ~1GB RAM when loaded
- Default proxy stays lightweight (<5ms overhead)
Tests:
- 26 new tests in test_proxy_llmlingua.py covering config, setup,
banner status, CLI args, DevEx messages, and edge cases
Documentation:
- Updated README.md with proxy integration section
- Updated docs/proxy.md with LLMLingua CLI options
- Updated docs/transforms.md with LLMLinguaCompressor reference
- Updated docs/ARCHITECTURE.md with pipeline and file structure
- Updated CHANGELOG.md with new feature
2026-01-14 12:12:45 -08:00
|
|
|
llmlingua = [
|
|
|
|
|
"llmlingua>=0.2.0",
|
|
|
|
|
"torch>=2.0.0",
|
|
|
|
|
"transformers>=4.30.0",
|
|
|
|
|
]
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# Memory system (hierarchical memory with vector search)
|
|
|
|
|
memory = [
|
|
|
|
|
"hnswlib>=0.8.0",
|
|
|
|
|
"sqlite-vec>=0.1.6",
|
|
|
|
|
"sentence-transformers>=2.2.0",
|
|
|
|
|
]
|
|
|
|
|
# Semantic relevance scoring with embeddings
|
|
|
|
|
relevance = [
|
|
|
|
|
"sentence-transformers>=2.2.0",
|
|
|
|
|
"numpy>=1.24.0",
|
|
|
|
|
]
|
|
|
|
|
# Image compression (ML-based routing)
|
|
|
|
|
image = [
|
|
|
|
|
"pillow>=10.0.0",
|
|
|
|
|
]
|
|
|
|
|
# Report generation
|
|
|
|
|
reports = [
|
|
|
|
|
"jinja2>=3.0.0",
|
Add AST-based code compression and custom model configuration
CodeAwareCompressor:
- Tree-sitter based AST parsing for Python, JS, TS, Go, Rust, Java, C, C++
- Preserves imports, signatures, type annotations, error handlers
- Guarantees syntactically valid output
- Uses tree-sitter-language-pack for broad language support
ContentRouter:
- Intelligent compression orchestrator
- Auto-routes content to optimal compressor based on type detection
- Source hint support for high-confidence routing
Custom Model Configuration:
- HEADROOM_MODEL_LIMITS env var and ~/.headroom/models.json support
- Pattern-based inference for unknown models (opus/sonnet/haiku tiers)
- Support for Claude 4.5, Claude 4, o3, o3-mini
- Graceful fallback - never crashes on unknown models
2026-01-14 13:46:55 -08:00
|
|
|
]
|
2026-02-06 11:40:23 -06:00
|
|
|
# any-llm multi-provider backend (requires Python 3.11+)
|
|
|
|
|
anyllm = [
|
|
|
|
|
"any-llm-sdk>=1.0.0",
|
|
|
|
|
]
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# LangChain integration
|
|
|
|
|
langchain = [
|
|
|
|
|
"langchain-core>=0.2.0",
|
|
|
|
|
"langchain-openai>=0.1.0",
|
|
|
|
|
]
|
2026-01-16 16:00:13 -08:00
|
|
|
# Agno agent framework integration
|
|
|
|
|
agno = [
|
|
|
|
|
"agno>=1.0.0",
|
|
|
|
|
]
|
feat: Add AWS Strands Agents SDK integration
## Description
Add Headroom integration with AWS Strands Agents SDK, enabling automatic
context optimization and tool output compression for Strands-based agents.
Fixes #14
## Type of Change
- [x] New feature (non-breaking change that adds functionality)
- [x] Documentation update
## Changes Made
### Core Integration (`headroom/integrations/strands/`)
- **HeadroomHookProvider** - Implements Strands `HookProvider` interface for
automatic tool output compression via `AfterToolCallEvent`. Compresses
verbose tool outputs before they enter conversation context.
- **HeadroomStrandsModel** - Model wrapper that extends Strands `Model` base
class for message-level optimization. Implements all required abstract
methods: `stream()`, `get_config()`, `update_config()`, `structured_output()`.
- **Provider auto-detection** - Automatically detects appropriate Headroom
provider (Anthropic, OpenAI, Google) based on wrapped Strands model type.
- **`strands-agents` as optional dependency** - Install with
`pip install headroom-ai[strands]`
### Testing (`tests/integrations/test_strands/`)
- **Real integration tests (25 tests)** - Use actual AWS Bedrock API calls
with Claude 3 Haiku. Skip automatically when credentials unavailable.
- **Unit tests (57 tests)** - Mock-based tests for internal logic, edge cases,
and error handling. No credentials required.
### Demo (`examples/strands_bedrock_demo.py`)
- Interactive demo showcasing both integration patterns
- Visual before/after compression comparison with token savings
- 4 verbose tools (search, logs, database, metrics) demonstrating real savings
- Supports `--hook` and `--model` flags for individual demos
## Testing
All tests verified:
- [x] Unit tests pass (57 tests)
- [x] Integration tests pass (25 tests with real Bedrock API)
- [x] Linting passes (`ruff check .`)
- [x] Type checking passes (`mypy headroom/integrations/strands/`)
- [x] Formatting passes (`ruff format --check`)
- [x] Demo runs successfully with ~50% token savings
## Test Output
```
$ pytest tests/integrations/test_strands/ -v
=================== 82 passed in 90.09s ===================
$ ruff check headroom/integrations/strands/ --ignore E402
All checks passed!
$ mypy headroom/integrations/strands/ --ignore-missing-imports
Success: no issues found
```
## Demo Results
```
╭────────────────────────────────────────────────────────────╮
│ HeadroomHookProvider Results │
│────────────────────────────────────────────────────────────│
│ Tokens BEFORE compression: 51,961 │
│ Tokens AFTER compression: 25,658 │
│ Tokens SAVED: 26,303 (50.6%) │
╰────────────────────────────────────────────────────────────╯
```
2026-01-31 00:31:37 -08:00
|
|
|
# AWS Strands Agents SDK integration
|
|
|
|
|
strands = [
|
|
|
|
|
"strands-agents>=0.1.0",
|
|
|
|
|
]
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# MCP server for Claude Code integration
|
2026-02-02 11:05:24 -08:00
|
|
|
mcp = [
|
|
|
|
|
"mcp>=1.0.0",
|
|
|
|
|
"httpx>=0.24.0",
|
|
|
|
|
]
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# Voice filler detection
|
Add Click-based CLI with memory management commands
Refactor CLI from argparse to Click for better extensibility:
- New headroom/cli/ package with modular command structure
- Memory commands: list, show, stats, edit, delete, prune, purge, export, import
- Rich terminal output with tables, colors, and formatted stats
- Duration parsing for --older-than and --since flags (7d, 2w, 1m)
- Comprehensive tests using Click's CliRunner (55 tests, no mocks)
CLI structure:
headroom proxy - Start optimization proxy (migrated from argparse)
headroom memory ... - Memory management (new)
headroom evals ... - Evaluation commands (migrated, now under evals group)
Backwards compatibility maintained via headroom/cli.py shim.
2026-01-29 21:19:27 -08:00
|
|
|
voice = [
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
"onnxruntime>=1.16.0",
|
|
|
|
|
"transformers>=4.30.0",
|
|
|
|
|
"torch>=2.0.0",
|
Add Click-based CLI with memory management commands
Refactor CLI from argparse to Click for better extensibility:
- New headroom/cli/ package with modular command structure
- Memory commands: list, show, stats, edit, delete, prune, purge, export, import
- Rich terminal output with tables, colors, and formatted stats
- Duration parsing for --older-than and --since flags (7d, 2w, 1m)
- Comprehensive tests using Click's CliRunner (55 tests, no mocks)
CLI structure:
headroom proxy - Start optimization proxy (migrated from argparse)
headroom memory ... - Memory management (new)
headroom evals ... - Evaluation commands (migrated, now under evals group)
Backwards compatibility maintained via headroom/cli.py shim.
2026-01-29 21:19:27 -08:00
|
|
|
]
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# Voice training (includes voice deps + training extras)
|
Add Click-based CLI with memory management commands
Refactor CLI from argparse to Click for better extensibility:
- New headroom/cli/ package with modular command structure
- Memory commands: list, show, stats, edit, delete, prune, purge, export, import
- Rich terminal output with tables, colors, and formatted stats
- Duration parsing for --older-than and --since flags (7d, 2w, 1m)
- Comprehensive tests using Click's CliRunner (55 tests, no mocks)
CLI structure:
headroom proxy - Start optimization proxy (migrated from argparse)
headroom memory ... - Memory management (new)
headroom evals ... - Evaluation commands (migrated, now under evals group)
Backwards compatibility maintained via headroom/cli.py shim.
2026-01-29 21:19:27 -08:00
|
|
|
voice-train = [
|
|
|
|
|
"headroom-ai[voice]",
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
"datasets>=2.14.0",
|
|
|
|
|
"accelerate>=0.20.0",
|
Add Click-based CLI with memory management commands
Refactor CLI from argparse to Click for better extensibility:
- New headroom/cli/ package with modular command structure
- Memory commands: list, show, stats, edit, delete, prune, purge, export, import
- Rich terminal output with tables, colors, and formatted stats
- Duration parsing for --older-than and --since flags (7d, 2w, 1m)
- Comprehensive tests using Click's CliRunner (55 tests, no mocks)
CLI structure:
headroom proxy - Start optimization proxy (migrated from argparse)
headroom memory ... - Memory management (new)
headroom evals ... - Evaluation commands (migrated, now under evals group)
Backwards compatibility maintained via headroom/cli.py shim.
2026-01-29 21:19:27 -08:00
|
|
|
]
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# Evaluation framework
|
Add comprehensive evaluation framework for compression accuracy
- Add headroom.evals module with 12+ dataset loaders (HotpotQA, SQuAD,
Natural Questions, TriviaQA, MS MARCO, LongBench, NarrativeQA, BFCL,
ToolBench, CodeSearchNet, HumanEval, built-in tool outputs)
- Add before/after evaluation runner that compares LLM responses with
original vs compressed context
- Add metrics: F1 score, semantic similarity, exact match, ground truth
- Add CLI: python -m headroom.evals quick|benchmark|list|report
- Add [evals] extra to pyproject.toml for pip install headroom-ai[evals]
Fix ContentRouter to use LLMLingua for plain text compression:
- Route TEXT strategy through LLMLingua instead of heuristic TextCompressor
- Adjust LLMLingua compression rates for better accuracy (0.5 vs 0.25)
- HotpotQA now achieves 95% accuracy with 44% compression
Update documentation with evaluation framework section
Fix test isolation in test_toin.py (TOIN singleton persistence)
2026-01-22 09:17:28 -08:00
|
|
|
evals = [
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
"datasets>=2.14.0",
|
|
|
|
|
"sentence-transformers>=2.2.0",
|
|
|
|
|
"numpy>=1.24.0",
|
|
|
|
|
"scikit-learn>=1.3.0",
|
|
|
|
|
"anthropic>=0.18.0",
|
|
|
|
|
"openai>=1.0.0",
|
2026-01-22 23:58:54 -08:00
|
|
|
]
|
Add Click-based CLI with memory management commands
Refactor CLI from argparse to Click for better extensibility:
- New headroom/cli/ package with modular command structure
- Memory commands: list, show, stats, edit, delete, prune, purge, export, import
- Rich terminal output with tables, colors, and formatted stats
- Duration parsing for --older-than and --since flags (7d, 2w, 1m)
- Comprehensive tests using Click's CliRunner (55 tests, no mocks)
CLI structure:
headroom proxy - Start optimization proxy (migrated from argparse)
headroom memory ... - Memory management (new)
headroom evals ... - Evaluation commands (migrated, now under evals group)
Backwards compatibility maintained via headroom/cli.py shim.
2026-01-29 21:19:27 -08:00
|
|
|
# AWS Bedrock backend
|
|
|
|
|
bedrock = [
|
|
|
|
|
"boto3>=1.28.0",
|
|
|
|
|
]
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# HTML content extraction
|
2026-01-31 10:08:29 -08:00
|
|
|
html = [
|
|
|
|
|
"trafilatura>=1.6.0",
|
|
|
|
|
]
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# Comprehensive LLM benchmarks
|
2026-02-01 21:23:09 -08:00
|
|
|
benchmark = [
|
|
|
|
|
"lm-eval>=0.4.0",
|
|
|
|
|
"openai>=1.0.0",
|
|
|
|
|
"anthropic>=0.18.0",
|
|
|
|
|
]
|
2026-01-07 11:36:44 -08:00
|
|
|
# Development dependencies
|
2026-01-06 23:16:58 -08:00
|
|
|
dev = [
|
|
|
|
|
"pytest>=7.0.0",
|
|
|
|
|
"pytest-cov>=4.0.0",
|
|
|
|
|
"pytest-asyncio>=0.21.0",
|
|
|
|
|
"ruff>=0.1.0",
|
|
|
|
|
"mypy>=1.0.0",
|
2026-01-21 21:49:29 -08:00
|
|
|
"pre-commit>=3.0.0",
|
2026-01-06 23:16:58 -08:00
|
|
|
"openai>=1.0.0",
|
2026-01-07 11:36:44 -08:00
|
|
|
"anthropic>=0.18.0",
|
2026-03-24 11:58:25 -07:00
|
|
|
"litellm==1.82.3",
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
"fastapi>=0.100.0",
|
|
|
|
|
"uvicorn>=0.23.0",
|
|
|
|
|
"httpx[http2]>=0.24.0",
|
|
|
|
|
"ollama>=0.4.0",
|
|
|
|
|
"langchain-ollama>=0.2.0",
|
|
|
|
|
"hnswlib>=0.8.0",
|
|
|
|
|
"sqlite-vec>=0.1.6",
|
|
|
|
|
"sentence-transformers>=2.2.0",
|
|
|
|
|
"numpy>=1.24.0",
|
2026-01-06 23:16:58 -08:00
|
|
|
]
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
# All optional dependencies (everything you need)
|
2026-01-07 11:36:44 -08:00
|
|
|
all = [
|
Slim core dependencies: 2.5GB → 195MB install size
Move heavy deps to optional extras: sentence-transformers, torch,
numpy, pillow, datasets, accelerate out of core. Remove unused deps
entirely (semantic-router, protobuf, sentencepiece).
New extras: [ml] for Kompress, [image] for image compression,
[langchain] for LangChain integration. Guard memory/image imports
so core install works without numpy/torch.
Core (tiktoken, pydantic, litellm, click, rich) gives full
compression: SmartCrusher, ContentRouter, CCR, TOIN, CLI.
2026-03-13 15:35:49 -07:00
|
|
|
"headroom-ai[proxy,code,ml,memory,relevance,image,reports,evals,voice,html,benchmark,mcp]",
|
2026-01-07 11:36:44 -08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[project.scripts]
|
|
|
|
|
headroom = "headroom.cli:main"
|
2026-01-06 23:16:58 -08:00
|
|
|
|
|
|
|
|
[project.urls]
|
2026-01-10 15:11:08 -08:00
|
|
|
Homepage = "https://github.com/chopratejas/headroom"
|
|
|
|
|
Documentation = "https://github.com/chopratejas/headroom#readme"
|
|
|
|
|
Repository = "https://github.com/chopratejas/headroom"
|
|
|
|
|
Issues = "https://github.com/chopratejas/headroom/issues"
|
|
|
|
|
Changelog = "https://github.com/chopratejas/headroom/blob/main/CHANGELOG.md"
|
2026-01-06 23:16:58 -08:00
|
|
|
|
|
|
|
|
[tool.hatch.build.targets.wheel]
|
|
|
|
|
packages = ["headroom"]
|
2026-02-01 22:51:56 -08:00
|
|
|
# Include non-Python files (dashboard templates, etc.)
|
|
|
|
|
artifacts = [
|
|
|
|
|
"headroom/dashboard/templates/*.html",
|
|
|
|
|
]
|
2026-01-06 23:16:58 -08:00
|
|
|
|
2026-01-07 11:36:44 -08:00
|
|
|
[tool.hatch.build.targets.sdist]
|
|
|
|
|
include = [
|
|
|
|
|
"/headroom",
|
|
|
|
|
"/tests",
|
|
|
|
|
"/LICENSE",
|
|
|
|
|
"/NOTICE",
|
|
|
|
|
"/README.md",
|
|
|
|
|
"/CHANGELOG.md",
|
|
|
|
|
]
|
|
|
|
|
|
2026-01-06 23:16:58 -08:00
|
|
|
[tool.ruff]
|
|
|
|
|
target-version = "py310"
|
|
|
|
|
line-length = 100
|
|
|
|
|
|
|
|
|
|
[tool.ruff.lint]
|
|
|
|
|
select = [
|
|
|
|
|
"E", # pycodestyle errors
|
|
|
|
|
"W", # pycodestyle warnings
|
|
|
|
|
"F", # pyflakes
|
|
|
|
|
"I", # isort
|
|
|
|
|
"B", # flake8-bugbear
|
|
|
|
|
"C4", # flake8-comprehensions
|
|
|
|
|
"UP", # pyupgrade
|
|
|
|
|
]
|
|
|
|
|
ignore = [
|
|
|
|
|
"E501", # line too long (handled by formatter)
|
|
|
|
|
"B008", # do not perform function calls in argument defaults
|
2026-01-07 11:36:44 -08:00
|
|
|
"B905", # zip without strict parameter
|
2026-01-21 21:49:29 -08:00
|
|
|
"UP038", # isinstance(x, (A, B)) is clearer than isinstance(x, A | B)
|
2026-01-06 23:16:58 -08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[tool.ruff.lint.isort]
|
|
|
|
|
known-first-party = ["headroom"]
|
|
|
|
|
|
2026-01-07 11:36:44 -08:00
|
|
|
[tool.ruff.format]
|
|
|
|
|
quote-style = "double"
|
|
|
|
|
indent-style = "space"
|
|
|
|
|
|
2026-01-06 23:16:58 -08:00
|
|
|
[tool.mypy]
|
|
|
|
|
python_version = "3.10"
|
|
|
|
|
warn_return_any = true
|
|
|
|
|
warn_unused_configs = true
|
|
|
|
|
disallow_untyped_defs = true
|
2026-01-07 11:36:44 -08:00
|
|
|
ignore_missing_imports = true
|
2026-01-06 23:16:58 -08:00
|
|
|
|
2026-01-10 15:53:38 -08:00
|
|
|
# Per-module overrides for modules with dynamic typing patterns
|
|
|
|
|
[[tool.mypy.overrides]]
|
|
|
|
|
module = [
|
|
|
|
|
"headroom.proxy.server",
|
2026-04-03 16:17:50 -07:00
|
|
|
"headroom.proxy.cost",
|
|
|
|
|
"headroom.proxy.prometheus_metrics",
|
|
|
|
|
"headroom.proxy.semantic_cache",
|
|
|
|
|
"headroom.proxy.rate_limiter",
|
|
|
|
|
"headroom.proxy.request_logger",
|
|
|
|
|
"headroom.proxy.helpers",
|
2026-01-10 15:53:38 -08:00
|
|
|
"headroom.integrations.langchain",
|
|
|
|
|
"headroom.integrations.mcp",
|
|
|
|
|
"headroom.ccr.mcp_server",
|
|
|
|
|
"headroom.relevance.embedding",
|
|
|
|
|
"headroom.reporting.generator",
|
|
|
|
|
]
|
|
|
|
|
disallow_untyped_defs = false
|
|
|
|
|
|
|
|
|
|
[[tool.mypy.overrides]]
|
|
|
|
|
module = [
|
|
|
|
|
"headroom.tokenizers.*",
|
|
|
|
|
"headroom.providers.litellm",
|
|
|
|
|
"headroom.providers.google",
|
|
|
|
|
]
|
|
|
|
|
disallow_untyped_defs = false
|
|
|
|
|
warn_return_any = false
|
|
|
|
|
|
2026-04-03 17:08:39 -07:00
|
|
|
# Handler mixins use self.* from HeadroomProxy via duck typing — mypy can't resolve these
|
|
|
|
|
[[tool.mypy.overrides]]
|
|
|
|
|
module = ["headroom.proxy.handlers.*"]
|
|
|
|
|
disallow_untyped_defs = false
|
|
|
|
|
ignore_errors = true
|
|
|
|
|
|
2026-01-10 15:53:38 -08:00
|
|
|
# Ignore third-party stubs with syntax errors
|
|
|
|
|
[[tool.mypy.overrides]]
|
|
|
|
|
module = ["mlx.*"]
|
|
|
|
|
ignore_errors = true
|
|
|
|
|
|
2026-01-06 23:16:58 -08:00
|
|
|
[tool.pytest.ini_options]
|
|
|
|
|
testpaths = ["tests"]
|
|
|
|
|
python_files = ["test_*.py"]
|
|
|
|
|
python_functions = ["test_*"]
|
|
|
|
|
addopts = "-v --tb=short"
|
2026-01-07 11:36:44 -08:00
|
|
|
asyncio_mode = "auto"
|
|
|
|
|
|
|
|
|
|
[tool.coverage.run]
|
|
|
|
|
source = ["headroom"]
|
|
|
|
|
branch = true
|
|
|
|
|
omit = [
|
|
|
|
|
"headroom/cli.py",
|
|
|
|
|
"*/tests/*",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[tool.coverage.report]
|
|
|
|
|
exclude_lines = [
|
|
|
|
|
"pragma: no cover",
|
|
|
|
|
"def __repr__",
|
|
|
|
|
"raise NotImplementedError",
|
|
|
|
|
"if TYPE_CHECKING:",
|
|
|
|
|
"if __name__ == .__main__.:",
|
|
|
|
|
]
|