File size: 4,706 Bytes
9c7d451
 
 
 
 
90d3aea
0acc7fb
175746c
9c7d451
175746c
9c7d451
 
175746c
 
 
 
9c7d451
 
 
 
175746c
 
 
9c7d451
 
 
175746c
9c7d451
175746c
 
 
9c7d451
 
175746c
9c7d451
175746c
 
9c7d451
 
 
 
175746c
9c7d451
175746c
9c7d451
 
 
 
9c9bb30
 
09973b6
9c7d451
 
 
175746c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45633b6
 
 
 
 
 
905c229
 
 
 
f1e7b62
 
 
 
175746c
9c7d451
 
 
 
 
 
 
175746c
67c927f
 
9c7d451
175746c
 
905c229
175746c
 
 
 
9c7d451
 
55814fe
 
 
 
 
9c7d451
 
 
 
175746c
 
 
 
 
 
 
 
 
 
9c7d451
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175746c
9c7d451
 
 
 
 
175746c
 
 
 
9c7d451
 
 
 
 
175746c
9c7d451
bf779b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c7d451
 
 
 
 
175746c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "headroom-ai"
version = "0.2.13"
description = "The Context Optimization Layer for LLM Applications - Cut costs by 50-90%"
readme = "README.md"
license = "Apache-2.0"
requires-python = ">=3.10"
authors = [
    { name = "Headroom Contributors" }
]
maintainers = [
    { name = "Headroom Contributors" }
]
keywords = [
    "llm",
    "openai",
    "anthropic",
    "claude",
    "gpt",
    "context",
    "token",
    "optimization",
    "compression",
    "caching",
    "proxy",
    "ai",
    "machine-learning",
]
classifiers = [
    "Development Status :: 4 - Beta",
    "Intended Audience :: Developers",
    "License :: OSI Approved :: Apache Software License",
    "Operating System :: OS Independent",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Topic :: Scientific/Engineering :: Artificial Intelligence",
    "Topic :: Software Development :: Libraries :: Python Modules",
    "Typing :: Typed",
]
dependencies = [
    "tiktoken>=0.5.0",
    "pydantic>=2.0.0",
    "openai>=2.14.0",
    "sentence-transformers>=5.2.0",
    "litellm>=1.0.0",
]

[project.optional-dependencies]
# 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",
]
# ML-based compression (LLMLingua-2)
llmlingua = [
    "llmlingua>=0.2.0",
    "torch>=2.0.0",
    "transformers>=4.30.0",
]
# AST-based code compression (tree-sitter)
code = [
    "tree-sitter-language-pack>=0.10.0",
]
# Agno agent framework integration
agno = [
    "agno>=1.0.0",
]
# Development dependencies
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",
    "anthropic>=0.18.0",
    "ollama>=0.4.0",  # For Ollama integration tests (local LLM, no API key needed)
    "langchain-ollama>=0.2.0",  # For LangChain+Ollama integration tests
]
# All optional dependencies
all = [
    "headroom-ai[relevance,proxy,reports,llmlingua,code]",
]

[project.scripts]
headroom = "headroom.cli:main"

[project.urls]
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"

[tool.hatch.build.targets.wheel]
packages = ["headroom"]

[tool.hatch.build.targets.sdist]
include = [
    "/headroom",
    "/tests",
    "/LICENSE",
    "/NOTICE",
    "/README.md",
    "/CHANGELOG.md",
]

[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
    "B905",  # zip without strict parameter
]

[tool.ruff.lint.isort]
known-first-party = ["headroom"]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"

[tool.mypy]
python_version = "3.10"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
ignore_missing_imports = true

# 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

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_functions = ["test_*"]
addopts = "-v --tb=short"
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__.:",
]