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-01-15 23:22:21 -08:00
|
|
|
version = "0.2.8"
|
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 = [
|
|
|
|
|
"tiktoken>=0.5.0",
|
|
|
|
|
"pydantic>=2.0.0",
|
2026-01-14 21:21:04 -08:00
|
|
|
"openai>=2.14.0",
|
|
|
|
|
"sentence-transformers>=5.2.0",
|
2026-01-16 00:35:04 -08:00
|
|
|
"litellm>=1.0.0",
|
2026-01-06 23:16:58 -08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[project.optional-dependencies]
|
2026-01-07 11:36:44 -08:00
|
|
|
# Semantic relevance scoring with embeddings
|
|
|
|
|
relevance = [
|
|
|
|
|
"sentence-transformers>=2.2.0",
|
|
|
|
|
"numpy>=1.24.0",
|
|
|
|
|
]
|
|
|
|
|
# Proxy server
|
|
|
|
|
proxy = [
|
|
|
|
|
"fastapi>=0.100.0",
|
|
|
|
|
"uvicorn>=0.23.0",
|
|
|
|
|
"httpx>=0.24.0",
|
|
|
|
|
]
|
|
|
|
|
# Report generation
|
|
|
|
|
reports = [
|
|
|
|
|
"jinja2>=3.0.0",
|
|
|
|
|
]
|
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
|
|
|
# ML-based compression (LLMLingua-2)
|
|
|
|
|
llmlingua = [
|
|
|
|
|
"llmlingua>=0.2.0",
|
|
|
|
|
"torch>=2.0.0",
|
|
|
|
|
"transformers>=4.30.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
|
|
|
# AST-based code compression (tree-sitter)
|
|
|
|
|
code = [
|
|
|
|
|
"tree-sitter-language-pack>=0.10.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",
|
|
|
|
|
"openai>=1.0.0",
|
2026-01-07 11:36:44 -08:00
|
|
|
"anthropic>=0.18.0",
|
2026-01-06 23:16:58 -08:00
|
|
|
]
|
2026-01-07 11:36:44 -08:00
|
|
|
# All optional dependencies
|
|
|
|
|
all = [
|
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
|
|
|
"headroom-ai[relevance,proxy,reports,llmlingua,code]",
|
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-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-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",
|
|
|
|
|
"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
|
|
|
|
|
|
|
|
|
|
# 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__.:",
|
|
|
|
|
]
|