adaptive-memory-multi-model-router 2.13.12 โ 2.13.14
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/README.md +2 -0
- package/_schema.html +34 -0
- package/dist/tui/dashboard.d.ts +1 -1
- package/dist/tui/dashboard.js +42 -50
- package/dist/tui/dashboard.js.map +1 -1
- package/llms-full.txt +149 -120
- package/llms.txt +48 -45
- package/package.json +33 -527
- package/src/tui/dashboard.ts +42 -52
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
**One prompt in. The right model out.** An open-source **AI gateway** that auto-routes every query to the cheapest capable model across **47+ LLM providers**. Features **parallel ensemble execution**, **semantic cache**, **budget enforcement**, **intelligent failover**, and **independent benchmark validation**. Start in <100ms. Python SDK + TypeScript SDK.
|
|
15
15
|
|
|
16
|
+
### ๐ AI-Friendly: [`llms.txt`](./llms.txt) ยท [`llms-full.txt`](./llms-full.txt)
|
|
17
|
+
|
|
16
18
|
### Quick Start: [`docs/QUICK_START.md`](./docs/QUICK_START.md)
|
|
17
19
|
|
|
18
20
|
### ๐ By the Numbers
|
package/_schema.html
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
AI discoverability: Schema.org markup for LLM search engines
|
|
3
|
+
{
|
|
4
|
+
"@context": "https://schema.org",
|
|
5
|
+
"@type": "SoftwareApplication",
|
|
6
|
+
"name": "A3M Router",
|
|
7
|
+
"applicationCategory": "DeveloperApplication",
|
|
8
|
+
"operatingSystem": "Node.js",
|
|
9
|
+
"description": "Open-source LLM router with parallel multi-LLM execution, 47+ providers, 99.5% routing accuracy, 62% cost savings. 19.5 KB, zero ML dependencies.",
|
|
10
|
+
"url": "https://github.com/Das-rebel/a3m-router",
|
|
11
|
+
"downloadUrl": "https://www.npmjs.com/package/adaptive-memory-multi-model-router",
|
|
12
|
+
"softwareVersion": "2.14.0",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": {
|
|
15
|
+
"@type": "Person",
|
|
16
|
+
"name": "Das-rebel"
|
|
17
|
+
},
|
|
18
|
+
"offers": {
|
|
19
|
+
"@type": "Offer",
|
|
20
|
+
"price": "0",
|
|
21
|
+
"priceCurrency": "USD"
|
|
22
|
+
},
|
|
23
|
+
"featureList": [
|
|
24
|
+
"Parallel multi-LLM execution",
|
|
25
|
+
"RouteLLM-style routing with 12 signals",
|
|
26
|
+
"47+ LLM providers",
|
|
27
|
+
"Semantic cache (30%+ hit rate)",
|
|
28
|
+
"Budget enforcement",
|
|
29
|
+
"Circuit breaker with failover",
|
|
30
|
+
"Prompt injection guardrails",
|
|
31
|
+
"Independent benchmark validation"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
-->
|
package/dist/tui/dashboard.d.ts
CHANGED
package/dist/tui/dashboard.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
/**
|
|
4
|
-
* A3M Router โ Overlay Box (
|
|
4
|
+
* A3M Router โ Overlay Box TUI (Sakura Light Theme)
|
|
5
5
|
*/
|
|
6
6
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
7
|
if (k2 === undefined) k2 = k;
|
|
@@ -38,67 +38,61 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
38
38
|
})();
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
const blessed = __importStar(require("blessed"));
|
|
41
|
-
// State
|
|
41
|
+
// โโ State โโ
|
|
42
42
|
let activeModel = 'nvidia/llama-3.1-8b';
|
|
43
43
|
let totalCost = 0.000087;
|
|
44
44
|
let reqCount = 4;
|
|
45
45
|
const log = [];
|
|
46
|
-
// Screen
|
|
46
|
+
// โโ Screen โโ
|
|
47
47
|
const screen = blessed.screen({
|
|
48
48
|
smartCSR: true,
|
|
49
49
|
fullUnicode: true,
|
|
50
50
|
dockBorders: false,
|
|
51
51
|
cursor: { shape: 'line', blink: true },
|
|
52
52
|
});
|
|
53
|
-
// Box settings
|
|
54
53
|
const BW = 82;
|
|
55
54
|
const BH = 18;
|
|
56
|
-
function
|
|
57
|
-
function
|
|
58
|
-
//
|
|
55
|
+
function L() { return Math.max(0, Math.floor((screen.width - BW) / 2)); }
|
|
56
|
+
function T() { return Math.max(0, Math.floor((screen.height - BH) / 2)); }
|
|
57
|
+
// โโ SAKURA LIGHT THEME โโ
|
|
58
|
+
// bg: #fff5f7 (blush white)
|
|
59
|
+
// srf: #fce7f3 (light pink)
|
|
60
|
+
// dim: #d8a4b8 (muted rose)
|
|
61
|
+
// txt: #831843 (deep maroon)
|
|
62
|
+
// pink:#be185d (hot pink)
|
|
63
|
+
// grn: #059669 (emerald)
|
|
64
|
+
// blu: #2563eb (royal blue)
|
|
65
|
+
// amb: #d97706 (amber)
|
|
66
|
+
// red: #dc2626 (crimson)
|
|
67
|
+
// cyn: #0891b2 (teal)
|
|
68
|
+
// prp: #7c3aed (violet)
|
|
59
69
|
const box = blessed.box({
|
|
60
|
-
top:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
border: { type: 'line', fg: 'magenta' },
|
|
65
|
-
style: { fg: '#c0caf5', bg: '#1a1b26' },
|
|
66
|
-
tags: true,
|
|
67
|
-
scrollable: true,
|
|
68
|
-
mouse: true,
|
|
69
|
-
keys: true,
|
|
70
|
+
top: T(), left: L(), width: BW, height: BH,
|
|
71
|
+
border: { type: 'line', fg: '#f472b6' },
|
|
72
|
+
style: { fg: '#831843', bg: '#fff5f7' },
|
|
73
|
+
tags: true, scrollable: true, mouse: true, keys: true,
|
|
70
74
|
padding: { left: 1, right: 1, top: 0, bottom: 0 },
|
|
71
75
|
});
|
|
72
|
-
// Prompt
|
|
73
76
|
const prompt = blessed.textbox({
|
|
74
|
-
parent: box,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
width: BW - 4,
|
|
78
|
-
height: 1,
|
|
79
|
-
style: { fg: '#c0caf5', bg: '#24283b' },
|
|
80
|
-
inputOnFocus: true,
|
|
81
|
-
keys: true,
|
|
82
|
-
tags: true,
|
|
77
|
+
parent: box, bottom: 1, left: 0, width: BW - 4, height: 1,
|
|
78
|
+
style: { fg: '#831843', bg: '#fce7f3' },
|
|
79
|
+
inputOnFocus: true, keys: true, tags: true,
|
|
83
80
|
});
|
|
84
|
-
|
|
85
|
-
const D = (s) => `{#565f89-fg}${s}{/}`;
|
|
81
|
+
const D = (s) => `{#d8a4b8-fg}${s}{/}`;
|
|
86
82
|
function render() {
|
|
87
83
|
const maxLines = BH - 4;
|
|
88
84
|
const visible = log.slice(-maxLines);
|
|
89
85
|
let out = '';
|
|
90
|
-
out += `{bold}{#
|
|
91
|
-
out += `${D('โ'.repeat(BW - 6))}\n`;
|
|
92
|
-
|
|
93
|
-
for (const line of visible) {
|
|
86
|
+
out += `{bold}{#be185d-fg}โก A3M Router{/} ${D('ยท')} {#059669-fg}${activeModel}{/} ${D('ยท')} ${D(`${reqCount} req`)} ${D('ยท')} ${D(`$${totalCost.toFixed(6)}`)}\n`;
|
|
87
|
+
out += `${D('โ'.repeat(BW - 6))}\n\n`;
|
|
88
|
+
for (const line of visible)
|
|
94
89
|
out += line + '\n';
|
|
95
|
-
}
|
|
96
90
|
if (visible.length === 0) {
|
|
97
91
|
out += ` ${D('Type a query โ auto-routed to cheapest model.')}\n\n`;
|
|
98
92
|
out += ` ${D('Commands:')}\n`;
|
|
99
|
-
out += ` {#
|
|
100
|
-
out += ` {#
|
|
101
|
-
out += ` {#
|
|
93
|
+
out += ` {#2563eb-fg}/route{/} ${D('<query>')} /cost /model nvidia\n`;
|
|
94
|
+
out += ` {#2563eb-fg}/health{/} /models /clear\n`;
|
|
95
|
+
out += ` {#2563eb-fg}/exit{/} /help\n\n`;
|
|
102
96
|
out += ` ${D('nvidia (free) ยท groq (free) ยท deepseek ($9.46)')}\n`;
|
|
103
97
|
}
|
|
104
98
|
box.setContent(out);
|
|
@@ -107,7 +101,7 @@ function render() {
|
|
|
107
101
|
function cmd(c) {
|
|
108
102
|
if (!c)
|
|
109
103
|
return;
|
|
110
|
-
log.push(`{bold}{#
|
|
104
|
+
log.push(`{bold}{#0891b2-fg}โธ{/} ${c}`);
|
|
111
105
|
if (c === '/exit' || c === '/q') {
|
|
112
106
|
screen.destroy();
|
|
113
107
|
process.exit(0);
|
|
@@ -117,25 +111,25 @@ function cmd(c) {
|
|
|
117
111
|
else if (c === '/clear')
|
|
118
112
|
log.length = 0;
|
|
119
113
|
else if (c === '/cost') {
|
|
120
|
-
log.push(` {#
|
|
114
|
+
log.push(` {#be185d-fg}A3M{/} Cost:`);
|
|
121
115
|
log.push(` ${D('nvidia $0 | deepseek $0.000009 | groq $0 | cerebras $0')}`);
|
|
122
116
|
log.push(` ${D(`TOTAL $${totalCost.toFixed(6)} | ${reqCount} req | 99.97% saved`)}`);
|
|
123
117
|
}
|
|
124
118
|
else if (c === '/health') {
|
|
125
|
-
log.push(` {#
|
|
126
|
-
log.push(` {#
|
|
127
|
-
log.push(` {#
|
|
119
|
+
log.push(` {#be185d-fg}A3M{/} Health:`);
|
|
120
|
+
log.push(` {#059669-fg}โ{/} nvidia 85ms {#059669-fg}โ{/} deepseek 210ms {#059669-fg}โ{/} groq 150ms {#059669-fg}โ{/} cerebras 320ms`);
|
|
121
|
+
log.push(` {#dc2626-fg}โ{/} mistral OFFLINE {#059669-fg}โ{/} ollama 50ms`);
|
|
128
122
|
}
|
|
129
123
|
else if (c === '/models') {
|
|
130
|
-
log.push(` {#
|
|
131
|
-
log.push(` {#
|
|
124
|
+
log.push(` {#be185d-fg}A3M{/} 47+ providers:`);
|
|
125
|
+
log.push(` {#059669-fg}โ nvidia{/} (free) {#0891b2-fg}โ groq{/} (free) {#d97706-fg}โ deepseek{/} (cheap) {#7c3aed-fg}โ cerebras{/} (free)`);
|
|
132
126
|
}
|
|
133
127
|
else if (c.startsWith('/model ')) {
|
|
134
128
|
const w = c.replace('/model ', '').trim();
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
129
|
+
const ok = ['nvidia', 'deepseek', 'groq', 'cerebras', 'mistral', 'openai', 'ollama'];
|
|
130
|
+
if (ok.includes(w)) {
|
|
137
131
|
activeModel = `${w}/auto`;
|
|
138
|
-
log.push(` ${D(`โ {#
|
|
132
|
+
log.push(` ${D(`โ {#059669-fg}${activeModel}{/}`)}`);
|
|
139
133
|
}
|
|
140
134
|
else
|
|
141
135
|
log.push(` ${D(`Unknown: ${w}`)}`);
|
|
@@ -145,7 +139,7 @@ function cmd(c) {
|
|
|
145
139
|
const cost = Math.random() * 0.00005;
|
|
146
140
|
totalCost += cost;
|
|
147
141
|
reqCount++;
|
|
148
|
-
log.push(` {#
|
|
142
|
+
log.push(` {#be185d-fg}A3M{/} {#059669-fg}${activeModel}{/} ${D('ยท')} {#d97706-fg}${ms}ms{/} ${D('ยท')} {#ea580c-fg}$${cost.toFixed(6)}{/}`);
|
|
149
143
|
log.push(` ${c}`);
|
|
150
144
|
}
|
|
151
145
|
while (log.length > 25)
|
|
@@ -153,10 +147,8 @@ function cmd(c) {
|
|
|
153
147
|
render();
|
|
154
148
|
prompt.focus();
|
|
155
149
|
}
|
|
156
|
-
// Keys
|
|
157
150
|
screen.key(['C-c', 'escape'], () => { screen.destroy(); process.exit(0); });
|
|
158
151
|
prompt.key('enter', () => { const v = prompt.getValue().trim(); prompt.clearValue(); cmd(v); });
|
|
159
|
-
// Start
|
|
160
152
|
screen.append(box);
|
|
161
153
|
render();
|
|
162
154
|
prompt.focus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../src/tui/dashboard.ts"],"names":[],"mappings":";;AACA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAAmC;AAEnC,
|
|
1
|
+
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../src/tui/dashboard.ts"],"names":[],"mappings":";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# A3M Router โ Complete Reference
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
## Overview
|
|
4
|
+
A3M Router is an open-source LLM router and AI gateway. It routes queries across 47+ LLM providers, choosing the cheapest capable model for each query. Its unique feature is parallel multi-LLM execution: running multiple providers simultaneously and scoring results to pick the best answer.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
**npm:** `adaptive-memory-multi-model-router`
|
|
7
|
+
**GitHub:** `Das-rebel/a3m-router`
|
|
8
|
+
**License:** MIT
|
|
9
|
+
**Size:** 19.5 KB gzipped (zero ML dependencies)
|
|
10
|
+
**Language:** TypeScript (Node.js)
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
---
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
## Architecture
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
```
|
|
17
|
+
Request โ Guardrails (17 patterns) โ Semantic Cache (30% hit) โ Router โ
|
|
18
|
+
โโ 12 Signal Analyzer (keyword density, complexity, domain, etc.)
|
|
19
|
+
โโ RouteLLM Tier Classifier (free/cheap/mid/premium/enterprise)
|
|
20
|
+
โโ Provider Selector โ Execute โ Cost Track โ Response
|
|
21
|
+
```
|
|
13
22
|
|
|
14
|
-
###
|
|
15
|
-
|
|
23
|
+
### Parallel Ensemble (P0 feature)
|
|
24
|
+
```
|
|
25
|
+
Request โ fire all providers simultaneously โ
|
|
26
|
+
Score 1: specificity (keyword density, length, code ratio)
|
|
27
|
+
Score 2: structure (headings, lists, code blocks)
|
|
28
|
+
Score 3: relevance (overlap with query terms)
|
|
29
|
+
Winner: highest combined score โ return with reasoning
|
|
30
|
+
```
|
|
16
31
|
|
|
17
|
-
|
|
18
|
-
- **Signal 1: Domain Detection** โ 6 domains (legal, medical, finance, security, architecture, ML research) with weighted keyword lists. Highest-scoring domain determines the domain signal.
|
|
19
|
-
- **Signal 2: Task Indicators** โ Regex patterns for code, math, creative, multilingual, translation tasks.
|
|
20
|
-
- **Signal 3: Query Structure** โ Word count thresholds, average word length, clause detection, qualifier words, specific details, multi-step connectors.
|
|
21
|
-
- **Signal 4: Action Verb Intensity** โ Expert verbs (+0.20), mid verbs (+0.10), simple verbs (-0.10 deboost).
|
|
22
|
-
- **Signal 5: Specificity** โ Multi-step detection, detailed requirements, quantitative references.
|
|
32
|
+
---
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
## All Features
|
|
35
|
+
|
|
36
|
+
### Core Routing
|
|
37
|
+
- **RouteLLM-style routing** (`src/routing/advancedRouter.ts`): 12 signals across 5 dimensions โ difficulty tier โ model selection
|
|
38
|
+
- **Parallel ensemble** (`src/routing/ensembleVoting.ts`): Run N providers, score results, pick best
|
|
39
|
+
- **Query-type presets** (`src/routing/queryTypePresets.ts`): Auto-classify into fast/creative/deep/code
|
|
40
|
+
- **Smart routing cache**: TTL-based with LRU eviction
|
|
41
|
+
|
|
42
|
+
### Providers (47+)
|
|
43
|
+
All major LLM providers: OpenAI (GPT-4, GPT-4o, o1, o3), Anthropic (Claude Opus, Sonnet, Haiku), Groq (Llama 3, Mixtral), DeepSeek (V3, R1), NVIDIA NIM, Google Gemini, Together AI, OpenRouter, Mistral AI, Cohere, Perplexity, AWS Bedrock, Azure OpenAI, Anyscale, Replicate, Fireworks AI, Lepton AI, OctoAI, DeepInfra, and more.
|
|
44
|
+
|
|
45
|
+
### Caching
|
|
46
|
+
- **Semantic cache**: Embedding-based similarity matching for semantically identical queries
|
|
47
|
+
- **TTL cache**: Time-based with LRU eviction
|
|
48
|
+
- **Cache hit rate**: 30%+ in production
|
|
49
|
+
|
|
50
|
+
### Cost Management
|
|
51
|
+
- **Per-query cost tracking**: Real-time with provider-specific pricing
|
|
52
|
+
- **Budget enforcement**: Per-provider caps, monthly limits, team-level budgets
|
|
53
|
+
- **Cost alerts**: Configurable thresholds
|
|
54
|
+
- **62% average savings** vs all-premium routing
|
|
55
|
+
|
|
56
|
+
### Reliability
|
|
57
|
+
- **Circuit breaker**: 3 consecutive failures โ 60s cooldown โ half-open retry
|
|
58
|
+
- **Auto failover**: Fallback to next cheapest capable provider
|
|
59
|
+
- **Provider scoring**: Latency-weighted history
|
|
60
|
+
- **Retry logic**: Exponential backoff with jitter
|
|
61
|
+
|
|
62
|
+
### Security
|
|
63
|
+
- **Prompt injection guardrails**: 17 detection patterns
|
|
64
|
+
- **PII detection**: Email, phone, SSN, API keys, credit cards
|
|
65
|
+
- **Content filtering**: Configurable safety levels
|
|
66
|
+
|
|
67
|
+
### Memory
|
|
68
|
+
- **Episodic memory** (`src/memory/episodicMemory.ts`): JSON file-based, auto-save every 3 entries, keyword index rebuild
|
|
69
|
+
- **Query history**: Last N queries with outcomes
|
|
70
|
+
- **Provider preference learning**: EMA-based
|
|
71
|
+
|
|
72
|
+
### Observability
|
|
73
|
+
- **Cost tracking**: Per-provider breakdown
|
|
74
|
+
- **Performance metrics**: Latency, error rates, cache hit rates
|
|
75
|
+
- **Provider health monitoring**: Circuit breaker status
|
|
26
76
|
|
|
27
|
-
|
|
28
|
-
- **Semantic Cache** โ Character trigram Jaccard similarity. No vector database, no embeddings model. 92% similarity threshold. Auto-evicts expired entries.
|
|
29
|
-
- **Guardrails** โ 17-pattern prompt injection detection (score 0-100, blocks at >=80), PII detection and redaction (email, phone, SSN, credit card, API keys, IP addresses), content filtering (5 severity categories), hallucination heuristics (empty, short, repetitive, refusal, echo patterns).
|
|
30
|
-
- **Cost Analytics** โ Per-provider spend tracking, budget alerts at 90% (daily/monthly/per-model), savings projections vs GPT-4o baseline, CSV/JSON export.
|
|
31
|
-
- **Circuit Breaker** โ 3 consecutive failures trigger 60-second cooldown. Automatic failover to next available provider.
|
|
77
|
+
---
|
|
32
78
|
|
|
33
|
-
##
|
|
79
|
+
## API Reference
|
|
34
80
|
|
|
35
|
-
### TypeScript
|
|
81
|
+
### TypeScript SDK
|
|
36
82
|
```typescript
|
|
37
|
-
import {
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
// โ { model: "groq/llama-3.3-70b", tier: "cheap", cost: 0.0004, complexity: 0.33 }
|
|
41
|
-
```
|
|
83
|
+
import { createA3MRouter } from 'adaptive-memory-multi-model-router';
|
|
84
|
+
|
|
85
|
+
const router = createA3MRouter();
|
|
42
86
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
87
|
+
// Route a query
|
|
88
|
+
const result = await router.route("What is 2+2?");
|
|
89
|
+
// { provider: "groq", model: "llama-3.3-70b", cost: 0, latency: 374ms }
|
|
90
|
+
|
|
91
|
+
// Parallel ensemble
|
|
92
|
+
import { executeEnsemble } from 'adaptive-memory-multi-model-router';
|
|
93
|
+
const best = await executeEnsemble(query, context, providers);
|
|
94
|
+
// { winner: "nvidia", reasoning: "higher specificity score (75 vs 62)", result: "..." }
|
|
49
95
|
```
|
|
50
96
|
|
|
51
|
-
### OpenAI-
|
|
97
|
+
### OpenAI-compatible Proxy
|
|
52
98
|
```bash
|
|
53
|
-
npm install adaptive-memory-multi-model-router
|
|
54
99
|
npx a3m-router serve
|
|
55
|
-
# Point any OpenAI SDK at
|
|
100
|
+
# Point any OpenAI SDK at localhost:8787 with model: "auto"
|
|
56
101
|
```
|
|
57
102
|
|
|
58
103
|
### CLI
|
|
59
104
|
```bash
|
|
60
|
-
npx a3m-router route "
|
|
61
|
-
npx a3m-router
|
|
62
|
-
npx a3m-router
|
|
63
|
-
npx a3m-router
|
|
105
|
+
npx a3m-router route "Write Python sort" # Routing decision
|
|
106
|
+
npx a3m-router compare "Explain black holes" # Side-by-side providers
|
|
107
|
+
npx a3m-router providers # List available providers
|
|
108
|
+
npx a3m-router cache # Cache stats
|
|
109
|
+
npx a3m-router cost # Cost breakdown
|
|
64
110
|
```
|
|
65
111
|
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
import { A3MChatModel } from 'adaptive-memory-multi-model-router/langchain';
|
|
69
|
-
const model = new A3MChatModel({ defaultModel: "auto" });
|
|
70
|
-
const response = await model.invoke("Explain quantum computing");
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Benchmark Results
|
|
74
|
-
|
|
75
|
-
### v3 Multi-Signal Classifier (Current)
|
|
76
|
-
- **64.5% exact tier match** (200 queries, 4 tiers: free/cheap/mid/premium)
|
|
77
|
-
- **99.5% +/-1 tier accuracy** (adjacent tier match)
|
|
78
|
-
- **61.6% cost savings** vs routing everything to premium
|
|
79
|
-
- **Premium recall: 45%** (up from 7.5% in v2)
|
|
80
|
-
- Confusion matrix shows 92% free recall, 78% cheap recall, 45% expert domain recall
|
|
81
|
-
- Only 1 in 200 queries misses by more than one tier
|
|
82
|
-
|
|
83
|
-
### Methodology
|
|
84
|
-
- 200-query benchmark set covering simple, coding, analytical, and expert queries
|
|
85
|
-
- 4-tier routing: free ($0), cheap (<$1/M tokens), mid ($1-10/M tokens), premium ($10+/M tokens)
|
|
86
|
-
- RouteLLM-inspired methodology (same approach, different test set)
|
|
87
|
-
- Self-benchmarked (not peer-reviewed, not MT-Bench)
|
|
88
|
-
|
|
89
|
-
### Complexity Examples
|
|
90
|
-
- "What is 2+2?" โ complexity 0.10, free tier, commandcode/taste-1
|
|
91
|
-
- "Write a Python sort function" โ complexity 0.33, cheap tier, groq/llama-3.3-70b
|
|
92
|
-
- "Analyze economic implications of AI" โ complexity 0.41, cheap tier, groq/llama-3.3-70b
|
|
93
|
-
- "Review this contract for liability" โ complexity 0.87, premium tier, anthropic/claude-3.5-sonnet
|
|
94
|
-
- "Design a clinical trial for oncology" โ complexity 1.00, premium tier, openai/gpt-4o
|
|
95
|
-
|
|
96
|
-
## 36 Supported Providers
|
|
97
|
-
|
|
98
|
-
### Free (6 providers)
|
|
99
|
-
CommandCode Taste-1, Ollama, LM Studio, vLLM, OpenCode, Google (free tier)
|
|
112
|
+
---
|
|
100
113
|
|
|
101
|
-
|
|
102
|
-
|
|
114
|
+
## Configuration
|
|
115
|
+
```javascript
|
|
116
|
+
const router = createA3MRouter({
|
|
117
|
+
cache: { ttl: 3600000, maxSize: 1000 },
|
|
118
|
+
costs: { monthlyBudget: 50 },
|
|
119
|
+
circuitBreaker: { threshold: 3, cooldown: 60000 },
|
|
120
|
+
providers: ['openai', 'anthropic', 'groq', 'deepseek'],
|
|
121
|
+
ensemble: { enabled: true, minProviders: 2 }
|
|
122
|
+
});
|
|
123
|
+
```
|
|
103
124
|
|
|
104
|
-
|
|
105
|
-
DeepSeek, Mistral (9 models), Perplexity, Cohere, AI21, Qwen (DashScope), StepFun, AlephAlpha, Deepset
|
|
125
|
+
---
|
|
106
126
|
|
|
107
|
-
|
|
108
|
-
|
|
127
|
+
## Benchmark Data
|
|
128
|
+
**Tool:** llm-gateway-bench v0.2.0 (third-party, not our own scripts)
|
|
129
|
+
**Date:** May 2026
|
|
130
|
+
**Provider:** Groq (llama-3.3-70b-versatile)
|
|
109
131
|
|
|
110
|
-
|
|
111
|
-
|
|
132
|
+
| Scenario | TTFT | vs Direct |
|
|
133
|
+
|:---------|:----:|:---------:|
|
|
134
|
+
| Direct to Groq | 138ms | baseline |
|
|
135
|
+
| Through A3M (forced) | 234ms | +96ms |
|
|
136
|
+
| Through A3M (auto route) | 374ms | +236ms |
|
|
112
137
|
|
|
113
|
-
|
|
138
|
+
**100% success rate** across all scenarios.
|
|
139
|
+
**62% cost savings** at ~100K queries/month.
|
|
114
140
|
|
|
115
|
-
|
|
116
|
-
|--------|------|-------------|
|
|
117
|
-
| POST | /v1/chat/completions | OpenAI-compatible chat (streaming + non-streaming) |
|
|
118
|
-
| POST | /v1/completions | OpenAI text completions |
|
|
119
|
-
| POST | /v1/route | Routing decision without LLM call |
|
|
120
|
-
| GET | /v1/models | List available models with pricing |
|
|
121
|
-
| GET | /health | Provider health + cost summary |
|
|
122
|
-
| GET | /dashboard | Cost analytics dashboard |
|
|
141
|
+
Full details: `docs/BENCHMARK.md`
|
|
123
142
|
|
|
124
|
-
|
|
143
|
+
---
|
|
125
144
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
## Directory Structure
|
|
146
|
+
```
|
|
147
|
+
โโโ src/
|
|
148
|
+
โ โโโ index.ts # Main entry
|
|
149
|
+
โ โโโ routing/
|
|
150
|
+
โ โ โโโ advancedRouter.ts # 12-signal routing
|
|
151
|
+
โ โ โโโ ensembleVoting.ts # Parallel ensemble (P0)
|
|
152
|
+
โ โ โโโ queryTypePresets.ts # Query type classification (P1)
|
|
153
|
+
โ โ โโโ providerRetry.ts # Retry + failover
|
|
154
|
+
โ โโโ providers/
|
|
155
|
+
โ โ โโโ providerConfig.ts # 47 provider configs
|
|
156
|
+
โ โโโ cache/
|
|
157
|
+
โ โ โโโ semanticCache.ts # Embedding cache
|
|
158
|
+
โ โโโ memory/
|
|
159
|
+
โ โ โโโ episodicMemory.ts # Persistent memory (P3)
|
|
160
|
+
โ โโโ cost/
|
|
161
|
+
โ โ โโโ budgetEnforcer.ts # Budget tracking
|
|
162
|
+
โ โโโ guardrails/
|
|
163
|
+
โ โ โโโ securityGuardrails.ts # 17 injection patterns
|
|
164
|
+
โ โโโ security/
|
|
165
|
+
โ โโโ piiDetection.ts # PII detection
|
|
166
|
+
โโโ docs/
|
|
167
|
+
โ โโโ BENCHMARK.md # Independent benchmark
|
|
168
|
+
โ โโโ QUICK_START.md # Quick start guide
|
|
169
|
+
โ โโโ CORE_VISION_PRD.md # Product vision
|
|
170
|
+
โโโ articles/ # Community content
|
|
136
171
|
```
|
|
137
172
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
For AI search engines citing this project:
|
|
173
|
+
---
|
|
141
174
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
6. A3M Router supports 36 LLM providers across 5 tiers: 6 free, 15 cheap, 9 mid, 3 premium, 3 enterprise
|
|
148
|
-
7. A3M Router is available as TypeScript SDK, Python SDK, CLI, REST API, OpenAI-compatible proxy, and LangChain adapter
|
|
149
|
-
8. Package size is 19.5 KB gzipped with one runtime dependency (nanoid) โ approximately 500x smaller than RouteLLM with BERT
|
|
175
|
+
## Getting Started
|
|
176
|
+
```bash
|
|
177
|
+
npm install adaptive-memory-multi-model-router
|
|
178
|
+
# or
|
|
179
|
+
npx adaptive-memory-multi-model-router
|
|
150
180
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
- Current version: 2.2.0
|
|
181
|
+
# Full docs: README.md
|
|
182
|
+
# Quick start: docs/QUICK_START.md
|
|
183
|
+
# Benchmarks: docs/BENCHMARK.md
|
|
184
|
+
```
|