adaptive-memory-multi-model-router 1.9.5 → 2.0.0

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 (121) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +50 -0
  2. package/.github/ISSUE_TEMPLATE/config.yml +11 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.md +37 -0
  4. package/.github/PULL_REQUEST_TEMPLATE.md +44 -0
  5. package/.github/workflows/npm-stats-validation.yml +152 -0
  6. package/.github/workflows/pages.yml +37 -0
  7. package/CHANGELOG.md +122 -0
  8. package/CODE_OF_CONDUCT.md +128 -0
  9. package/CONTRIBUTING.md +110 -0
  10. package/LAUNCH-PAIN-DRIVEN.md +339 -0
  11. package/LAUNCH.md +575 -0
  12. package/POPULARITY_BOOSTERS.md +285 -0
  13. package/README.md +231 -300
  14. package/SECURITY.md +69 -0
  15. package/articles/CONTENT_STRUCTURE.md +292 -0
  16. package/articles/DEVTO_COST_GUIDE.md +473 -0
  17. package/articles/DEVTO_FINAL.md +416 -0
  18. package/articles/DEVTO_MULTI_PROVIDER.md +542 -0
  19. package/articles/HN_10X_BETTER.md +430 -0
  20. package/articles/HN_CHINESE_STYLE.md +308 -0
  21. package/articles/HN_FINAL.md +199 -0
  22. package/articles/HN_POSTED_VERSION.md +56 -0
  23. package/articles/HN_RESEARCH.md +364 -0
  24. package/articles/PAIN-DRIVEN-devto-v2.md +308 -0
  25. package/articles/PAIN-DRIVEN-devto-v3.md +268 -0
  26. package/articles/PAIN-DRIVEN-devto.md +242 -0
  27. package/articles/PAIN-DRIVEN-hackernews-v2.md +138 -0
  28. package/articles/PAIN-DRIVEN-hackernews-v3.md +151 -0
  29. package/articles/PAIN-DRIVEN-hackernews.md +131 -0
  30. package/articles/PAIN-DRIVEN-reddit-v2.md +301 -0
  31. package/articles/PAIN-DRIVEN-reddit-v3.md +236 -0
  32. package/articles/PAIN-DRIVEN-reddit.md +218 -0
  33. package/articles/PAIN-DRIVEN-twitter-v2.md +110 -0
  34. package/articles/PAIN-DRIVEN-twitter-v3.md +121 -0
  35. package/articles/PAIN-DRIVEN-twitter.md +120 -0
  36. package/articles/PORTKEY_VS_A3M.md +147 -0
  37. package/articles/REDDIT_FINAL.md +232 -0
  38. package/articles/TWITTER_FINAL.md +167 -0
  39. package/articles/WHY_10X_BETTER.md +261 -0
  40. package/articles/WHY_CHINESE_STYLE_BETTER.md +323 -0
  41. package/articles/hashnode-llm-cost-optimization.md +125 -0
  42. package/articles/medium-building-llm-router.md +205 -0
  43. package/articles/twitter-thread-cost-savings.md +98 -0
  44. package/articles/youtube-tutorial-script.md +262 -0
  45. package/assets/banner.svg +109 -0
  46. package/assets/logo.svg +68 -0
  47. package/assets/social-preview.svg +64 -0
  48. package/demo/demo-script.md +53 -0
  49. package/dist/analytics/costAnalytics.d.ts +77 -0
  50. package/dist/analytics/costAnalytics.d.ts.map +1 -0
  51. package/dist/analytics/costAnalytics.js +219 -0
  52. package/dist/analytics/costAnalytics.js.map +1 -0
  53. package/dist/cache/semanticCache.d.ts +62 -0
  54. package/dist/cache/semanticCache.d.ts.map +1 -0
  55. package/dist/cache/semanticCache.js +176 -0
  56. package/dist/cache/semanticCache.js.map +1 -0
  57. package/dist/cli.js +35 -0
  58. package/dist/index.d.ts +4 -723
  59. package/dist/index.js +11 -362
  60. package/dist/index.js.map +1 -1
  61. package/dist/integrations/langchainAdapter.d.ts +146 -0
  62. package/dist/integrations/langchainAdapter.d.ts.map +1 -0
  63. package/dist/integrations/langchainAdapter.js +731 -0
  64. package/dist/integrations/langchainAdapter.js.map +1 -0
  65. package/dist/integrations/oauth.d.ts +69 -0
  66. package/dist/integrations/oauth.d.ts.map +1 -0
  67. package/dist/integrations/oauth.js +225 -21
  68. package/dist/integrations/oauth.js.map +1 -0
  69. package/dist/memory/autoFetch.d.ts +39 -0
  70. package/dist/memory/autoFetch.d.ts.map +1 -0
  71. package/dist/memory/autoFetch.js +80 -88
  72. package/dist/memory/autoFetch.js.map +1 -0
  73. package/dist/memory/memoryTree.d.ts +76 -0
  74. package/dist/memory/memoryTree.d.ts.map +1 -0
  75. package/dist/memory/memoryTree.js +185 -130
  76. package/dist/memory/memoryTree.js.map +1 -0
  77. package/dist/memory/obsidianVault.d.ts +71 -0
  78. package/dist/memory/obsidianVault.d.ts.map +1 -0
  79. package/dist/memory/obsidianVault.js +207 -22
  80. package/dist/memory/obsidianVault.js.map +1 -0
  81. package/dist/providers/providerConfig.d.ts +49 -0
  82. package/dist/providers/providerConfig.d.ts.map +1 -0
  83. package/dist/providers/providerConfig.js +806 -401
  84. package/dist/providers/providerConfig.js.map +1 -0
  85. package/dist/security/guardrails.d.ts +76 -0
  86. package/dist/security/guardrails.d.ts.map +1 -0
  87. package/dist/security/guardrails.js +479 -0
  88. package/dist/security/guardrails.js.map +1 -0
  89. package/dist/server/dashboard.d.ts +58 -0
  90. package/dist/server/dashboard.d.ts.map +1 -0
  91. package/dist/server/dashboard.js +553 -0
  92. package/dist/server/dashboard.js.map +1 -0
  93. package/dist/server/modelMapper.d.ts +43 -0
  94. package/dist/server/modelMapper.d.ts.map +1 -0
  95. package/dist/server/modelMapper.js +154 -0
  96. package/dist/server/modelMapper.js.map +1 -0
  97. package/dist/server/proxyServer.d.ts +41 -0
  98. package/dist/server/proxyServer.d.ts.map +1 -0
  99. package/dist/server/proxyServer.js +932 -0
  100. package/dist/server/proxyServer.js.map +1 -0
  101. package/dist/skills/__tests__/skill_manager.test.d.ts +2 -0
  102. package/dist/skills/__tests__/skill_manager.test.d.ts.map +1 -0
  103. package/dist/skills/__tests__/skill_manager.test.js +268 -0
  104. package/dist/skills/__tests__/skill_manager.test.js.map +1 -0
  105. package/docs-site/index.html +347 -0
  106. package/package.json +53 -7
  107. package/playground/README.md +51 -0
  108. package/playground/codesandbox.json +12 -0
  109. package/playground/index.js +39 -0
  110. package/scripts/update-npm-badges.js +158 -0
  111. package/src/analytics/costAnalytics.ts +304 -0
  112. package/src/cache/semanticCache.ts +221 -0
  113. package/src/index.ts +6 -0
  114. package/src/integrations/langchainAdapter.ts +955 -0
  115. package/src/providers/providerConfig.ts +923 -0
  116. package/src/security/guardrails.ts +585 -0
  117. package/src/server/dashboard.ts +610 -0
  118. package/src/server/modelMapper.ts +182 -0
  119. package/src/server/proxyServer.ts +1105 -0
  120. package/src/types/langchain.d.ts +83 -0
  121. package/tsconfig.build.json +20 -0
package/SECURITY.md ADDED
@@ -0,0 +1,69 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ We release patches for security vulnerabilities. Which versions are eligible
6
+ receiving such patches depend on their current support status:
7
+
8
+ | Version | Supported |
9
+ | ------- | ------------------ |
10
+ | 1.9.x | :white_check_mark: |
11
+ | 1.8.x | :white_check_mark: |
12
+ | < 1.8 | :x: |
13
+
14
+ ## Reporting a Vulnerability
15
+
16
+ Please report security vulnerabilities by emailing us at [Sdas22@gmail.com](mailto:Sdas22@gmail.com).
17
+
18
+ Please include:
19
+ - Description of the vulnerability
20
+ - Steps to reproduce (if possible)
21
+ - Potential impact
22
+ - Suggested fix (if any)
23
+
24
+ We will acknowledge receipt within 48 hours and send a more detailed response
25
+ within 72 hours indicating the next steps.
26
+
27
+ ## Security Features
28
+
29
+ A3M Router includes several security features:
30
+
31
+ ### Input Validation
32
+ - Prompt injection detection
33
+ - PII (Personally Identifiable Information) detection
34
+ - Content filtering
35
+ - Rate limiting
36
+
37
+ ### API Security
38
+ - No hardcoded API keys
39
+ - Environment variable configuration
40
+ - Secure credential storage recommendations
41
+
42
+ ### Best Practices
43
+ - Regular dependency updates
44
+ - Automated security scanning
45
+ - Code review for all changes
46
+
47
+ ## Security Measures
48
+
49
+ We take the following measures to ensure the security of our users:
50
+
51
+ 1. **Dependency Management**: Regular audits of dependencies
52
+ 2. **Code Review**: All changes reviewed by maintainers
53
+ 3. **Automated Testing**: Security tests in CI/CD pipeline
54
+ 4. **Vulnerability Scanning**: Automated scanning for known vulnerabilities
55
+
56
+ ## Responsible Disclosure
57
+
58
+ We follow responsible disclosure practices:
59
+
60
+ 1. We will acknowledge your report within 48 hours
61
+ 2. We will provide a timeline for fixes
62
+ 3. We will credit you in the release notes (unless you prefer anonymity)
63
+ 4. We will not take legal action against researchers who follow this policy
64
+
65
+ ## Contact
66
+
67
+ For security-related inquiries, contact:
68
+ - Email: Sdas22@gmail.com
69
+ - GitHub Security Advisories: [Create an advisory](https://github.com/Das-rebel/adaptive-memory-multi-model-router/security/advisories)
@@ -0,0 +1,292 @@
1
+ # A3M Router Content Structure
2
+
3
+ ## The Flow: Pain → Research → FREE → Other Points
4
+
5
+ ### 1. PAIN (Lead with this - 30% of content)
6
+
7
+ **The Hook:**
8
+ - "I was paying $2,400/month for OpenAI API calls"
9
+ - "Our AI costs hit 40% of infrastructure budget"
10
+ - "CFO said: cut 50% or remove features"
11
+
12
+ **The Agitation:**
13
+ - "We were using GPT-4 for EVERYTHING"
14
+ - "Even 'What is 2+2?' went to GPT-4 at $0.03/query"
15
+ - "Using a Ferrari for grocery runs"
16
+
17
+ **The Analysis:**
18
+ - "I looked at our logs"
19
+ - "34% simple Q&A, 28% code, 22% summarization, 16% complex"
20
+ - "We were overpaying by 70% for 84% of queries"
21
+
22
+ ---
23
+
24
+ ### 2. RESEARCH (Show the insight - 20% of content)
25
+
26
+ **The Discovery:**
27
+ - "I benchmarked alternatives"
28
+ - "Groq is 50x cheaper and 5x faster for code"
29
+ - "Mistral is 15x cheaper with 90% quality"
30
+ - "Different queries need different models"
31
+
32
+ **The Insight:**
33
+ - "Simple Q&A → any model works"
34
+ - "Code generation → speed matters"
35
+ - "Complex reasoning → quality matters"
36
+ - "One size doesn't fit all"
37
+
38
+ **The Approach:**
39
+ - "Inspired by RouteLLM (arXiv paper)"
40
+ - "Learned routing based on query characteristics"
41
+ - "Match capability to requirements"
42
+
43
+ ---
44
+
45
+ ### 3. FREE (The CTA - 15% of content)
46
+
47
+ **The Offer:**
48
+ - "npm install adaptive-memory-multi-model-router"
49
+ - "npx a3m-router route 'Your query'"
50
+ - "Try it online - no signup needed"
51
+ - "Open source, MIT license"
52
+
53
+ **The Playground:**
54
+ - "https://codesandbox.io/... (playground link)"
55
+ - "Test routing without API keys"
56
+ - "See which provider gets selected"
57
+
58
+ **The CLI:**
59
+ ```bash
60
+ npx a3m-router route "Your query"
61
+ npx a3m-router benchmark
62
+ npx a3m-router providers
63
+ ```
64
+
65
+ ---
66
+
67
+ ### 4. OTHER POINTS (Supporting info - 35% of content)
68
+
69
+ **Results:**
70
+ - "70% cost reduction"
71
+ - "2x speed improvement"
72
+ - "94% quality retention"
73
+ - "872 weekly downloads"
74
+
75
+ **Features:**
76
+ - "12 providers configured"
77
+ - "Zero configuration"
78
+ - "Cost tracking"
79
+ - "Automatic fallback"
80
+
81
+ **Technical:**
82
+ - "Query analysis"
83
+ - "Provider profiles"
84
+ - "Routing algorithm"
85
+ - "Benchmarks"
86
+
87
+ ---
88
+
89
+ ## Content Distribution by Platform
90
+
91
+ ### Hacker News
92
+
93
+ **Structure:**
94
+ 1. **PAIN** (40%) - Personal story, numbers
95
+ 2. **RESEARCH** (15%) - Brief insight
96
+ 3. **FREE** (20%) - Code example, CLI
97
+ 4. **OTHER** (25%) - Technical details
98
+
99
+ **Why:** HN loves personal stories + code
100
+
101
+ ---
102
+
103
+ ### Dev.to
104
+
105
+ **Structure:**
106
+ 1. **PAIN** (30%) - Relatable story
107
+ 2. **RESEARCH** (25%) - Deep dive into problem
108
+ 3. **FREE** (15%) - Installation, playground
109
+ 4. **OTHER** (30%) - Tutorial, examples
110
+
111
+ **Why:** Dev.to readers want to learn + implement
112
+
113
+ ---
114
+
115
+ ### Twitter
116
+
117
+ **Structure:**
118
+ 1. **PAIN** (50%) - Hook tweets
119
+ 2. **RESEARCH** (20%) - Insight tweets
120
+ 3. **FREE** (20%) - CTA tweets
121
+ 4. **OTHER** (10%) - Results tweet
122
+
123
+ **Why:** Twitter needs immediate hooks
124
+
125
+ ---
126
+
127
+ ### Reddit (r/MachineLearning)
128
+
129
+ **Structure:**
130
+ 1. **PAIN** (20%) - Brief context
131
+ 2. **RESEARCH** (40%) - Technical approach
132
+ 3. **FREE** (15%) - Try it
133
+ 4. **OTHER** (25%) - Results, discussion
134
+
135
+ **Why:** ML community wants methodology
136
+
137
+ ---
138
+
139
+ ## The Golden Ratio
140
+
141
+ ### For Maximum Engagement:
142
+ - **40% Pain** - Make it relatable
143
+ - **20% Research** - Show you're smart
144
+ - **20% Free** - Remove friction
145
+ - **20% Other** - Support with facts
146
+
147
+ ### For Technical Audiences:
148
+ - **20% Pain** - Brief context
149
+ - **40% Research** - Deep technical
150
+ - **15% Free** - Easy to try
151
+ - **25% Other** - Implementation details
152
+
153
+ ### For Business Audiences:
154
+ - **50% Pain** - ROI focus
155
+ - **15% Research** - Trust building
156
+ - **20% Free** - Low risk trial
157
+ - **15% Other** - Case studies
158
+
159
+ ---
160
+
161
+ ## Example: HN Post (40/20/20/20)
162
+
163
+ ```
164
+ [PAIN - 40%]
165
+ I was paying $2,400/month for OpenAI API calls.
166
+ We're 5 people, 1,000 queries/day.
167
+ Using GPT-4 for EVERYTHING.
168
+ Even "What is 2+2?" at $0.03/query.
169
+ CFO said cut 50% or remove features.
170
+
171
+ [RESEARCH - 20%]
172
+ I looked at logs: 34% simple, 28% code, 22% summary, 16% complex.
173
+ Different queries need different models.
174
+ Built learned routing inspired by RouteLLM paper.
175
+
176
+ [FREE - 20%]
177
+ npm install adaptive-memory-multi-model-router
178
+ npx a3m-router route "Your query"
179
+ Try online: [playground link]
180
+ Zero config, 12 providers, MIT license.
181
+
182
+ [OTHER - 20%]
183
+ Results: 70% savings, 2x speed, 94% quality.
184
+ Supports Groq, Cerebras, Mistral, OpenAI, etc.
185
+ GitHub: [link]
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Key Principles
191
+
192
+ ### 1. Pain First, Always
193
+ - Start with the problem
194
+ - Make it personal
195
+ - Use specific numbers
196
+ - Create emotional connection
197
+
198
+ ### 2. Research Validates
199
+ - Show you understand the problem
200
+ - Reference credible sources
201
+ - Demonstrate expertise
202
+ - Build trust
203
+
204
+ ### 3. Free Removes Friction
205
+ - No signup required
206
+ - Immediate value
207
+ - Low risk trial
208
+ - Easy to share
209
+
210
+ ### 4. Other Points Support
211
+ - Don't lead with features
212
+ - Use for credibility
213
+ - Keep it brief
214
+ - Support the main story
215
+
216
+ ---
217
+
218
+ ## Common Mistakes
219
+
220
+ ### ❌ WRONG: Feature-First
221
+ ```
222
+ A3M Router is an intelligent routing system with 12 providers,
223
+ cost tracking, automatic fallback, batch processing...
224
+
225
+ It can reduce costs by 70%.
226
+ ```
227
+ **Why it fails:** No emotional connection, sounds like marketing
228
+
229
+ ### ✅ RIGHT: Pain-First
230
+ ```
231
+ I was paying $2,400/month for OpenAI API calls.
232
+ We were using GPT-4 for everything.
233
+ Built a router that cut it to $720.
234
+ ```
235
+ **Why it works:** Relatable problem, personal story, specific result
236
+
237
+ ---
238
+
239
+ ### ❌ WRONG: Research-First
240
+ ```
241
+ RouteLLM (arXiv:2404.06035) proposes learned routing...
242
+ We implemented this approach with provider profiles...
243
+ ```
244
+ **Why it fails:** Too academic, no hook
245
+
246
+ ### ✅ RIGHT: Pain → Research
247
+ ```
248
+ I was paying $2,400/month (pain).
249
+ Then I discovered RouteLLM paper (research).
250
+ Applied it to build this router (solution).
251
+ ```
252
+ **Why it works:** Context first, then credibility
253
+
254
+ ---
255
+
256
+ ### ❌ WRONG: Free-First
257
+ ```
258
+ Try A3M Router free!
259
+ npm install adaptive-memory-multi-model-router
260
+ It has 12 providers and cost tracking...
261
+ ```
262
+ **Why it fails:** No reason to care, sounds salesy
263
+
264
+ ### ✅ RIGHT: Pain → Free
265
+ ```
266
+ I was paying $2,400/month (pain).
267
+ Built this to fix it (solution).
268
+ Try it free: npm install... (CTA)
269
+ ```
270
+ **Why it works:** Context creates desire, then easy action
271
+
272
+ ---
273
+
274
+ ## Summary
275
+
276
+ **The Formula:**
277
+
278
+ ```
279
+ [PAIN] I had this expensive problem
280
+ [RESEARCH] I discovered this insight
281
+ [FREE] I built this solution (try it free)
282
+ [OTHER] Here are the results and details
283
+ ```
284
+
285
+ **The Ratio:**
286
+ - Pain: 30-50% (depending on audience)
287
+ - Research: 15-40% (depending on audience)
288
+ - Free: 15-20% (always easy to try)
289
+ - Other: 15-35% (supporting info)
290
+
291
+ **The Goal:**
292
+ Make them feel the pain, trust your solution, try it immediately.