promptolian 2.2.1__tar.gz
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.
- promptolian-2.2.1/PKG-INFO +206 -0
- promptolian-2.2.1/README.md +148 -0
- promptolian-2.2.1/promptolian/__init__.py +17 -0
- promptolian-2.2.1/promptolian/cli.py +554 -0
- promptolian-2.2.1/promptolian/compress.py +204 -0
- promptolian-2.2.1/promptolian/mcp_server.py +165 -0
- promptolian-2.2.1/promptolian/patch.py +283 -0
- promptolian-2.2.1/promptolian/proxy.py +1219 -0
- promptolian-2.2.1/promptolian/server.py +70 -0
- promptolian-2.2.1/promptolian.egg-info/PKG-INFO +206 -0
- promptolian-2.2.1/promptolian.egg-info/SOURCES.txt +20 -0
- promptolian-2.2.1/promptolian.egg-info/dependency_links.txt +1 -0
- promptolian-2.2.1/promptolian.egg-info/entry_points.txt +4 -0
- promptolian-2.2.1/promptolian.egg-info/requires.txt +48 -0
- promptolian-2.2.1/promptolian.egg-info/top_level.txt +1 -0
- promptolian-2.2.1/pyproject.toml +107 -0
- promptolian-2.2.1/setup.cfg +4 -0
- promptolian-2.2.1/tests/test_api.py +136 -0
- promptolian-2.2.1/tests/test_context_engine.py +122 -0
- promptolian-2.2.1/tests/test_engine.py +122 -0
- promptolian-2.2.1/tests/test_proxy.py +249 -0
- promptolian-2.2.1/tests/test_sdk.py +196 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: promptolian
|
|
3
|
+
Version: 2.2.1
|
|
4
|
+
Summary: Drop-in SDK for Anthropic & OpenAI — compresses prompts transparently. CLI + REST API + Claude Code MCP.
|
|
5
|
+
Author-email: Maurizio Lospi <maurizio.lospi@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://promptolian.com
|
|
8
|
+
Project-URL: Repository, https://github.com/maurizio-lospi/promptolian
|
|
9
|
+
Keywords: prompt,compression,llm,tokens,claude,chatgpt,mcp
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Provides-Extra: tiktoken
|
|
21
|
+
Requires-Dist: tiktoken>=0.6; extra == "tiktoken"
|
|
22
|
+
Provides-Extra: nlp
|
|
23
|
+
Requires-Dist: tiktoken>=0.6; extra == "nlp"
|
|
24
|
+
Requires-Dist: spacy>=3.7; extra == "nlp"
|
|
25
|
+
Provides-Extra: proxy
|
|
26
|
+
Requires-Dist: flask>=3.0; extra == "proxy"
|
|
27
|
+
Requires-Dist: flask-cors>=4.0; extra == "proxy"
|
|
28
|
+
Requires-Dist: httpx>=0.27; extra == "proxy"
|
|
29
|
+
Provides-Extra: proxy-cloud
|
|
30
|
+
Requires-Dist: flask>=3.0; extra == "proxy-cloud"
|
|
31
|
+
Requires-Dist: flask-cors>=4.0; extra == "proxy-cloud"
|
|
32
|
+
Requires-Dist: httpx>=0.27; extra == "proxy-cloud"
|
|
33
|
+
Requires-Dist: psycopg2-binary>=2.9; extra == "proxy-cloud"
|
|
34
|
+
Requires-Dist: stripe>=9.0; extra == "proxy-cloud"
|
|
35
|
+
Provides-Extra: sdk
|
|
36
|
+
Requires-Dist: anthropic>=0.25; extra == "sdk"
|
|
37
|
+
Provides-Extra: sdk-openai
|
|
38
|
+
Requires-Dist: openai>=1.0; extra == "sdk-openai"
|
|
39
|
+
Provides-Extra: server
|
|
40
|
+
Requires-Dist: flask>=3.0; extra == "server"
|
|
41
|
+
Requires-Dist: flask-cors>=4.0; extra == "server"
|
|
42
|
+
Provides-Extra: self-hosted
|
|
43
|
+
Requires-Dist: flask>=3.0; extra == "self-hosted"
|
|
44
|
+
Requires-Dist: flask-cors>=4.0; extra == "self-hosted"
|
|
45
|
+
Requires-Dist: tiktoken>=0.6; extra == "self-hosted"
|
|
46
|
+
Requires-Dist: spacy>=3.7; extra == "self-hosted"
|
|
47
|
+
Requires-Dist: httpx>=0.27; extra == "self-hosted"
|
|
48
|
+
Provides-Extra: mcp
|
|
49
|
+
Requires-Dist: mcp>=1.0; extra == "mcp"
|
|
50
|
+
Requires-Dist: httpx>=0.27; extra == "mcp"
|
|
51
|
+
Provides-Extra: full
|
|
52
|
+
Requires-Dist: promptolian[tiktoken]; extra == "full"
|
|
53
|
+
Requires-Dist: promptolian[nlp]; extra == "full"
|
|
54
|
+
Requires-Dist: promptolian[server]; extra == "full"
|
|
55
|
+
Requires-Dist: promptolian[mcp]; extra == "full"
|
|
56
|
+
Requires-Dist: stripe>=9.0; extra == "full"
|
|
57
|
+
Requires-Dist: psycopg2-binary>=2.9; extra == "full"
|
|
58
|
+
|
|
59
|
+
# Promptolian — Context Reliability Proxy for AI Agents
|
|
60
|
+
|
|
61
|
+
> Proxy layer for AI agents — keeps context intact across long conversations and eliminates redundant token costs. One line to add, zero changes to your agent logic.
|
|
62
|
+
|
|
63
|
+
**[promptolian.com](https://promptolian.com)** · [Pricing](https://promptolian.com/pricing.html) · [Dashboard](https://promptolian.com/dashboard.html) · [Docs](https://promptolian.com/docs.html)
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Quick Start (dev)
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# 1. Setup (run once)
|
|
71
|
+
bash ~/promptly/workspace.sh
|
|
72
|
+
|
|
73
|
+
# 2. Start public API at http://localhost:3001
|
|
74
|
+
cd ~/promptly/public/api && python3 api.py
|
|
75
|
+
|
|
76
|
+
# 3. Start transparent proxy at http://localhost:3002
|
|
77
|
+
python -m promptolian.proxy
|
|
78
|
+
# or: python -m promptolian.proxy --compress (+ context history compression)
|
|
79
|
+
|
|
80
|
+
# 4. Full dev workspace (tmux — API + proxy + website + monitor)
|
|
81
|
+
~/promptly/workspace.sh
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Project Structure
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
~/promptly/
|
|
90
|
+
│
|
|
91
|
+
├── public/ ← Public git submodule (promptolian.com)
|
|
92
|
+
│ ├── website/
|
|
93
|
+
│ │ ├── index.html ← Landing page
|
|
94
|
+
│ │ ├── pricing.html ← Pricing + ROI calculator
|
|
95
|
+
│ │ ├── benchmarks.html ← Context quality benchmark results
|
|
96
|
+
│ │ └── docs.html ← Integration docs
|
|
97
|
+
│ ├── api/
|
|
98
|
+
│ │ ├── api.py ← Flask REST API (port 3001)
|
|
99
|
+
│ │ └── context_engine.py ← KV-sandwich context compression pipeline
|
|
100
|
+
│ └── promptolian/
|
|
101
|
+
│ ├── proxy.py ← Transparent proxy (port 3002)
|
|
102
|
+
│ └── __main__.py ← CLI entry point
|
|
103
|
+
│
|
|
104
|
+
├── tools/
|
|
105
|
+
│ ├── hooks/ ← Claude Code compression hooks
|
|
106
|
+
│ ├── scripts/
|
|
107
|
+
│ │ ├── benchmark_compression.py ← 25-session quality benchmark (Factory.ai methodology)
|
|
108
|
+
│ │ ├── build_sessions_50.py ← Session data builder for benchmarks
|
|
109
|
+
│ │ ├── article_draft.md ← Article: "Your AI Agent Is Forgetting Things"
|
|
110
|
+
│ │ ├── gen_article_cover.py ← Cover image generator (PIL)
|
|
111
|
+
│ │ └── article_images/ ← cover_article.png, kv_sandwich.svg, ...
|
|
112
|
+
│ ├── audit/
|
|
113
|
+
│ │ └── fact_retention_check.py ← Regex-only fact retention auditor (OSS)
|
|
114
|
+
│ ├── dev/ ← Local dev utilities
|
|
115
|
+
│ └── reports/ ← Roadmap, schemas, onboarding docs
|
|
116
|
+
│
|
|
117
|
+
├── services/ ← Production Flask server + dashboard
|
|
118
|
+
│
|
|
119
|
+
├── tests/
|
|
120
|
+
│ ├── test_engine.py ← Engine tests
|
|
121
|
+
│ ├── test_context_engine.py ← Context engine tests
|
|
122
|
+
│ └── test_api.py ← API endpoint tests
|
|
123
|
+
│
|
|
124
|
+
└── monitor.py ← Live DB stats + fix tracker
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Context Engine
|
|
130
|
+
|
|
131
|
+
`public/api/context_engine.py` — KV-sandwich architecture:
|
|
132
|
+
|
|
133
|
+
- **HEAD** (first 2 turns): verbatim — session framing preserved
|
|
134
|
+
- **MIDDLE**: entity-encoded + compressed — redundant tokens removed
|
|
135
|
+
- **TAIL** (last 4 turns): verbatim — recent facts + task state intact
|
|
136
|
+
|
|
137
|
+
Benchmark results (25 sessions, Factory.ai 6-dimension scoring):
|
|
138
|
+
|
|
139
|
+
| | Promptolian | Anthropic built-in | OpenAI built-in |
|
|
140
|
+
|---|---|---|---|
|
|
141
|
+
| Quality score | **4.26 / 5** | 3.44 / 5 | 3.35 / 5 |
|
|
142
|
+
| Compression | 21.8% | 98.7% | 99.3% |
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Tool Schema Caching (proxy)
|
|
147
|
+
|
|
148
|
+
The transparent proxy adds `cache_control` to tool schemas and re-injects them on subsequent calls. Anthropic bills cached tokens at 10%.
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
Without proxy: 500 calls/day × 5 tools × 120 tok × 30 days = 9M tok/mo → $27.00
|
|
152
|
+
With proxy: 9M tok × 10% cache rate = 900K tok/mo → $2.70
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Tests
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Run all tests
|
|
161
|
+
python3 -m pytest tests/ -v
|
|
162
|
+
|
|
163
|
+
# By module
|
|
164
|
+
python3 -m pytest tests/test_context_engine.py
|
|
165
|
+
python3 -m pytest tests/test_api.py
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Fact Retention Audit (OSS)
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
python3 tools/audit/fact_retention_check.py session.json --verbose --threshold 80
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Regex-only (no LLM). Extracts numbers, URLs, key=value pairs, hostnames from session messages, checks survival rate after compression. Exit 0 = pass, 1 = below threshold.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Plans
|
|
181
|
+
|
|
182
|
+
| Plan | Price | Sessions | Keys |
|
|
183
|
+
|---|---|---|---|
|
|
184
|
+
| Free | $0 | SQLite · self-hosted | — |
|
|
185
|
+
| Solo | $9/mo | PostgreSQL · always-on | 1 |
|
|
186
|
+
| Team | $49/mo | PostgreSQL · always-on | Up to 10 |
|
|
187
|
+
|
|
188
|
+
→ [promptolian.com/pricing.html](https://promptolian.com/pricing.html)
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Tech Stack
|
|
193
|
+
|
|
194
|
+
| Layer | Tool |
|
|
195
|
+
|-------|------|
|
|
196
|
+
| Context engine | Python (rule-based, no LLM) |
|
|
197
|
+
| Proxy | Python / Flask |
|
|
198
|
+
| Public API | Flask + Flask-CORS |
|
|
199
|
+
| Database (local) | SQLite |
|
|
200
|
+
| Database (prod) | PostgreSQL (Railway) |
|
|
201
|
+
| Payments | Stripe |
|
|
202
|
+
| Website hosting | Vercel |
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
*Last updated: 2026-05-27 · Maurito · Zürich*
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Promptolian — Context Reliability Proxy for AI Agents
|
|
2
|
+
|
|
3
|
+
> Proxy layer for AI agents — keeps context intact across long conversations and eliminates redundant token costs. One line to add, zero changes to your agent logic.
|
|
4
|
+
|
|
5
|
+
**[promptolian.com](https://promptolian.com)** · [Pricing](https://promptolian.com/pricing.html) · [Dashboard](https://promptolian.com/dashboard.html) · [Docs](https://promptolian.com/docs.html)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Start (dev)
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# 1. Setup (run once)
|
|
13
|
+
bash ~/promptly/workspace.sh
|
|
14
|
+
|
|
15
|
+
# 2. Start public API at http://localhost:3001
|
|
16
|
+
cd ~/promptly/public/api && python3 api.py
|
|
17
|
+
|
|
18
|
+
# 3. Start transparent proxy at http://localhost:3002
|
|
19
|
+
python -m promptolian.proxy
|
|
20
|
+
# or: python -m promptolian.proxy --compress (+ context history compression)
|
|
21
|
+
|
|
22
|
+
# 4. Full dev workspace (tmux — API + proxy + website + monitor)
|
|
23
|
+
~/promptly/workspace.sh
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Project Structure
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
~/promptly/
|
|
32
|
+
│
|
|
33
|
+
├── public/ ← Public git submodule (promptolian.com)
|
|
34
|
+
│ ├── website/
|
|
35
|
+
│ │ ├── index.html ← Landing page
|
|
36
|
+
│ │ ├── pricing.html ← Pricing + ROI calculator
|
|
37
|
+
│ │ ├── benchmarks.html ← Context quality benchmark results
|
|
38
|
+
│ │ └── docs.html ← Integration docs
|
|
39
|
+
│ ├── api/
|
|
40
|
+
│ │ ├── api.py ← Flask REST API (port 3001)
|
|
41
|
+
│ │ └── context_engine.py ← KV-sandwich context compression pipeline
|
|
42
|
+
│ └── promptolian/
|
|
43
|
+
│ ├── proxy.py ← Transparent proxy (port 3002)
|
|
44
|
+
│ └── __main__.py ← CLI entry point
|
|
45
|
+
│
|
|
46
|
+
├── tools/
|
|
47
|
+
│ ├── hooks/ ← Claude Code compression hooks
|
|
48
|
+
│ ├── scripts/
|
|
49
|
+
│ │ ├── benchmark_compression.py ← 25-session quality benchmark (Factory.ai methodology)
|
|
50
|
+
│ │ ├── build_sessions_50.py ← Session data builder for benchmarks
|
|
51
|
+
│ │ ├── article_draft.md ← Article: "Your AI Agent Is Forgetting Things"
|
|
52
|
+
│ │ ├── gen_article_cover.py ← Cover image generator (PIL)
|
|
53
|
+
│ │ └── article_images/ ← cover_article.png, kv_sandwich.svg, ...
|
|
54
|
+
│ ├── audit/
|
|
55
|
+
│ │ └── fact_retention_check.py ← Regex-only fact retention auditor (OSS)
|
|
56
|
+
│ ├── dev/ ← Local dev utilities
|
|
57
|
+
│ └── reports/ ← Roadmap, schemas, onboarding docs
|
|
58
|
+
│
|
|
59
|
+
├── services/ ← Production Flask server + dashboard
|
|
60
|
+
│
|
|
61
|
+
├── tests/
|
|
62
|
+
│ ├── test_engine.py ← Engine tests
|
|
63
|
+
│ ├── test_context_engine.py ← Context engine tests
|
|
64
|
+
│ └── test_api.py ← API endpoint tests
|
|
65
|
+
│
|
|
66
|
+
└── monitor.py ← Live DB stats + fix tracker
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Context Engine
|
|
72
|
+
|
|
73
|
+
`public/api/context_engine.py` — KV-sandwich architecture:
|
|
74
|
+
|
|
75
|
+
- **HEAD** (first 2 turns): verbatim — session framing preserved
|
|
76
|
+
- **MIDDLE**: entity-encoded + compressed — redundant tokens removed
|
|
77
|
+
- **TAIL** (last 4 turns): verbatim — recent facts + task state intact
|
|
78
|
+
|
|
79
|
+
Benchmark results (25 sessions, Factory.ai 6-dimension scoring):
|
|
80
|
+
|
|
81
|
+
| | Promptolian | Anthropic built-in | OpenAI built-in |
|
|
82
|
+
|---|---|---|---|
|
|
83
|
+
| Quality score | **4.26 / 5** | 3.44 / 5 | 3.35 / 5 |
|
|
84
|
+
| Compression | 21.8% | 98.7% | 99.3% |
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Tool Schema Caching (proxy)
|
|
89
|
+
|
|
90
|
+
The transparent proxy adds `cache_control` to tool schemas and re-injects them on subsequent calls. Anthropic bills cached tokens at 10%.
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
Without proxy: 500 calls/day × 5 tools × 120 tok × 30 days = 9M tok/mo → $27.00
|
|
94
|
+
With proxy: 9M tok × 10% cache rate = 900K tok/mo → $2.70
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Tests
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Run all tests
|
|
103
|
+
python3 -m pytest tests/ -v
|
|
104
|
+
|
|
105
|
+
# By module
|
|
106
|
+
python3 -m pytest tests/test_context_engine.py
|
|
107
|
+
python3 -m pytest tests/test_api.py
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Fact Retention Audit (OSS)
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
python3 tools/audit/fact_retention_check.py session.json --verbose --threshold 80
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Regex-only (no LLM). Extracts numbers, URLs, key=value pairs, hostnames from session messages, checks survival rate after compression. Exit 0 = pass, 1 = below threshold.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Plans
|
|
123
|
+
|
|
124
|
+
| Plan | Price | Sessions | Keys |
|
|
125
|
+
|---|---|---|---|
|
|
126
|
+
| Free | $0 | SQLite · self-hosted | — |
|
|
127
|
+
| Solo | $9/mo | PostgreSQL · always-on | 1 |
|
|
128
|
+
| Team | $49/mo | PostgreSQL · always-on | Up to 10 |
|
|
129
|
+
|
|
130
|
+
→ [promptolian.com/pricing.html](https://promptolian.com/pricing.html)
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Tech Stack
|
|
135
|
+
|
|
136
|
+
| Layer | Tool |
|
|
137
|
+
|-------|------|
|
|
138
|
+
| Context engine | Python (rule-based, no LLM) |
|
|
139
|
+
| Proxy | Python / Flask |
|
|
140
|
+
| Public API | Flask + Flask-CORS |
|
|
141
|
+
| Database (local) | SQLite |
|
|
142
|
+
| Database (prod) | PostgreSQL (Railway) |
|
|
143
|
+
| Payments | Stripe |
|
|
144
|
+
| Website hosting | Vercel |
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
*Last updated: 2026-05-27 · Maurito · Zürich*
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Promptolian — prompt compression engine."""
|
|
2
|
+
|
|
3
|
+
__version__ = "2.3.0"
|
|
4
|
+
__author__ = "Maurizio Lospi"
|
|
5
|
+
|
|
6
|
+
from .compress import compress, compress_messages, CompressionStats, count_tokens
|
|
7
|
+
from .patch import patch_anthropic, patch_openai, get_stats
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"compress",
|
|
11
|
+
"compress_messages",
|
|
12
|
+
"CompressionStats",
|
|
13
|
+
"count_tokens",
|
|
14
|
+
"patch_anthropic",
|
|
15
|
+
"patch_openai",
|
|
16
|
+
"get_stats",
|
|
17
|
+
]
|