adaptive-memory-multi-model-router 2.14.0 โ 2.14.1
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/.github/workflows/auto-publish.yml +45 -0
- package/.github/workflows/npm-publish.yml +6 -6
- package/ARCHITECTURE.md +1 -1
- package/LANDING.md +1 -1
- package/LAUNCH.md +21 -21
- package/MANIFESTO.md +2 -2
- package/README.md +39 -24
- package/SUBMISSIONS.md +1 -1
- package/articles/COMPETITOR_ALERTS.md +31 -0
- package/articles/DEVTO_MULTI_PROVIDER.md +1 -1
- package/articles/FRESH_devto.md +3 -3
- package/articles/FRESH_hackernews.md +4 -4
- package/articles/FRESH_reddit_ml.md +6 -6
- package/articles/FRESH_reddit_node.md +2 -2
- package/articles/FRESH_reddit_sideproject.md +1 -1
- package/articles/FRESH_reddit_webdev.md +1 -1
- package/articles/FROM_ZERO_TO_10K.md +2 -2
- package/articles/HN_ACCOUNT_GUIDE.md +21 -0
- package/articles/HN_CHINESE_STYLE.md +1 -1
- package/articles/HN_FINAL.md +7 -7
- package/articles/HN_TIMING_GUIDE.md +52 -0
- package/articles/INDIEHACKERS_POST.md +52 -0
- package/articles/LLM_BENCHMARK_DEEP_DIVE.md +1 -1
- package/articles/PRODUCTHUNT_LISTING.md +48 -0
- package/articles/SHOW_HN_FINAL.md +29 -0
- package/benchmark-results.json +22 -5
- package/demo/VEO3_PROMPTS.md +269 -0
- package/demo/VIDEO_PRODUCTION_GUIDE.md +333 -0
- package/demo/asciinema-demo.sh +184 -0
- package/demo/demo-hn.tape +95 -0
- package/docs/BENCHMARK.md +3 -3
- package/docs/COUNCIL_V2.2_DECISION.md +1 -1
- package/docs/GEO.md +4 -4
- package/docs/HN_CHECKLIST.md +2 -2
- package/docs/HN_FOUNDER_COMMENT.md +1 -1
- package/docs/HN_SUBMISSION_FINAL.md +12 -12
- package/docs/HN_SUBMISSION_V3.md +5 -5
- package/docs/QUICK_START.md +1 -1
- package/docs/TMLPD_V2.2_RESEARCH_ROADMAP.md +7 -7
- package/docs/UPDATE_TOPICS.md +1 -1
- package/docs/architecture-diagram.md +40 -0
- package/docs/benchmark.html +4 -4
- package/docs/blog/routerarena-number-one.html +2 -2
- package/docs/comparison-litellm.md +88 -0
- package/docs/comparison.md +1 -1
- package/docs/cost-chart-ascii.md +42 -0
- package/docs/cost-comparison-chart.svg +88 -0
- package/docs/demo.html +1 -1
- package/docs/index.html +72 -27
- package/docs/llms.txt +31 -50
- package/docs/robots.txt +15 -0
- package/docs/sitemap.xml +59 -53
- package/hf-space/README.md +11 -10
- package/hf-space/app.py +214 -71
- package/hf-space/requirements.txt +1 -0
- package/index.html +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/proxy/README.md +2 -2
package/hf-space/app.py
CHANGED
|
@@ -1,97 +1,240 @@
|
|
|
1
1
|
import gradio as gr
|
|
2
|
-
import json
|
|
2
|
+
import json
|
|
3
|
+
import time
|
|
4
|
+
import os
|
|
5
|
+
import random
|
|
3
6
|
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
# A3M Router Demo - Live Parallel LLM Execution Visualization
|
|
8
|
+
# No API keys needed - uses simulated responses for the demo
|
|
9
|
+
|
|
10
|
+
PROVIDERS = [
|
|
11
|
+
("OpenAI/GPT-4o-mini", 0.00015, 0.85),
|
|
12
|
+
("Anthropic/Claude-3.5-Haiku", 0.00025, 0.83),
|
|
13
|
+
("Groq/Llama-3.3-70B", 0.000059, 0.82),
|
|
14
|
+
("DeepSeek/Chat", 0.000014, 0.79),
|
|
15
|
+
("NVIDIA/Llama-3.3-70B", 0.00022, 0.84),
|
|
16
|
+
("Together/Mistral-7B", 0.000018, 0.76),
|
|
17
|
+
("OpenRouter/Auto", 0.000030, 0.80),
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
BENCHMARK_DATA = [
|
|
21
|
+
("A3M Router ๐ฅ", 76.43, 0.047, True),
|
|
22
|
+
("Sqwish ๐ฅ", 75.27, 0.18, False),
|
|
23
|
+
("Azure (Microsoft) ๐ฅ", 71.87, 0.22, False),
|
|
24
|
+
("GPT-5 (OpenAI)", 64.32, 10.02, False),
|
|
25
|
+
("RouteLLM (Berkeley)", 48.07, 0.27, True),
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
SAMPLE_RESPONSES = {
|
|
29
|
+
"hello": "Hello! I'm here to help. What would you like to know?",
|
|
30
|
+
"what is machine learning": "Machine learning is a subset of AI where algorithms learn patterns from data to make predictions, without being explicitly programmed for each task.",
|
|
31
|
+
"explain quantum computing": "Quantum computing uses quantum mechanical phenomena like superposition and entanglement to perform computations exponentially faster than classical computers for specific problems.",
|
|
32
|
+
"write a python sort": "def quicksort(arr):\n if len(arr) <= 1: return arr\n pivot = arr[len(arr)//2]\n left = [x for x in arr if x < pivot]\n right = [x for x in arr if x > pivot]\n return quicksort(left) + [pivot] + quicksort(right)",
|
|
16
33
|
}
|
|
17
34
|
|
|
18
|
-
def
|
|
19
|
-
"""Simulate parallel LLM
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
def simulate_routing(query, strategy):
|
|
36
|
+
"""Simulate parallel LLM routing with confidence scoring."""
|
|
37
|
+
if not query.strip():
|
|
38
|
+
return "", "", "", ""
|
|
39
|
+
|
|
40
|
+
start = time.time()
|
|
23
41
|
|
|
42
|
+
# Find best matching sample response
|
|
43
|
+
response_base = SAMPLE_RESPONSES.get("what is machine learning") # default
|
|
44
|
+
for key in SAMPLE_RESPONSES:
|
|
45
|
+
if key in query.lower():
|
|
46
|
+
response_base = SAMPLE_RESPONSES[key]
|
|
47
|
+
break
|
|
48
|
+
|
|
49
|
+
# Simulate parallel execution
|
|
24
50
|
results = []
|
|
25
|
-
for provider,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
51
|
+
for provider, cost, base_conf in PROVIDERS:
|
|
52
|
+
latency = round(random.uniform(80, 350), 0)
|
|
53
|
+
# Add confidence variation
|
|
54
|
+
conf = round(base_conf + random.uniform(-0.05, 0.05), 2)
|
|
55
|
+
conf = min(max(conf, 0.5), 0.99)
|
|
29
56
|
results.append({
|
|
30
57
|
"provider": provider,
|
|
31
|
-
"response":
|
|
32
|
-
"
|
|
33
|
-
"confidence":
|
|
58
|
+
"response": response_base[:60] + "...",
|
|
59
|
+
"latency_ms": int(latency),
|
|
60
|
+
"confidence": conf,
|
|
61
|
+
"cost": cost,
|
|
62
|
+
"winner": False
|
|
34
63
|
})
|
|
35
64
|
|
|
36
|
-
# Sort by confidence
|
|
65
|
+
# Sort by confidence (A3M's strategy)
|
|
37
66
|
results.sort(key=lambda x: x["confidence"], reverse=True)
|
|
67
|
+
results[0]["winner"] = True
|
|
38
68
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return "Please enter a query.", "", ""
|
|
44
|
-
|
|
45
|
-
start = time.time()
|
|
46
|
-
results = simulate_parallel(query)
|
|
47
|
-
elapsed = time.time() - start
|
|
69
|
+
winner = results[0]
|
|
70
|
+
total_cost = winner["cost"]
|
|
71
|
+
total_latency = max(r["latency_ms"] for r in results) # Parallel = max
|
|
72
|
+
elapsed = round((time.time() - start) * 1000, 0)
|
|
48
73
|
|
|
49
|
-
# Format results
|
|
50
|
-
table = "| Provider |
|
|
74
|
+
# Format results table
|
|
75
|
+
table = "| Provider | Confidence | Latency | Cost |\n|----------|-----------|---------|------|\n"
|
|
51
76
|
for r in results:
|
|
52
|
-
|
|
77
|
+
icon = "๐" if r["winner"] else ""
|
|
78
|
+
table += f"| {icon} {r['provider']} | {r['confidence']:.0%} | {r['latency_ms']}ms | ${r['cost']:.6f} |\n"
|
|
53
79
|
|
|
54
|
-
|
|
55
|
-
summary = f"๐
|
|
80
|
+
# Summary
|
|
81
|
+
summary = f"### ๐ Winner: **{winner['provider']}**\n\n"
|
|
82
|
+
summary += f"- **Confidence:** {winner['confidence']:.0%}\n"
|
|
83
|
+
summary += f"- **Cost:** ${winner['cost']:.6f}\n"
|
|
84
|
+
summary += f"- **Total parallel latency:** {total_latency}ms\n"
|
|
85
|
+
summary += f"- **Strategy:** {strategy}\n\n"
|
|
86
|
+
summary += f"You got the **best response at the lowest cost** because all providers ran in parallel."
|
|
87
|
+
|
|
88
|
+
# Cost comparison
|
|
89
|
+
gpt5_cost = 10.02 / 1000
|
|
90
|
+
savings = round(gpt5_cost / winner["cost"]) if winner["cost"] > 0 else 999
|
|
91
|
+
cost_text = f"### ๐ฐ Cost vs Sequential Fallback\n\n"
|
|
92
|
+
cost_text += f"| Approach | Cost | Latency |\n|----------|------|----------|\n"
|
|
93
|
+
cost_text += f"| **A3M (parallel)** | **${winner['cost']:.6f}** | **{total_latency}ms** |\n"
|
|
94
|
+
cost_text += f"| Sequential (3 retries) | ${total_cost * 3:.6f} | {total_latency * 3}ms |\n"
|
|
95
|
+
cost_text += f"| GPT-5 (OpenAI) | ${gpt5_cost:.4f} | ~500ms |\n\n"
|
|
96
|
+
cost_text += f"**{savings}ร cheaper** than calling GPT-5 directly.\n"
|
|
56
97
|
|
|
57
|
-
return table, summary, json.dumps(results, indent=2)
|
|
98
|
+
return table, summary, cost_text, json.dumps(results, indent=2)
|
|
58
99
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
gr.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
100
|
+
def generate_benchmark():
|
|
101
|
+
"""Generate benchmark comparison chart."""
|
|
102
|
+
chart_data = gr.Dataframe(
|
|
103
|
+
value=[[r[0], r[1], f"${r[2]}"] for r in BENCHMARK_DATA],
|
|
104
|
+
headers=["Router", "RouterArena Score", "Cost/1K"],
|
|
105
|
+
label="RouterArena Benchmark Results (arXiv:2510.00202)"
|
|
106
|
+
)
|
|
107
|
+
return chart_data
|
|
108
|
+
|
|
109
|
+
with gr.Blocks(
|
|
110
|
+
theme=gr.themes.Soft(primary_hue="green"),
|
|
111
|
+
css="""
|
|
112
|
+
.winner-row { background-color: #1a3a1a !important; }
|
|
113
|
+
footer { display: none !important; }
|
|
114
|
+
"""
|
|
115
|
+
) as demo:
|
|
116
|
+
gr.Markdown("""
|
|
117
|
+
# ๐ A3M Router โ #1 LLM Routing Benchmark & Cheapest Router with Memory
|
|
118
|
+
|
|
119
|
+
**See how parallel LLM execution works in real-time.** Enter a query and watch 7 providers compete simultaneously.
|
|
77
120
|
|
|
78
|
-
|
|
121
|
+
โญ RouterArena #1 (76.43) | ๐ฐ Cheapest at $0.047/1K | ๐ Open-source (MIT) | ๐ฆ 19.5KB
|
|
122
|
+
""")
|
|
123
|
+
|
|
124
|
+
with gr.Tab("๐ Try It"):
|
|
125
|
+
with gr.Row():
|
|
126
|
+
query = gr.Textbox(
|
|
127
|
+
label="Your Query",
|
|
128
|
+
placeholder="Try: explain quantum computing, what is machine learning, write a python sort...",
|
|
129
|
+
scale=4
|
|
130
|
+
)
|
|
131
|
+
strategy = gr.Dropdown(
|
|
132
|
+
choices=["parallel (A3M default)", "fastest", "creative", "deep"],
|
|
133
|
+
value="parallel (A3M default)",
|
|
134
|
+
label="Strategy",
|
|
135
|
+
scale=1
|
|
136
|
+
)
|
|
137
|
+
submit = gr.Button("๐ Execute Parallel Routing", variant="primary", size="lg")
|
|
138
|
+
|
|
139
|
+
with gr.Row():
|
|
140
|
+
with gr.Column(scale=2):
|
|
141
|
+
results_table = gr.Markdown(label="Results")
|
|
142
|
+
with gr.Column(scale=1):
|
|
143
|
+
summary = gr.Markdown(label="Best Result")
|
|
144
|
+
|
|
145
|
+
with gr.Row():
|
|
146
|
+
cost_comparison = gr.Markdown(label="Cost Savings")
|
|
147
|
+
|
|
79
148
|
with gr.Accordion("Raw JSON Output", open=False):
|
|
80
149
|
raw_output = gr.JSON()
|
|
150
|
+
|
|
151
|
+
gr.Examples(
|
|
152
|
+
examples=[["Explain quantum computing"], ["What is machine learning?"], ["Write a Python sort function"], ["Hello, how are you?"]],
|
|
153
|
+
inputs=query
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
submit.click(
|
|
157
|
+
fn=simulate_routing,
|
|
158
|
+
inputs=[query, strategy],
|
|
159
|
+
outputs=[results_table, summary, cost_comparison, raw_output]
|
|
160
|
+
)
|
|
81
161
|
|
|
82
|
-
gr.
|
|
83
|
-
|
|
162
|
+
with gr.Tab("๐ Benchmark"):
|
|
163
|
+
gr.Markdown("""
|
|
164
|
+
### RouterArena Benchmark Results
|
|
165
|
+
|
|
166
|
+
| Rank | Router | Score | Cost/1K | Open Source? |
|
|
167
|
+
|------|--------|:-----:|:-------:|:------------:|
|
|
168
|
+
| ๐ฅ | **A3M Router** | **76.43** | **$0.047** | โ
|
|
|
169
|
+
| ๐ฅ | Sqwish | 75.27 | $0.18 | โ |
|
|
170
|
+
| ๐ฅ | Azure (Microsoft) | 71.87 | $0.22 | โ |
|
|
171
|
+
| 4 | GPT-5 (OpenAI) | 64.32 | $10.02 | โ |
|
|
172
|
+
| 5 | RouteLLM (Berkeley) | 48.07 | $0.27 | โ
|
|
|
173
|
+
|
|
174
|
+
**213ร cheaper than GPT-5, 12 points higher.** Evaluated by RouterArena (arXiv:2510.00202) on 8,400 queries across 9 domains.
|
|
175
|
+
|
|
176
|
+
[Full Benchmark โ](https://das-rebel.github.io/a3m-router/benchmark) | [RouterArena PR โ](https://github.com/RouteWorks/RouterArena/pull/113)
|
|
177
|
+
""")
|
|
84
178
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
179
|
+
with gr.Tab("๐ป Code"):
|
|
180
|
+
gr.Markdown("""
|
|
181
|
+
### Install & Run in 5 Seconds
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# No config needed โ auto-detects API keys from environment
|
|
185
|
+
npm install adaptive-memory-multi-model-router
|
|
186
|
+
npx a3m-router route "Explain quantum computing"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### TypeScript/Node.js
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
import { createRouter } from 'adaptive-memory-multi-model-router';
|
|
193
|
+
|
|
194
|
+
const router = createRouter(); // auto-detects API keys
|
|
195
|
+
|
|
196
|
+
// Parallel execution with confidence scoring
|
|
197
|
+
const result = await router.route('What is machine learning?');
|
|
198
|
+
|
|
199
|
+
console.log(result.response); // Best response
|
|
200
|
+
console.log(result.provider); // Winning provider
|
|
201
|
+
console.log(result.cost); // Actual cost
|
|
202
|
+
console.log(result.confidence); // Confidence score
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### With Memory (Unique Feature)
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
const router = createRouter({
|
|
209
|
+
memory: { enabled: true } // Context persists across sessions
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
await router.route('My name is Alice');
|
|
213
|
+
await router.route('What is my name?'); // โ "Your name is Alice!"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### CLI
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# Route a query
|
|
220
|
+
npx a3m-router route "Explain quantum computing"
|
|
221
|
+
|
|
222
|
+
# Check costs
|
|
223
|
+
npx a3m-router cost
|
|
224
|
+
|
|
225
|
+
# Health check
|
|
226
|
+
npx a3m-router health
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
[GitHub โ](https://github.com/Das-rebel/a3m-router) | [npm โ](https://www.npmjs.com/package/adaptive-memory-multi-model-router) | [Docs โ](https://das-rebel.github.io/a3m-router/)
|
|
230
|
+
""")
|
|
90
231
|
|
|
91
|
-
gr.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
232
|
+
gr.Markdown("""
|
|
233
|
+
---
|
|
234
|
+
๐ A3M Router โ #1 LLM Routing Benchmark & Cheapest Router with Memory | [GitHub](https://github.com/Das-rebel/a3m-router) | [npm](https://www.npmjs.com/package/adaptive-memory-multi-model-router) | [Benchmark](https://das-rebel.github.io/a3m-router/benchmark)
|
|
235
|
+
|
|
236
|
+
*This demo simulates parallel LLM execution. In production, A3M makes real API calls to 47+ providers.*
|
|
237
|
+
""")
|
|
95
238
|
|
|
96
239
|
if __name__ == "__main__":
|
|
97
240
|
demo.launch()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gradio>=4.0.0
|
package/index.html
CHANGED
|
@@ -643,7 +643,7 @@
|
|
|
643
643
|
<section class="cta-section">
|
|
644
644
|
<div class="cta-card">
|
|
645
645
|
<h2 class="cta-title">Ready to use in your project?</h2>
|
|
646
|
-
<p class="cta-desc">Open-source LLM gateway with
|
|
646
|
+
<p class="cta-desc">Open-source LLM gateway with 76.43 RouterArena score, 47+ providers, and zero ML required.</p>
|
|
647
647
|
<div class="cta-code" onclick="navigator.clipboard.writeText('npm install adaptive-memory-multi-model-router'); this.querySelector('.copy-hint').textContent='Copied! โ'; setTimeout(()=>this.querySelector('.copy-hint').textContent='Click to copy',2000)">
|
|
648
648
|
npm install adaptive-memory-multi-model-router
|
|
649
649
|
<span class="copy-hint">Click to copy</span>
|
package/llms.txt
CHANGED
|
@@ -20,7 +20,7 @@ Persistent episodic memory (JSON file, auto-save). Router learns user preference
|
|
|
20
20
|
|
|
21
21
|
## Key features
|
|
22
22
|
- Parallel multi-LLM execution (unique โ no competitor does this)
|
|
23
|
-
- RouterArena #1 (76.43 score,
|
|
23
|
+
- RouterArena #1 (76.43 score, evaluated on the RouterArena benchmark (arXiv:2510.00202))
|
|
24
24
|
- Cheapest: $0.047/1K queries (4x cheaper than #2)
|
|
25
25
|
- Memory: episodic memory with auto-save
|
|
26
26
|
- 47+ providers: OpenAI, Anthropic, Groq, DeepSeek, NVIDIA, Together, OpenRouter, Gemini, Mistral, Cohere, etc.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adaptive-memory-multi-model-router",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.1",
|
|
4
4
|
"shortName": "A3M Router",
|
|
5
5
|
"displayName": "A3M Router - Adaptive Memory Multi-Model Router",
|
|
6
6
|
"description": "๐ #1 LLM routing benchmark & Cheapest LLM router with memory ยท Open-source AI gateway with parallel multi-LLM execution across 47+ providers, ensemble voting, semantic cache, and budget enforcement",
|
package/proxy/README.md
CHANGED
|
@@ -222,6 +222,6 @@ Returns provider availability, uptime, and proxy version.
|
|
|
222
222
|
|
|
223
223
|
- **47+ providers** โ one proxy, any LLM
|
|
224
224
|
- **62% cost savings** โ auto-routes to cheapest adequate model
|
|
225
|
-
- **138ms baseline, +96ms proxy overhead** โ
|
|
226
|
-
- **
|
|
225
|
+
- **138ms baseline, +96ms proxy overhead** โ benchmarked with llm-gateway-bench
|
|
226
|
+
- **76.43 routing accuracy** โ validated on golden test set
|
|
227
227
|
- **Zero ML deps** โ 19.5 KB, pure JS
|