headroom-ai 0.2.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- headroom/__init__.py +212 -0
- headroom/cache/__init__.py +76 -0
- headroom/cache/anthropic.py +517 -0
- headroom/cache/base.py +342 -0
- headroom/cache/compression_feedback.py +613 -0
- headroom/cache/compression_store.py +814 -0
- headroom/cache/dynamic_detector.py +1026 -0
- headroom/cache/google.py +884 -0
- headroom/cache/openai.py +584 -0
- headroom/cache/registry.py +175 -0
- headroom/cache/semantic.py +451 -0
- headroom/ccr/__init__.py +77 -0
- headroom/ccr/context_tracker.py +582 -0
- headroom/ccr/mcp_server.py +319 -0
- headroom/ccr/response_handler.py +772 -0
- headroom/ccr/tool_injection.py +415 -0
- headroom/cli.py +219 -0
- headroom/client.py +977 -0
- headroom/compression/__init__.py +42 -0
- headroom/compression/detector.py +424 -0
- headroom/compression/handlers/__init__.py +22 -0
- headroom/compression/handlers/base.py +219 -0
- headroom/compression/handlers/code_handler.py +506 -0
- headroom/compression/handlers/json_handler.py +418 -0
- headroom/compression/masks.py +345 -0
- headroom/compression/universal.py +465 -0
- headroom/config.py +474 -0
- headroom/exceptions.py +192 -0
- headroom/integrations/__init__.py +159 -0
- headroom/integrations/agno/__init__.py +53 -0
- headroom/integrations/agno/hooks.py +345 -0
- headroom/integrations/agno/model.py +625 -0
- headroom/integrations/agno/providers.py +154 -0
- headroom/integrations/langchain/__init__.py +106 -0
- headroom/integrations/langchain/agents.py +326 -0
- headroom/integrations/langchain/chat_model.py +1002 -0
- headroom/integrations/langchain/langsmith.py +324 -0
- headroom/integrations/langchain/memory.py +319 -0
- headroom/integrations/langchain/providers.py +200 -0
- headroom/integrations/langchain/retriever.py +371 -0
- headroom/integrations/langchain/streaming.py +341 -0
- headroom/integrations/mcp/__init__.py +37 -0
- headroom/integrations/mcp/server.py +533 -0
- headroom/memory/__init__.py +37 -0
- headroom/memory/extractor.py +390 -0
- headroom/memory/fast_store.py +621 -0
- headroom/memory/fast_wrapper.py +311 -0
- headroom/memory/inline_extractor.py +229 -0
- headroom/memory/store.py +434 -0
- headroom/memory/worker.py +260 -0
- headroom/memory/wrapper.py +321 -0
- headroom/models/__init__.py +39 -0
- headroom/models/registry.py +687 -0
- headroom/parser.py +293 -0
- headroom/pricing/__init__.py +51 -0
- headroom/pricing/anthropic_prices.py +81 -0
- headroom/pricing/litellm_pricing.py +113 -0
- headroom/pricing/openai_prices.py +91 -0
- headroom/pricing/registry.py +188 -0
- headroom/providers/__init__.py +61 -0
- headroom/providers/anthropic.py +621 -0
- headroom/providers/base.py +131 -0
- headroom/providers/cohere.py +362 -0
- headroom/providers/google.py +427 -0
- headroom/providers/litellm.py +297 -0
- headroom/providers/openai.py +566 -0
- headroom/providers/openai_compatible.py +521 -0
- headroom/proxy/__init__.py +19 -0
- headroom/proxy/server.py +2683 -0
- headroom/py.typed +0 -0
- headroom/relevance/__init__.py +124 -0
- headroom/relevance/base.py +106 -0
- headroom/relevance/bm25.py +255 -0
- headroom/relevance/embedding.py +255 -0
- headroom/relevance/hybrid.py +259 -0
- headroom/reporting/__init__.py +5 -0
- headroom/reporting/generator.py +549 -0
- headroom/storage/__init__.py +41 -0
- headroom/storage/base.py +125 -0
- headroom/storage/jsonl.py +220 -0
- headroom/storage/sqlite.py +289 -0
- headroom/telemetry/__init__.py +91 -0
- headroom/telemetry/collector.py +764 -0
- headroom/telemetry/models.py +880 -0
- headroom/telemetry/toin.py +1579 -0
- headroom/tokenizer.py +80 -0
- headroom/tokenizers/__init__.py +75 -0
- headroom/tokenizers/base.py +210 -0
- headroom/tokenizers/estimator.py +198 -0
- headroom/tokenizers/huggingface.py +317 -0
- headroom/tokenizers/mistral.py +245 -0
- headroom/tokenizers/registry.py +398 -0
- headroom/tokenizers/tiktoken_counter.py +248 -0
- headroom/transforms/__init__.py +106 -0
- headroom/transforms/base.py +57 -0
- headroom/transforms/cache_aligner.py +357 -0
- headroom/transforms/code_compressor.py +1313 -0
- headroom/transforms/content_detector.py +335 -0
- headroom/transforms/content_router.py +1158 -0
- headroom/transforms/llmlingua_compressor.py +638 -0
- headroom/transforms/log_compressor.py +529 -0
- headroom/transforms/pipeline.py +297 -0
- headroom/transforms/rolling_window.py +350 -0
- headroom/transforms/search_compressor.py +365 -0
- headroom/transforms/smart_crusher.py +2682 -0
- headroom/transforms/text_compressor.py +259 -0
- headroom/transforms/tool_crusher.py +338 -0
- headroom/utils.py +215 -0
- headroom_ai-0.2.13.dist-info/METADATA +315 -0
- headroom_ai-0.2.13.dist-info/RECORD +114 -0
- headroom_ai-0.2.13.dist-info/WHEEL +4 -0
- headroom_ai-0.2.13.dist-info/entry_points.txt +2 -0
- headroom_ai-0.2.13.dist-info/licenses/LICENSE +190 -0
- headroom_ai-0.2.13.dist-info/licenses/NOTICE +43 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""Telemetry module for building the data flywheel.
|
|
2
|
+
|
|
3
|
+
This module collects PRIVACY-PRESERVING statistics about compression patterns
|
|
4
|
+
to enable cross-user learning and improve compression over time.
|
|
5
|
+
|
|
6
|
+
What we collect (anonymized):
|
|
7
|
+
- Tool output structure patterns (field types, not values)
|
|
8
|
+
- Compression decisions and ratios
|
|
9
|
+
- Retrieval patterns (rate, type, not content)
|
|
10
|
+
- Strategy effectiveness
|
|
11
|
+
|
|
12
|
+
What we DON'T collect:
|
|
13
|
+
- Actual data values
|
|
14
|
+
- User identifiers
|
|
15
|
+
- Queries or search terms
|
|
16
|
+
- File paths or tool names (unless opted in)
|
|
17
|
+
|
|
18
|
+
Usage:
|
|
19
|
+
from headroom.telemetry import get_telemetry_collector
|
|
20
|
+
|
|
21
|
+
collector = get_telemetry_collector()
|
|
22
|
+
|
|
23
|
+
# Record a compression event
|
|
24
|
+
collector.record_compression(
|
|
25
|
+
tool_signature="search_api:v1",
|
|
26
|
+
original_items=1000,
|
|
27
|
+
compressed_items=20,
|
|
28
|
+
strategy="top_n",
|
|
29
|
+
field_stats={...},
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Export for aggregation
|
|
33
|
+
stats = collector.export_stats()
|
|
34
|
+
|
|
35
|
+
TOIN (Tool Output Intelligence Network):
|
|
36
|
+
from headroom.telemetry import get_toin
|
|
37
|
+
|
|
38
|
+
toin = get_toin()
|
|
39
|
+
|
|
40
|
+
# Get compression hints before compressing
|
|
41
|
+
hint = toin.get_recommendation(tool_signature, query_context)
|
|
42
|
+
|
|
43
|
+
# Record compression outcome
|
|
44
|
+
toin.record_compression(tool_signature, ...)
|
|
45
|
+
|
|
46
|
+
# Record retrieval (automatic via compression_store)
|
|
47
|
+
toin.record_retrieval(sig_hash, retrieval_type, query, query_fields)
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
from .collector import (
|
|
51
|
+
TelemetryCollector,
|
|
52
|
+
TelemetryConfig,
|
|
53
|
+
get_telemetry_collector,
|
|
54
|
+
reset_telemetry_collector,
|
|
55
|
+
)
|
|
56
|
+
from .models import (
|
|
57
|
+
AnonymizedToolStats,
|
|
58
|
+
CompressionEvent,
|
|
59
|
+
FieldDistribution,
|
|
60
|
+
RetrievalStats,
|
|
61
|
+
ToolSignature,
|
|
62
|
+
)
|
|
63
|
+
from .toin import (
|
|
64
|
+
CompressionHint,
|
|
65
|
+
TOINConfig,
|
|
66
|
+
ToolIntelligenceNetwork,
|
|
67
|
+
ToolPattern,
|
|
68
|
+
get_toin,
|
|
69
|
+
reset_toin,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
__all__ = [
|
|
73
|
+
# Collector
|
|
74
|
+
"TelemetryCollector",
|
|
75
|
+
"TelemetryConfig",
|
|
76
|
+
"get_telemetry_collector",
|
|
77
|
+
"reset_telemetry_collector",
|
|
78
|
+
# Models
|
|
79
|
+
"AnonymizedToolStats",
|
|
80
|
+
"CompressionEvent",
|
|
81
|
+
"FieldDistribution",
|
|
82
|
+
"RetrievalStats",
|
|
83
|
+
"ToolSignature",
|
|
84
|
+
# TOIN
|
|
85
|
+
"CompressionHint",
|
|
86
|
+
"TOINConfig",
|
|
87
|
+
"ToolIntelligenceNetwork",
|
|
88
|
+
"ToolPattern",
|
|
89
|
+
"get_toin",
|
|
90
|
+
"reset_toin",
|
|
91
|
+
]
|