adaptive-memory-multi-model-router 2.2.5 → 2.2.6

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.
Files changed (63) hide show
  1. package/README.md +17 -22
  2. package/README.md.bak +836 -0
  3. package/dist/analytics/costAnalytics.d.ts +1 -0
  4. package/dist/cache/cacheKeyGenerator.d.ts +67 -0
  5. package/dist/cache/cacheKeyGenerator.d.ts.map +1 -0
  6. package/dist/cache/cacheKeyGenerator.js +211 -0
  7. package/dist/cache/cacheKeyGenerator.js.map +1 -0
  8. package/dist/cache/semanticCache.d.ts +41 -0
  9. package/dist/cache/semanticCache.d.ts.map +1 -1
  10. package/dist/cache/semanticCache.js +142 -0
  11. package/dist/cache/semanticCache.js.map +1 -1
  12. package/dist/cli.js +35 -478
  13. package/dist/cost/costTracker.js +0 -3
  14. package/dist/cost/preCallCostEstimator.d.ts +114 -0
  15. package/dist/cost/preCallCostEstimator.d.ts.map +1 -0
  16. package/dist/cost/preCallCostEstimator.js +256 -0
  17. package/dist/cost/preCallCostEstimator.js.map +1 -0
  18. package/dist/index.d.ts +16 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +264 -64
  21. package/dist/index.js.map +1 -1
  22. package/dist/inference/speculativeDecoding.d.ts +133 -0
  23. package/dist/inference/speculativeDecoding.d.ts.map +1 -0
  24. package/dist/inference/speculativeDecoding.js +276 -0
  25. package/dist/inference/speculativeDecoding.js.map +1 -0
  26. package/dist/integrations/langchainAdapter.d.ts +1 -0
  27. package/dist/integrations/oauth.d.ts +1 -0
  28. package/dist/memory/autoFetch.d.ts +1 -0
  29. package/dist/memory/memoryTree.d.ts +1 -0
  30. package/dist/memory/obsidianVault.d.ts +1 -0
  31. package/dist/providers/providerConfig.d.ts +1 -0
  32. package/dist/providers/providerConfig.js +2 -0
  33. package/dist/providers/providerHealth.d.ts +117 -0
  34. package/dist/providers/providerHealth.d.ts.map +1 -0
  35. package/dist/providers/providerHealth.js +309 -0
  36. package/dist/providers/providerHealth.js.map +1 -0
  37. package/dist/providers/registry.js +126 -128
  38. package/dist/routing/advancedRouter.js +310 -427
  39. package/dist/routing/difficultyClassifier.d.ts +79 -0
  40. package/dist/routing/difficultyClassifier.d.ts.map +1 -0
  41. package/dist/routing/difficultyClassifier.js +329 -0
  42. package/dist/routing/difficultyClassifier.js.map +1 -0
  43. package/dist/sdk.d.ts +125 -0
  44. package/dist/sdk.d.ts.map +1 -0
  45. package/dist/sdk.js +109 -100
  46. package/dist/sdk.js.map +1 -0
  47. package/dist/security/guardrails.d.ts +1 -0
  48. package/dist/server/dashboard.d.ts +1 -0
  49. package/dist/server/modelMapper.d.ts +1 -0
  50. package/dist/server/proxyServer.d.ts +1 -0
  51. package/package.json +4 -2
  52. package/src/cache/cacheKeyGenerator.ts +242 -0
  53. package/src/cache/semanticCache.ts +148 -0
  54. package/src/cost/preCallCostEstimator.ts +345 -0
  55. package/src/inference/speculativeDecoding.ts +373 -0
  56. package/src/providers/providerHealth.ts +397 -0
  57. package/src/routing/difficultyClassifier.ts +420 -0
  58. package/test/provider-test.js +2 -2
  59. package/test.js +7 -7
  60. package/test.js.bak +376 -0
  61. package/tsconfig.json +15 -5
  62. package/src/index.ts +0 -99
  63. package/src/skills/__tests__/skill_manager.test.ts +0 -328
package/README.md CHANGED
@@ -54,7 +54,7 @@ npx a3m-router serve # OpenAI proxy at localhost:87
54
54
 
55
55
  ## Why A3M Router
56
56
 
57
- Every LLM router either uses ML (RouteLLM 1.5 GB, GPU required) or doesn't route at all (LiteLLM you pick the model). A3M Router is the only one that achieves near-ML accuracy with zero ML overhead, then adds memory, caching, guardrails, and cost tracking on top.
57
+ A3M Router uses multi-signal heuristic routing -- 12 keyword signals across 5 dimensions -- to classify query complexity and route to cost-effective providers. No ML model weights. No GPU required. Starts in <100ms.
58
58
 
59
59
  For **generative engine optimization** — synthesizing multiple AI models into a single coherent output — A3M Router pairs [MCTS workflow optimization](#mcts-workflow-optimization) for multi-agent orchestration with heuristic scoring for per-query routing. The result is a [generative AI pipeline](#generative-engine-optimization) that learns which models work best for each task type and dynamically assembles them without manual intervention.
60
60
 
@@ -204,36 +204,31 @@ User Query
204
204
  Routing Accuracy Comparison (200 queries)
205
205
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
206
206
  A3M Router ████████████████████████████████████████████████████ 99.5%
207
- RouteLLM ███████████████████████████████████████████ ~85%
208
207
 
209
208
  Package Size Comparison
210
209
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
211
210
  A3M Router █ 19.5 KB
212
211
  LiteLLM ████████████████████████████████ ~50 MB
213
- RouteLLM ████████████████████████████████████████████████████ ~1.5 GB
214
212
 
215
213
  Startup Time
216
214
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
217
215
  A3M Router ████ <100ms
218
216
  LiteLLM ████████████████ ~500ms
219
- RouteLLM ████████████████████████████████████████████████████ ~2s
220
217
  ```
221
218
 
222
219
  See full benchmark methodology at [`scripts/routing-benchmark-v2.js`](scripts/routing-benchmark-v2.js) or run it with `node scripts/routing-benchmark-v2.js`.
223
220
 
224
- , same methodology as [RouteLLM (arXiv:2404.06035)](https://arxiv.org/abs/2404.06035).
225
-
226
- | Metric | A3M Router | RouteLLM (BERT) |
221
+ | Metric | A3M Router | LiteLLM |
227
222
  |--------|:----------:|:---------------:|
228
- | **±1 tier accuracy** | **99.5%** | ~85% |
229
- | Exact tier match | 64.5% | Not published |
230
- | Cost savings vs all-premium | 61.6% | ~60-70% |
231
- | GPU required | No | Yes |
232
- | Model weights | 0 KB | 500 MB+ |
233
- | Package size | 19.5 KB gzipped | 1.5 GB+ |
234
- | Startup time | <100 ms | ~2 s |
223
+ | **±1 tier accuracy** | **99.5%** | N/A (manual) |
224
+ | Exact tier match | 64.5% | N/A |
225
+ | Cost savings vs all-premium | 61.6% | 0% (you pick) |
226
+ | GPU required | No | No |
227
+ | Model weights | 0 KB | 0 KB |
228
+ | Package size | 19.5 KB gzipped | ~50 MB |
229
+ | Startup time | <100 ms | ~500ms |
235
230
 
236
- RouteLLM scores from arXiv:2404.06035 on MT-Bench. Our scores on 200-query self-benchmark. Same methodology, different test set. Not directly comparable.
231
+ Internal benchmark on 200-query test set. LiteLLM requires manual model selection.
237
232
 
238
233
  ```
239
234
  routed → free cheap mid premium
@@ -270,7 +265,7 @@ Premium █ ~5% of queries
270
265
 
271
266
  Based on real provider pricing. Simple queries → free models. Expert → premium only when needed.
272
267
 
273
- Real provider pricing. 10,000 queries/month. [RouteLLM paper](https://arxiv.org/abs/2404.06035) shows ~47% of queries are simple.
268
+ Real provider pricing. 10,000 queries/month. Industry data shows ~47% of queries are simple (routable to free/cheap tiers).
274
269
 
275
270
  | Query Type | % Traffic | GPT-4o Only | A3M Routes To | A3M Cost | Savings |
276
271
  |-----------|:---------:|:-----------:|:-------------:|:--------:|:-------:|
@@ -751,12 +746,12 @@ const modelWithTools = model.bindTools([searchTool, calculatorTool]);
751
746
 
752
747
  ## Comparison
753
748
 
754
- | Feature | A3M Router | [RouteLLM](https://github.com/lm-sys/RouteLLM) | [LiteLLM](https://github.com/BerriAI/litellm) | [Portkey](https://github.com/Portkey-AI/gateway) | [OpenRouter](https://openrouter.ai) |
755
- |---------|:----------:|:-------:|:-------:|:-------:|:-------:|
756
- | **Routing accuracy published** | **Yes** (99.5% ±1) | Yes (~85%) | No | No | No |
757
- | **Intelligent routing** | Multi-signal per-query | BERT classifier | Manual selection | Manual | Manual |
758
- | **Zero ML / Zero GPU** | **Yes** | No (BERT) | Yes | Yes | Yes |
759
- | **Package size** | 19.5 KB | ~1.5 GB | ~50 MB | ~30 MB | API-only |
749
+ | Feature | A3M Router | [LiteLLM](https://github.com/BerriAI/litellm) | [Portkey](https://github.com/Portkey-AI/gateway) | [OpenRouter](https://openrouter.ai) |
750
+ |---------|:----------:|:-------:|:-------:|:-------:|
751
+ | **Routing accuracy published** | **Yes** (99.5% ±1) | No (manual) | No | No |
752
+ | **Intelligent routing** | Multi-signal per-query | Manual selection | Manual | Manual |
753
+ | **Zero ML / Zero GPU** | **Yes** | Yes | Yes | Yes |
754
+ | **Package size** | 19.5 KB | ~50 MB | ~30 MB | API-only |
760
755
  | **OpenAI-compatible proxy** | **Yes** | No | Yes | Yes | Yes |
761
756
  | **Adaptive memory** | **Yes** | No | No | No | No |
762
757
  | **Semantic cache** | **Yes** (trigram) | No | No | Yes | No |