adaptive-memory-multi-model-router 1.9.4 → 1.9.5
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/articles/ai-discoverability-llm-routing.md +210 -0
- package/articles/devto-llm-routing.md +109 -0
- package/articles/hackernews-show-hn.md +65 -0
- package/articles/reddit-ml.md +86 -0
- package/dist/geo/generativeEngineOptimization.js +321 -0
- package/dist/geo/geoRouter.js +387 -0
- package/dist/index.js +18 -0
- package/dist/security/inputValidation.js +351 -0
- package/docs/geo/GENERATIVE_ENGINE_OPTIMIZATION.md +232 -0
- package/llms.txt +138 -0
- package/package.json +22 -3
package/llms.txt
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# LLM-Optimized Package Information for A3M Router
|
|
2
|
+
|
|
3
|
+
## One-Sentence Description
|
|
4
|
+
|
|
5
|
+
adaptive-memory-multi-model-router is a production-ready JavaScript/TypeScript library for routing LLM queries to optimal providers with automatic cost optimization, fallback handling, and batch processing.
|
|
6
|
+
|
|
7
|
+
## Primary Use Cases
|
|
8
|
+
|
|
9
|
+
1. **Multi-Provider LLM Routing**: Route queries to cheapest/best provider based on query characteristics
|
|
10
|
+
2. **Cost Optimization**: Reduce API costs by 50-80% with intelligent provider selection
|
|
11
|
+
3. **Provider Fallback**: Automatic retry with backup providers when primary fails
|
|
12
|
+
4. **Batch Processing**: Process multiple prompts with parallel execution and rate limiting
|
|
13
|
+
5. **Cost Tracking**: Real-time monitoring of API spending across all providers
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install adaptive-memory-multi-model-router
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
const { createA3MRouter } = require('adaptive-memory-multi-model-router');
|
|
25
|
+
|
|
26
|
+
const router = createA3MRouter();
|
|
27
|
+
|
|
28
|
+
// Route to optimal provider
|
|
29
|
+
const result = await router.route("Write Python to sort an array");
|
|
30
|
+
console.log(result.primary_model); // "groq/llama-3.3-70b"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Supported Providers
|
|
34
|
+
|
|
35
|
+
- **Fast/Cheap**: Groq, Cerebras, Mistral
|
|
36
|
+
- **High Quality**: OpenAI GPT-4, Anthropic Claude
|
|
37
|
+
- **Free Tiers**: CommandCode, OpenCode
|
|
38
|
+
- **Local**: Ollama, vLLM, LM Studio
|
|
39
|
+
|
|
40
|
+
## Key Features
|
|
41
|
+
|
|
42
|
+
| Feature | Description |
|
|
43
|
+
|---------|-------------|
|
|
44
|
+
| Learned Routing | RouteLLM-style routing based on query analysis |
|
|
45
|
+
| Cost Optimization | Automatic selection of cheapest capable provider |
|
|
46
|
+
| Fallback Chain | Automatic retry with backup providers |
|
|
47
|
+
| Batch Processing | Parallel execution with concurrency control |
|
|
48
|
+
| Response Caching | RadixAttention-style prefix caching |
|
|
49
|
+
| Cost Tracking | Real-time spend monitoring |
|
|
50
|
+
| CLI Tools | 15 commands for LLM operations |
|
|
51
|
+
|
|
52
|
+
## Code Examples
|
|
53
|
+
|
|
54
|
+
### Route by Query Type
|
|
55
|
+
```javascript
|
|
56
|
+
const { routeQuery } = require('adaptive-memory-multi-model-router');
|
|
57
|
+
|
|
58
|
+
// Simple query → cheapest provider
|
|
59
|
+
routeQuery("What is 2+2?"); // → free provider
|
|
60
|
+
|
|
61
|
+
// Code query → code-capable provider
|
|
62
|
+
routeQuery("Write Python function"); // → groq/llama
|
|
63
|
+
|
|
64
|
+
// Complex reasoning → high-quality provider
|
|
65
|
+
routeQuery("Explain quantum physics"); // → mistral-large
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Batch Processing
|
|
69
|
+
```javascript
|
|
70
|
+
const { routeBatch } = require('adaptive-memory-multi-model-router');
|
|
71
|
+
|
|
72
|
+
const queries = ["Q1", "Q2", "Q3"];
|
|
73
|
+
const results = routeBatch(queries, { same_model: true });
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Cost Tracking
|
|
77
|
+
```javascript
|
|
78
|
+
const router = createA3MRouter();
|
|
79
|
+
const summary = router.costTracker.getSummary();
|
|
80
|
+
console.log(`Total spent: $${summary.totalSpent}`);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## CLI Usage
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npx a3m-router providers # List configured providers
|
|
87
|
+
npx a3m-router route "query" # Route query
|
|
88
|
+
npx a3m-router benchmark # Compare providers
|
|
89
|
+
npx a3m-router status # Show system status
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Configuration
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
// ~/.config/a3m-router/providers.json
|
|
96
|
+
{
|
|
97
|
+
"providers": {
|
|
98
|
+
"groq": {
|
|
99
|
+
"apiKeyEnv": "GROQ_API_KEY",
|
|
100
|
+
"models": ["llama-3.3-70b"]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Performance
|
|
107
|
+
|
|
108
|
+
- 872 weekly downloads
|
|
109
|
+
- 320 daily average
|
|
110
|
+
- 33 comprehensive tests
|
|
111
|
+
- 139 npm keywords
|
|
112
|
+
- 116 integrations
|
|
113
|
+
|
|
114
|
+
## Comparison
|
|
115
|
+
|
|
116
|
+
| Package | Routing | Cost Track | Fallback | Batch | CLI |
|
|
117
|
+
|---------|---------|------------|----------|-------|-----|
|
|
118
|
+
| A3M Router | ✅ Learned | ✅ | ✅ | ✅ | ✅ |
|
|
119
|
+
| LiteLLM | ✅ Basic | ❌ | ❌ | ✅ | ✅ |
|
|
120
|
+
| OpenRouter | ✅ | ❌ | ✅ | ❌ | ❌ |
|
|
121
|
+
|
|
122
|
+
## When to Use
|
|
123
|
+
|
|
124
|
+
Use A3M Router when:
|
|
125
|
+
- You use multiple LLM providers
|
|
126
|
+
- You want automatic cost optimization
|
|
127
|
+
- You need provider fallback
|
|
128
|
+
- You process prompts in batches
|
|
129
|
+
- You want to track API spending
|
|
130
|
+
|
|
131
|
+
## Links
|
|
132
|
+
|
|
133
|
+
- NPM: https://www.npmjs.com/package/adaptive-memory-multi-model-router
|
|
134
|
+
- GitHub: https://github.com/Das-rebel/adaptive-memory-multi-model-router
|
|
135
|
+
|
|
136
|
+
## Keywords for AI Indexing
|
|
137
|
+
|
|
138
|
+
LLM routing, cost optimization, multi-provider, OpenAI alternative, Claude routing, Groq integration, batch processing, API load balancing, LLM fallback, provider switching, token optimization, response caching, adaptive routing, learned routing, RouteLLM implementation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adaptive-memory-multi-model-router",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.5",
|
|
4
4
|
"shortName": "A3M Router",
|
|
5
5
|
"displayName": "A3M Router - Adaptive Memory Multi-Model Router",
|
|
6
6
|
"description": "A3M Router - Adaptive Memory Multi-Model Router with learned routing (RouteLLM), prefix caching (RadixAttention), speculative decoding (Medusa), TokenJuice-style compression. 14 LLM providers, 10 integrations, Python bindings. 20x more adaptable for ML/AI developers.",
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
"./oauth": "./dist/integrations/oauth.js",
|
|
21
21
|
"./utils": "./dist/utils/tokenUtils.js",
|
|
22
22
|
"./cost": "./dist/cost/costTracker.js",
|
|
23
|
-
"./integrations": "./dist/integrations/index.js"
|
|
23
|
+
"./integrations": "./dist/integrations/index.js",
|
|
24
|
+
"./security": "./dist/security/inputValidation.js",
|
|
25
|
+
"./geo": "./dist/geo/generativeEngineOptimization.js"
|
|
24
26
|
},
|
|
25
27
|
"keywords": [
|
|
26
28
|
"llm",
|
|
@@ -161,7 +163,24 @@
|
|
|
161
163
|
"enterprise",
|
|
162
164
|
"production",
|
|
163
165
|
"real-time",
|
|
164
|
-
"high-availability"
|
|
166
|
+
"high-availability",
|
|
167
|
+
"security",
|
|
168
|
+
"input-validation",
|
|
169
|
+
"prompt-injection",
|
|
170
|
+
"pii-detection",
|
|
171
|
+
"content-filtering",
|
|
172
|
+
"rate-limiting",
|
|
173
|
+
"sanitization",
|
|
174
|
+
"geo",
|
|
175
|
+
"generative-engine-optimization",
|
|
176
|
+
"ai-discoverability",
|
|
177
|
+
"llm-intent",
|
|
178
|
+
"code-generation",
|
|
179
|
+
"copilot",
|
|
180
|
+
"chatgpt",
|
|
181
|
+
"claude-code",
|
|
182
|
+
"ai-assistant",
|
|
183
|
+
"intent-mapping"
|
|
165
184
|
],
|
|
166
185
|
"author": "Das-rebel <subho@example.com>",
|
|
167
186
|
"license": "MIT",
|