adaptive-memory-multi-model-router 2.13.1 → 2.13.2
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.
- package/LANDING.md +23 -26
- package/MANIFESTO.md +21 -34
- package/README.md +136 -199
- package/package.json +2 -2
- package/tmlpd-pi-extension/README.md +29 -29
package/LANDING.md
CHANGED
|
@@ -1,46 +1,43 @@
|
|
|
1
|
-
# A3M
|
|
2
|
-
### The intelligence layer for model choice
|
|
1
|
+
# A3M Router — Parallel Multi-LLM Execution with Intelligent Merge
|
|
3
2
|
|
|
4
|
-
*One prompt
|
|
3
|
+
*One prompt. All providers. The best answer.*
|
|
5
4
|
|
|
6
5
|
---
|
|
7
6
|
|
|
8
|
-
## What
|
|
7
|
+
## What It Is
|
|
9
8
|
|
|
10
|
-
A
|
|
9
|
+
A routing layer between your app and every LLM provider. Routes every query to the cheapest capable model, runs multiple providers in parallel when quality matters, and scores results to return the best answer.
|
|
11
10
|
|
|
12
|
-
## What
|
|
11
|
+
## What It Does
|
|
13
12
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
13
|
+
- **Parallel ensemble** — Runs NVIDIA + Groq + OpenAI simultaneously, scores results, picks best
|
|
14
|
+
- **Smart routing** — 12 heuristic signals classify query complexity, routes to cheapest capable model
|
|
15
|
+
- **Cost control** — Hard per-user/team budgets with real-time tracking and alerts
|
|
16
|
+
- **Fault tolerance** — Circuit breaker, automatic failover, exponential backoff with jitter
|
|
17
|
+
- **Memory persistence** — Cross-session episodic memory with keyword indexing
|
|
18
18
|
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
**Calm. Invisible. Trustworthy.**
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## The Evidence
|
|
19
|
+
## By the Numbers
|
|
26
20
|
|
|
27
21
|
| Metric | Result |
|
|
28
22
|
|--------|--------|
|
|
29
|
-
| Routing Accuracy |
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
| Routing Accuracy | **99.5%** ±1 tier |
|
|
24
|
+
| Cost Savings | **62%** vs all-premium |
|
|
25
|
+
| Providers | **47+** |
|
|
26
|
+
| Cache Hit Rate | **30%+** |
|
|
27
|
+
| Size | **19.5 KB** |
|
|
28
|
+
| Startup | **<100ms** |
|
|
34
29
|
|
|
35
|
-
## Start in
|
|
30
|
+
## Start in 30 Seconds
|
|
36
31
|
|
|
37
32
|
```bash
|
|
38
33
|
npm install adaptive-memory-multi-model-router
|
|
39
|
-
npx a3m-router serve
|
|
34
|
+
npx a3m-router serve # OpenAI proxy at localhost:8787
|
|
35
|
+
npx a3m-router route "What is 2+2?" # Routing decision
|
|
36
|
+
npx a3m-router compare "Explain AI" # All providers side-by-side
|
|
40
37
|
```
|
|
41
38
|
|
|
42
|
-
|
|
39
|
+
Point any OpenAI-compatible client to `http://localhost:8787` with `model: "auto"`.
|
|
43
40
|
|
|
44
41
|
---
|
|
45
42
|
|
|
46
|
-
*A3M.
|
|
43
|
+
*A3M Router. Parallel multi-LLM execution with result merging.*
|
package/MANIFESTO.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# A3M Manifesto
|
|
1
|
+
# A3M Manifesto — Intelligent Multi-LLM Routing
|
|
2
2
|
|
|
3
|
-
*
|
|
3
|
+
*The intelligence layer between your app and every model.*
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -8,47 +8,34 @@
|
|
|
8
8
|
|
|
9
9
|
LLM ops are noisy. Expensive. Fragile.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
You choose providers one at a time. Bills accumulate. Providers fail silently. Quality varies across models. And when one provider fails, everyone retries at once — making the problem worse.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## The Truth
|
|
16
|
-
|
|
17
|
-
**A3M is not a router. A3M is taste for AI systems.**
|
|
18
|
-
|
|
19
|
-
It removes noise. Picks wisely. Makes every request feel inevitable.
|
|
20
|
-
|
|
21
|
-
---
|
|
13
|
+
**Sequential fallback is the default. It shouldn't be.**
|
|
22
14
|
|
|
23
|
-
##
|
|
15
|
+
## The Insight
|
|
24
16
|
|
|
25
|
-
|
|
17
|
+
Every query is different. Some need deep reasoning. Some need creative writing. Some need quick lookups. Most don't need GPT-4o — but you pay for it anyway.
|
|
26
18
|
|
|
27
|
-
|
|
19
|
+
**Nobody does parallel multi-LLM execution with result merging. Everyone does sequential fallback (try A → B → C).**
|
|
28
20
|
|
|
29
|
-
|
|
21
|
+
## The Solution
|
|
30
22
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
## The Evidence
|
|
34
|
-
|
|
35
|
-
| Metric | Value |
|
|
36
|
-
|--------|-------|
|
|
37
|
-
| Routing Accuracy | 100% |
|
|
38
|
-
| Fault Injection Pass Rate | 100% |
|
|
39
|
-
| Projected Cost Delta | -$0.33 per query |
|
|
40
|
-
|
|
41
|
-
---
|
|
23
|
+
A3M Router is a routing layer that sits between your app and every LLM provider. It:
|
|
42
24
|
|
|
43
|
-
|
|
25
|
+
1. **Routes** every query to the cheapest capable model (99.5% accuracy)
|
|
26
|
+
2. **Executes in parallel** when quality matters (ensemble voting)
|
|
27
|
+
3. **Enforces budgets** with hard caps per user and team
|
|
28
|
+
4. **Recovers gracefully** when providers fail (circuit breaker, failover)
|
|
29
|
+
5. **Learns from history** (persistent memory, exponential moving average)
|
|
44
30
|
|
|
45
|
-
|
|
46
|
-
npm install adaptive-memory-multi-model-router
|
|
47
|
-
npx a3m-router serve
|
|
48
|
-
```
|
|
31
|
+
## The Principles
|
|
49
32
|
|
|
50
|
-
|
|
33
|
+
1. **Parallel first** — When quality matters, run providers concurrently, not sequentially
|
|
34
|
+
2. **Transparent scoring** — Every ensemble result shows why it won
|
|
35
|
+
3. **Cost-aware** — Route simple queries to cheap providers automatically
|
|
36
|
+
4. **Zero ML** — Heuristic routing achieves 99.5% accuracy without GPUs or training
|
|
37
|
+
5. **Self-hosted** — No vendor lock-in, no account required
|
|
51
38
|
|
|
52
39
|
---
|
|
53
40
|
|
|
54
|
-
*A3M.
|
|
41
|
+
*A3M Router. Parallel multi-LLM execution with intelligent merge.*
|
package/README.md
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
[](https://github.com/Das-rebel/adaptive-memory-multi-model-router/actions)
|
|
7
7
|
[](./LICENSE)
|
|
8
8
|
|
|
9
|
-
> **Parallel Multi-LLM Execution with Intelligent Merge**
|
|
10
|
-
>
|
|
9
|
+
> **Parallel Multi-LLM Execution with Intelligent Merge**
|
|
10
|
+
> 47+ providers · ±1 tier routing · 3 routing modes · 62% cost savings · 19.5 KB · Zero ML
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## 🔥 What Makes A3M Different
|
|
15
15
|
|
|
16
|
-
**
|
|
16
|
+
**Everybody does sequential fallback (try A → B → C). Nobody does parallel multi-LLM execution with result merging.**
|
|
17
17
|
|
|
18
18
|
```mermaid
|
|
19
19
|
graph LR
|
|
@@ -24,188 +24,118 @@ graph LR
|
|
|
24
24
|
N --> M[Merge & Score]
|
|
25
25
|
G --> M
|
|
26
26
|
O --> M
|
|
27
|
-
M --> R[Best Answer + Reasoning]
|
|
27
|
+
M --> R[Best Answer + Winner Reasoning]
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
**A3M runs all providers simultaneously, scores each result by quality, and returns the best — with a transparent explanation of why it was chosen.**
|
|
31
|
-
|
|
32
30
|
| Everyone Else | A3M Router |
|
|
33
31
|
|:---|:---|
|
|
34
|
-
| `try A →
|
|
35
|
-
| Sequential fallback | Parallel ensemble |
|
|
36
|
-
| One chance per provider | All providers contribute |
|
|
37
|
-
| Black
|
|
32
|
+
| `try A → fail → try B → fail → try C` | `run A + B + C → score → pick best` |
|
|
33
|
+
| Sequential fallback (slow, fragile) | **Parallel ensemble** (fast, robust) |
|
|
34
|
+
| One chance per provider | All providers contribute simultaneously |
|
|
35
|
+
| Black-box routing | Transparent scoring with reasoning |
|
|
38
36
|
|
|
39
37
|
---
|
|
40
38
|
|
|
41
|
-
##
|
|
42
|
-
|
|
43
|
-
A3M Router is the routing engine at the heart of **all OmniClaw projects**:
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
┌─────────────────┐
|
|
47
|
-
│ A3M Router │
|
|
48
|
-
│ (Central Brain)│
|
|
49
|
-
└────────┬────────┘
|
|
50
|
-
│
|
|
51
|
-
┌──────────────────┼──────────────────┐
|
|
52
|
-
▼ ▼ ▼
|
|
53
|
-
┌────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
54
|
-
│ PI Agent │ │ WhatsApp Bot │ │ Telegram Bot │
|
|
55
|
-
│ (CLI) │ │ (GreenAPI) │ │ (@Dasomni) │
|
|
56
|
-
└────────────┘ └──────────────┘ └──────────────┘
|
|
57
|
-
│ │ │
|
|
58
|
-
└──────────────────┴──────────────────┘
|
|
59
|
-
▼
|
|
60
|
-
┌──────────────┐
|
|
61
|
-
│ 47+ LLM │
|
|
62
|
-
│ Providers │
|
|
63
|
-
│ NVIDIA · Groq · OpenAI · Anthropic · +│
|
|
64
|
-
└──────────────┘
|
|
65
|
-
```
|
|
39
|
+
## ⚡ Core Features
|
|
66
40
|
|
|
67
|
-
|
|
68
|
-
- **WhatsApp Bot** — `/ensemble`, `/multi`, `/digest`, smart routing
|
|
69
|
-
- **Telegram Bot** — `/ask`, `/digest`, `/compare`
|
|
70
|
-
- **CLI** — `npx a3m-router route`, `serve`, `compare`
|
|
41
|
+
### P0 — Parallel Ensemble (Unique)
|
|
71
42
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## ⚡ Parallel Ensemble (P0 — Core Differentiator)
|
|
77
|
-
|
|
78
|
-
Run every query against **NVIDIA + Groq + OpenAI** simultaneously. Score results on:
|
|
79
|
-
- **Specificity** — contains numbers, tech terms, code snippets
|
|
80
|
-
- **Structure** — well-formatted, bullet points, depth
|
|
81
|
-
- **Historical accuracy** — per-provider performance in similar queries
|
|
43
|
+
Run every query against multiple providers simultaneously. Score each result on specificity, structure, and relevance. Return the best answer with a transparent explanation.
|
|
82
44
|
|
|
83
45
|
```typescript
|
|
84
46
|
import { executeEnsemble } from 'adaptive-memory-multi-model-router/ensemble';
|
|
85
47
|
|
|
86
|
-
const result = await executeEnsemble(
|
|
87
|
-
"Explain how vector databases work",
|
|
88
|
-
systemPrompt,
|
|
89
|
-
context,
|
|
90
|
-
{ nvidia: callNvidia, groq: callGroq },
|
|
91
|
-
{ providers: ['nvidia', 'groq'], timeoutMs: 30000 }
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
console.log(`🏆 Winner: ${result.winner} (score: ${result.scores[result.winner]})`);
|
|
95
|
-
console.log(`📝 Reasoning: ${result.reasoning}`);
|
|
96
|
-
// → 🏆 Winner: nvidia (score: 75)
|
|
97
|
-
// → 📝 Reasoning: Ensemble merged 2 providers. nvidia scored 75 vs groq at 65.
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### Why This Matters
|
|
48
|
+
const result = await executeEnsemble(query, systemPrompt, context, executors);
|
|
101
49
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
50
|
+
console.log(`🏆 ${result.winner}: ${result.scores[result.winner]}`);
|
|
51
|
+
// → 🏆 nvidia: 75 (vs groq: 65)
|
|
52
|
+
// → "nvidia scored higher on specificity (code snippets) and structure"
|
|
53
|
+
```
|
|
105
54
|
|
|
106
|
-
|
|
55
|
+
### P1 — Query-Type Presets
|
|
107
56
|
|
|
108
|
-
Route
|
|
57
|
+
Route every query to the optimal provider and temperature based on what type of task it is:
|
|
109
58
|
|
|
110
59
|
| Type | Provider | Temp | Ensemble | Use Case |
|
|
111
60
|
|:---|:---|:---:|:---:|:---|
|
|
112
61
|
| ⚡ Fast | Groq | 0.3 | ❌ | Quick lookups, simple Q&A |
|
|
113
62
|
| 🔬 Research | NVIDIA | 0.3 | ✅ | Deep analysis, comparisons |
|
|
114
63
|
| 🎨 Creative | NVIDIA | 0.7 | ❌ | Writing, brainstorming |
|
|
115
|
-
| 💻 Code |
|
|
64
|
+
| 💻 Code | Any | 0.2 | ✅ | Debugging, architecture |
|
|
116
65
|
| 📖 Factual | Groq | 0.2 | ❌ | Definitions, facts |
|
|
117
66
|
|
|
118
67
|
```typescript
|
|
119
68
|
import { createPresetRouter } from 'adaptive-memory-multi-model-router/presets';
|
|
120
69
|
|
|
121
70
|
const router = createPresetRouter();
|
|
122
|
-
const preset = router.classify("Write a Python sort function");
|
|
123
|
-
// →
|
|
71
|
+
const preset = router.classify("Write a Python sort function"); // → 'code'
|
|
72
|
+
preset.temperature; // → 0.2
|
|
73
|
+
preset.ensemble; // → true
|
|
124
74
|
```
|
|
125
75
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
## 💰 Cost Control (P2)
|
|
76
|
+
### P2 — Cost Control
|
|
129
77
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
- **Per-provider breakdown** — see exactly where every dollar goes
|
|
133
|
-
- **Per-user/team budgets** — hard caps with alerts at 50%/80%/100%
|
|
134
|
-
- **Per-query cost display** — every response shows token count and cost
|
|
135
|
-
- **Auto-route simple queries** to cheapest providers
|
|
78
|
+
Hard budget enforcement, per-query cost tracking, and automatic cost optimization. Every response reports token count and cost.
|
|
136
79
|
|
|
137
80
|
```bash
|
|
138
81
|
npx a3m-router cost
|
|
139
82
|
|
|
140
83
|
💰 Cost Analytics (May 2026)
|
|
141
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
142
|
-
Total Spend: $127.45 / $500.00
|
|
143
|
-
Daily Average: $4.27
|
|
144
|
-
Queries: 28,392
|
|
145
|
-
|
|
146
84
|
Groq: $42.30 ████████ 33%
|
|
147
85
|
NVIDIA: $51.20 █████████ 40%
|
|
148
86
|
Claude: $28.90 █████ 23%
|
|
149
|
-
|
|
87
|
+
Total: $127.45 / $500.00 budget
|
|
150
88
|
```
|
|
151
89
|
|
|
152
|
-
|
|
90
|
+
### P3 — Persistent Memory
|
|
153
91
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
Agent memory persists across sessions via a simple `.memory.json` file:
|
|
92
|
+
Agent memories persist across sessions via a local JSON file. Auto-saves every 3 entries. Full keyword index rebuilt on load.
|
|
157
93
|
|
|
158
94
|
```typescript
|
|
159
95
|
import { EpisodicMemoryStore } from 'adaptive-memory-multi-model-router/memory';
|
|
160
96
|
|
|
161
|
-
const memory = new EpisodicMemoryStore(1000, './.
|
|
162
|
-
|
|
163
|
-
// Memory auto-saves to disk every 3 entries
|
|
164
|
-
// On startup, auto-loads from disk
|
|
165
|
-
// Full keyword index rebuilt on load
|
|
166
|
-
|
|
97
|
+
const memory = new EpisodicMemoryStore(1000, './.memory.json');
|
|
167
98
|
const similar = memory.getSimilarTasks("Python async API", 5);
|
|
168
|
-
console.log(`📖 Found ${similar.length} similar past tasks`);
|
|
169
99
|
```
|
|
170
100
|
|
|
171
101
|
---
|
|
172
102
|
|
|
173
|
-
##
|
|
103
|
+
## ⚡ Quick Start
|
|
174
104
|
|
|
175
105
|
```bash
|
|
176
|
-
npm install adaptive-memory-multi-model-router #
|
|
106
|
+
npm install adaptive-memory-multi-model-router # Node / TypeScript
|
|
177
107
|
pip install a3m-router # Python
|
|
178
108
|
```
|
|
179
109
|
|
|
180
|
-
###
|
|
110
|
+
### Route a Query
|
|
181
111
|
|
|
182
112
|
```typescript
|
|
183
113
|
import { A3MRouter } from 'adaptive-memory-multi-model-router/sdk';
|
|
184
114
|
|
|
185
115
|
const router = new A3MRouter();
|
|
116
|
+
const decision = router.route("Review this contract for liability");
|
|
117
|
+
// → { model: "anthropic/claude-3.5-sonnet", cost: 0.008, complexity: 0.87 }
|
|
118
|
+
```
|
|
186
119
|
|
|
187
|
-
|
|
188
|
-
const decision = router.route("Review this contract for liability clauses");
|
|
189
|
-
// → { model: "anthropic/claude-3.5-sonnet", tier: "premium", cost: 0.008 }
|
|
120
|
+
### Run Parallel Ensemble
|
|
190
121
|
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
// → Runs NVIDIA + Groq
|
|
122
|
+
```typescript
|
|
123
|
+
const response = await router.ensemble("Explain vector databases");
|
|
124
|
+
// → Runs NVIDIA + Groq simultaneously, returns best answer with winner reasoning
|
|
194
125
|
```
|
|
195
126
|
|
|
196
|
-
### OpenAI-Compatible Proxy
|
|
127
|
+
### OpenAI-Compatible Proxy (Zero Code Change)
|
|
197
128
|
|
|
198
129
|
```bash
|
|
199
130
|
npx a3m-router serve
|
|
200
|
-
# → Proxy
|
|
131
|
+
# → Proxy: http://localhost:8787
|
|
201
132
|
```
|
|
202
133
|
|
|
203
134
|
```python
|
|
204
135
|
from openai import OpenAI
|
|
205
|
-
client = OpenAI(base_url="http://localhost:8787/v1"
|
|
206
|
-
|
|
136
|
+
client = OpenAI(base_url="http://localhost:8787/v1")
|
|
207
137
|
response = client.chat.completions.create(
|
|
208
|
-
model="auto", # ← ensemble
|
|
138
|
+
model="auto", # ← ensemble, routing, cost tracking all kick in
|
|
209
139
|
messages=[{"role": "user", "content": "Hello!"}]
|
|
210
140
|
)
|
|
211
141
|
```
|
|
@@ -214,11 +144,11 @@ response = client.chat.completions.create(
|
|
|
214
144
|
|
|
215
145
|
```bash
|
|
216
146
|
npx a3m-router route "Explain quantum computing" # Route decision
|
|
217
|
-
npx a3m-router compare "What is AI?"
|
|
218
|
-
npx a3m-router
|
|
219
|
-
npx a3m-router
|
|
220
|
-
npx a3m-router
|
|
221
|
-
npx a3m-router
|
|
147
|
+
npx a3m-router compare "What is AI?" # Side-by-side providers
|
|
148
|
+
npx a3m-router health # Provider health
|
|
149
|
+
npx a3m-router cost # Cost analytics
|
|
150
|
+
npx a3m-router benchmark # Accuracy test
|
|
151
|
+
npx a3m-router serve --port 8787 # Start proxy
|
|
222
152
|
```
|
|
223
153
|
|
|
224
154
|
---
|
|
@@ -229,29 +159,29 @@ npx a3m-router benchmark # Run accuracy test
|
|
|
229
159
|
User Query
|
|
230
160
|
│
|
|
231
161
|
▼
|
|
232
|
-
|
|
233
|
-
│
|
|
234
|
-
|
|
235
|
-
│
|
|
236
|
-
│ ┌──────────┐ ┌─────────┐
|
|
237
|
-
│ │Guardrails│→│ Cache │→│
|
|
238
|
-
│ │ 🔒
|
|
239
|
-
│ │Injection │ │ HitRate │ │12
|
|
240
|
-
│ └──────────┘ └─────────┘
|
|
241
|
-
│
|
|
242
|
-
│ ┌──────────┐ ┌─────────┐
|
|
243
|
-
│ │Memory │ │ Budget │ │Circuit
|
|
244
|
-
│ │🧠 EMA │ │ 💰 Hard │ │Breaker
|
|
245
|
-
│ │Persist │ │ Caps │ │3→60s Cool
|
|
246
|
-
│ └──────────┘ └─────────┘
|
|
247
|
-
│
|
|
248
|
-
|
|
249
|
-
│
|
|
250
|
-
▼
|
|
251
|
-
┌──────┐ ┌────────┐
|
|
252
|
-
│NVIDIA│ │ Groq │ │
|
|
253
|
-
│ 0.3 │ │
|
|
254
|
-
└──────┘ └────────┘
|
|
162
|
+
┌─────────────────────────────────────────────────────────┐
|
|
163
|
+
│ A3M Router Engine │
|
|
164
|
+
├─────────────────────────────────────────────────────────┤
|
|
165
|
+
│ │
|
|
166
|
+
│ ┌──────────┐ ┌─────────┐ ┌──────────┐ ┌─────────┐ │
|
|
167
|
+
│ │Guardrails│→│ Cache │→│ Router │→│ Ensemble│ │
|
|
168
|
+
│ │ 🔒 17x │ │ 💾 30% │ │ 🎯 MCTS │ │ ⚡ Par │ │
|
|
169
|
+
│ │Injection │ │ HitRate │ │12 Sig. │ │ +Score │ │
|
|
170
|
+
│ └──────────┘ └─────────┘ └──────────┘ └─────────┘ │
|
|
171
|
+
│ │
|
|
172
|
+
│ ┌──────────┐ ┌─────────┐ ┌──────────┐ ┌─────────┐ │
|
|
173
|
+
│ │Memory │ │ Budget │ │Circuit │ │Retry │ │
|
|
174
|
+
│ │🧠 EMA │ │ 💰 Hard │ │Breaker 🔄│ │⚡ Exp │ │
|
|
175
|
+
│ │Persist │ │ Caps │ │3→60s Cool│ │Backoff │ │
|
|
176
|
+
│ └──────────┘ └─────────┘ └──────────┘ └─────────┘ │
|
|
177
|
+
│ │
|
|
178
|
+
└─────────────────────────────────────────────────────────┘
|
|
179
|
+
│ │ │ │
|
|
180
|
+
▼ ▼ ▼ ▼
|
|
181
|
+
┌──────┐ ┌────────┐ ┌────────┐ ┌────────┐
|
|
182
|
+
│NVIDIA│ │ Groq │ │OpenAI │ │Anthropic│
|
|
183
|
+
│ 0.3 │ │0.3-0.7 │ │0.2-0.7 │ │ 0.3 │
|
|
184
|
+
└──────┘ └────────┘ └────────┘ └────────┘
|
|
255
185
|
```
|
|
256
186
|
|
|
257
187
|
---
|
|
@@ -260,113 +190,120 @@ User Query
|
|
|
260
190
|
|
|
261
191
|
| Metric | Value |
|
|
262
192
|
|:-------|:------|
|
|
263
|
-
| Weekly Downloads | **4,766**
|
|
193
|
+
| Weekly Downloads | **4,766** (top 0.2% of npm) |
|
|
264
194
|
| Providers | **47+** — NVIDIA, Groq, OpenAI, Anthropic, DeepSeek, + |
|
|
265
195
|
| Routing Accuracy | **99.5%** ±1 difficulty tier |
|
|
266
196
|
| Cost Savings | **62%** vs all-premium routing |
|
|
267
|
-
| Cache Hit Rate | **30%+**
|
|
268
|
-
| Size | **19.5 KB** —
|
|
269
|
-
| Startup | **<100ms** —
|
|
197
|
+
| Cache Hit Rate | **30%+** semantic deduplication |
|
|
198
|
+
| Package Size | **19.5 KB** — zero ML dependencies |
|
|
199
|
+
| Startup Time | **<100ms** — no GPU, no model loading |
|
|
270
200
|
|
|
271
201
|
---
|
|
272
202
|
|
|
273
203
|
## 🆚 Competitor Comparison
|
|
274
204
|
|
|
275
|
-
| Feature | A3M
|
|
205
|
+
| Feature | A3M | litellm | one-api | LibreChat | gpt-researcher |
|
|
276
206
|
|:---|:---:|:---:|:---:|:---:|:---:|
|
|
277
|
-
| **Parallel ensemble** |
|
|
278
|
-
| **Confidence scoring** |
|
|
279
|
-
| **Sequential fallback** | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
207
|
+
| **Parallel ensemble** | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
208
|
+
| **Confidence scoring** | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
280
209
|
| **Cost tracking** | ✅ | ❌ | ✅ | ❌ | ❌ |
|
|
281
|
-
| **Memory persistence** |
|
|
282
|
-
| **Query-type presets** |
|
|
210
|
+
| **Memory persistence** | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
211
|
+
| **Query-type presets** | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
212
|
+
| **Sequential fallback** | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
283
213
|
| **Self-hosted** | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
284
|
-
| **OpenAI proxy** | ✅ | ❌ | ✅ | ❌ | ❌ |
|
|
285
214
|
| **Python SDK** | ✅ | ✅ | ❌ | ❌ | ✅ |
|
|
286
|
-
| **TypeScript SDK** | ✅ | ❌ | ❌ | ✅ | ❌ |
|
|
287
215
|
| **Stars** | ⭐ | 48K | 34K | 20K | 20K |
|
|
288
216
|
|
|
289
|
-
**
|
|
217
|
+
**Unique:** Parallel multi-LLM execution with result merging doesn't exist anywhere else. Everyone does `try A → fail → try B`.
|
|
290
218
|
|
|
291
219
|
---
|
|
292
220
|
|
|
293
|
-
## 📈
|
|
221
|
+
## 📈 Smart Routing
|
|
294
222
|
|
|
295
|
-
|
|
223
|
+
Route every query to the cheapest capable model with **99.5% ±1 tier accuracy**:
|
|
296
224
|
|
|
297
225
|
```
|
|
298
|
-
Complexity 0.00
|
|
299
|
-
├── free
|
|
300
|
-
│ taste-1
|
|
301
|
-
│ $0
|
|
226
|
+
Complexity 0.00 ───────── 0.19 ────────── 0.44 ────────── 1.00
|
|
227
|
+
├── free ────|── cheap ───────|── mid ────────| premium ─┤
|
|
228
|
+
│ taste-1 │ llama-3.3-70b │ gpt-4o-mini │ gpt-4o │
|
|
229
|
+
│ $0 │ $0.20/M │ $0.60/M │ $2.50/M │
|
|
302
230
|
```
|
|
303
231
|
|
|
304
|
-
| Query |
|
|
232
|
+
| Query | A3M Cost | GPT-4o Cost | Savings |
|
|
305
233
|
|:---|:---:|:---:|:---:|
|
|
306
|
-
| "What is 2+2?" | $0 (free) | $2.50 | **100%** |
|
|
234
|
+
| "What is 2+2?" | $0 (free tier) | $2.50 | **100%** |
|
|
307
235
|
| "Write Python sort" | $0.14 | $2.50 | **94%** |
|
|
308
236
|
| "Design oncology trial" | $2.50 | $2.50 | **0%** |
|
|
309
237
|
| **100K queries/month** | **$124** | **$341** | **64%** |
|
|
310
238
|
|
|
239
|
+
### Three Routing Modes
|
|
240
|
+
|
|
241
|
+
| Mode | Latency | Use Case |
|
|
242
|
+
|:---|:---:|:---|
|
|
243
|
+
| **Heuristic** (12 signals) | <1ms | Single-query routing to cheapest capable model |
|
|
244
|
+
| **MCTS** (UCB1 search) | ~2s | Multi-agent workflow optimization |
|
|
245
|
+
| **Ensemble** (parallel + scoring) | = slowest provider | Best-answer guarantee with transparency |
|
|
246
|
+
|
|
311
247
|
---
|
|
312
248
|
|
|
313
|
-
## 🔬 Research-Backed
|
|
249
|
+
## 🔬 Research-Backed
|
|
250
|
+
|
|
251
|
+
Built on findings from 30+ 2024‑2025 arXiv papers:
|
|
252
|
+
|
|
253
|
+
| Paper | Used In |
|
|
254
|
+
|:------|:--------|
|
|
255
|
+
| [RouteLLM](https://arxiv.org/abs/2404.06035) — Cost-quality routing | Heuristic signal classification |
|
|
256
|
+
| [RadixAttention (SGLang)](https://arxiv.org/abs/2412.15115) — Prefix caching | Cache module |
|
|
257
|
+
| [Medusa](https://arxiv.org/abs/2401.10774) — Speculative decoding | Multi-token prediction |
|
|
258
|
+
| [A-Mem](https://arxiv.org/abs/2502.12110) — Episodic memory | MemoryTree with EMA |
|
|
259
|
+
| [MCTS / UCB1](https://arxiv.org/abs/2411.20000) — Multi-agent search | Provider selection algorithm |
|
|
260
|
+
| [AgentOrchestra](https://arxiv.org/abs/2506.12508) — Hierarchical orchestration | Multi-agent workflows |
|
|
314
261
|
|
|
315
|
-
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## When NOT to Use
|
|
316
265
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
| [Speculative Decoding (Medusa)](https://arxiv.org/abs/2401.10774) | 2024 | Multi-token prediction — 2-3x speedup |
|
|
322
|
-
| [A-Mem](https://arxiv.org/abs/2502.12110) | 2025 | Episodic memory with EMA updates |
|
|
323
|
-
| [MCTS](https://arxiv.org/abs/2411.20000) | 2024 | UCB1-based multi-agent optimization |
|
|
324
|
-
| [FlashAttention](https://arxiv.org/abs/2407.07403) | 2024 | Memory-efficient attention patterns |
|
|
266
|
+
- **Single provider** — no routing benefit
|
|
267
|
+
- **>80% expert queries** — just use GPT‑4o directly
|
|
268
|
+
- **250+ providers needed** — use Portkey
|
|
269
|
+
- **Enterprise SLAs / managed hosting** — this is self-hosted
|
|
325
270
|
|
|
326
271
|
---
|
|
327
272
|
|
|
328
|
-
##
|
|
273
|
+
## Package Exports
|
|
329
274
|
|
|
330
275
|
```typescript
|
|
331
|
-
// Core
|
|
332
|
-
import { routeQuery, routeBatch, extractQueryFeatures
|
|
333
|
-
import { A3MRouter }
|
|
276
|
+
// Core routing
|
|
277
|
+
import { routeQuery, routeBatch, extractQueryFeatures } from 'adaptive-memory-multi-model-router';
|
|
278
|
+
import { A3MRouter } from 'adaptive-memory-multi-model-router/sdk';
|
|
334
279
|
|
|
335
|
-
// Ensemble (P0) —
|
|
336
|
-
import { executeEnsemble, mergeComplementary
|
|
280
|
+
// Ensemble (P0) — core differentiator
|
|
281
|
+
import { executeEnsemble, mergeComplementary } from 'adaptive-memory-multi-model-router/ensemble';
|
|
337
282
|
|
|
338
283
|
// Presets (P1)
|
|
339
|
-
import { createPresetRouter,
|
|
284
|
+
import { createPresetRouter, DEFAULT_PRESETS } from 'adaptive-memory-multi-model-router/presets';
|
|
340
285
|
|
|
341
286
|
// Cost (P2)
|
|
342
|
-
import { BudgetEnforcer, CostTracker
|
|
287
|
+
import { BudgetEnforcer, CostTracker } from 'adaptive-memory-multi-model-router/cost';
|
|
343
288
|
|
|
344
289
|
// Memory (P3)
|
|
345
|
-
import { EpisodicMemoryStore }
|
|
290
|
+
import { EpisodicMemoryStore } from 'adaptive-memory-multi-model-router/memory';
|
|
346
291
|
|
|
347
292
|
// Caching
|
|
348
|
-
import { SemanticCache, PrefixCache }
|
|
293
|
+
import { SemanticCache, PrefixCache } from 'adaptive-memory-multi-model-router/cache';
|
|
349
294
|
|
|
350
295
|
// Security
|
|
351
|
-
import { GuardrailEngine }
|
|
296
|
+
import { GuardrailEngine } from 'adaptive-memory-multi-model-router/security';
|
|
352
297
|
|
|
353
298
|
// Providers
|
|
354
299
|
import { registerProvider, getAvailableProviders } from 'adaptive-memory-multi-model-router/providers';
|
|
355
300
|
|
|
356
|
-
// Server
|
|
357
|
-
import { createProxyServer }
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
---
|
|
361
|
-
|
|
362
|
-
## 📋 When NOT to Use
|
|
301
|
+
// Server (OpenAI-compatible proxy)
|
|
302
|
+
import { createProxyServer } from 'adaptive-memory-multi-model-router/server';
|
|
363
303
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
- You need enterprise SLAs or managed hosting
|
|
368
|
-
|
|
369
|
-
For single-provider use cases, the native SDK is simpler.
|
|
304
|
+
// Orchestration
|
|
305
|
+
import { MCTSWorkflowOptimizer } from 'adaptive-memory-multi-model-router/orchestration';
|
|
306
|
+
```
|
|
370
307
|
|
|
371
308
|
---
|
|
372
309
|
|
|
@@ -386,15 +323,15 @@ For single-provider use cases, the native SDK is simpler.
|
|
|
386
323
|
|
|
387
324
|
- [npm package](https://www.npmjs.com/package/adaptive-memory-multi-model-router)
|
|
388
325
|
- [GitHub repo](https://github.com/Das-rebel/adaptive-memory-multi-model-router)
|
|
389
|
-
- [TMLPD Extension (PI Tools)](https://github.com/Das-rebel/adaptive-memory-multi-model-router/tree/main/tmlpd-pi-extension)
|
|
390
326
|
- [API Reference](docs/API.md)
|
|
391
327
|
- [Architecture](docs/ARCHITECTURAL-IMPROVEMENTS-2025.md)
|
|
328
|
+
- [Quick Start](docs/QUICK_START.md)
|
|
392
329
|
- [Discussions](https://github.com/Das-rebel/adaptive-memory-multi-model-router/discussions)
|
|
393
330
|
- [Contributing](CONTRIBUTING.md)
|
|
394
331
|
|
|
395
|
-
MIT License. No vendor lock-in. No account required.
|
|
332
|
+
MIT License. No vendor lock-in. No account required.
|
|
396
333
|
|
|
397
|
-
**
|
|
334
|
+
**If this helps you, star the repo** ⭐ — it helps more developers discover parallel multi-LLM execution.
|
|
398
335
|
|
|
399
336
|
---
|
|
400
337
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adaptive-memory-multi-model-router",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.2",
|
|
4
4
|
"shortName": "A3M Router",
|
|
5
5
|
"displayName": "A3M Router - Adaptive Memory Multi-Model Router",
|
|
6
|
-
"description": "Parallel Multi-LLM Execution with Intelligent Merge.
|
|
6
|
+
"description": "Parallel Multi-LLM Execution with Intelligent Merge. 47+ providers, parallel ensemble (nobody else does this), confidence scoring, query-type presets, persistent memory. RouteLLM-style routing with 99.5% accuracy. 62% cost savings. 3 routing modes: heuristic (<1ms), MCTS, ensemble. Zero ML, 19.5KB. MIT.",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"bin": {
|
|
9
9
|
"a3m-router": "dist/cli.js",
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
# TMLPD
|
|
1
|
+
# TMLPD — Parallel Multi-LLM Execution Module
|
|
2
2
|
|
|
3
3
|
> **Part of the [A3M Router](https://github.com/Das-rebel/adaptive-memory-multi-model-router) ecosystem.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Parallel multi-LLM execution with confidence-weighted ensemble merging. Runs providers simultaneously, scores each result, and returns the best answer with transparent reasoning.
|
|
6
6
|
|
|
7
7
|
## What This Is
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- **Execute prompts across multiple LLMs in parallel** and pick the best result
|
|
12
|
-
- **Smart-route** single queries to the optimal provider based on task type
|
|
13
|
-
- **Track costs** across all providers and sessions
|
|
14
|
-
- **Persist agent memory** across CLI sessions
|
|
9
|
+
A TypeScript library for executing prompts across multiple LLM providers **in parallel** — not sequentially. Every provider runs at the same time, results are scored on quality, and the best answer is selected with a clear explanation of why it won.
|
|
15
10
|
|
|
16
11
|
## Core Features
|
|
17
12
|
|
|
18
|
-
|
|
|
19
|
-
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
| Cost tracking | Per-query cost display
|
|
24
|
-
| Persistent memory | Cross-session `.memory.json` with keyword indexing |
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
| Feature | Description |
|
|
14
|
+
|:--------|:------------|
|
|
15
|
+
| **Parallel execution** | Run N providers simultaneously, not sequentially |
|
|
16
|
+
| **Ensemble scoring** | Score results on specificity, structure, and relevance |
|
|
17
|
+
| **Query-type presets** | Auto-configure provider + temp per task type |
|
|
18
|
+
| **Cost tracking** | Per-query cost display with provider breakdown |
|
|
19
|
+
| **Persistent memory** | Cross-session `.memory.json` with keyword indexing |
|
|
20
|
+
| **Prefix caching** | RadixAttention-style caching for repeated prefixes |
|
|
21
|
+
| **Speculative decoding** | Medusa/EAGLE-style multi-token prediction |
|
|
22
|
+
| **Token compression** | ISON encoding for ~40% token reduction |
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
npm install tmlpd-pi
|
|
30
|
-
```
|
|
24
|
+
## Usage
|
|
31
25
|
|
|
32
26
|
```typescript
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
const tmlpd = createTMLPD({ cache: { ttl_seconds: 3600 } });
|
|
27
|
+
import { executeEnsemble, createPresetRouter, EpisodicMemoryStore } from "tmlpd-pi";
|
|
36
28
|
|
|
37
|
-
// Parallel
|
|
38
|
-
const result = await
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
prompt, systemPrompt, context,
|
|
29
|
+
// Parallel ensemble: run all providers simultaneously, pick best
|
|
30
|
+
const result = await executeEnsemble(
|
|
31
|
+
"Explain vector databases",
|
|
32
|
+
systemPrompt,
|
|
33
|
+
context,
|
|
43
34
|
{ nvidia: callNvidia, groq: callGroq }
|
|
44
35
|
);
|
|
36
|
+
console.log(`Winner: ${result.winner} (score: ${result.scores[result.winner]})`);
|
|
37
|
+
|
|
38
|
+
// Query-type presets: auto-configure per task
|
|
39
|
+
const router = createPresetRouter();
|
|
40
|
+
const preset = router.classify("Write a Python sort function"); // → 'code'
|
|
41
|
+
|
|
42
|
+
// Persistent memory
|
|
43
|
+
const memory = new EpisodicMemoryStore(1000, './memory.json');
|
|
44
|
+
const similar = memory.getSimilarTasks("Python async API", 5);
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
## Exports
|