adaptive-memory-multi-model-router 2.15.2 → 2.15.4
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/ARCHITECTURE.md +1 -1
- package/README.md +248 -150
- package/adapters/README.md +36 -0
- package/adapters/__init__.py +25 -0
- package/adapters/a3m_adapter/__init__.py +15 -0
- package/adapters/a3m_adapter/adapter/__init__.py +7 -0
- package/adapters/a3m_adapter/adapter/config.py +100 -0
- package/adapters/a3m_adapter/adapter/langchain.py +155 -0
- package/adapters/a3m_adapter/adapter/llamaindex.py +162 -0
- package/adapters/a3m_adapter/tests/__init__.py +1 -0
- package/adapters/a3m_adapter/tests/test_adapters.py +120 -0
- package/adapters/setup.py +23 -0
- package/articles/HN_SHOW_SEO.md +49 -0
- package/articles/PRODUCTHUNT_READY.md +47 -67
- package/articles/REDDIT_SEO_2026.md +50 -0
- package/demo/IMPROVED_PROMPTS.md +3 -3
- package/demo/VEO3_PROMPTS.md +2 -2
- package/demo/VIDEO_PRODUCTION_GUIDE.md +3 -3
- package/docs/comparison-litellm.md +10 -18
- package/docs/index.html +29 -34
- package/docs/llms-full.txt +286 -153
- package/docs/llms.txt +109 -70
- package/docs-site/index.html +19 -19
- package/llms.txt +109 -70
- package/mcp-server/package.json +0 -6
- package/mcp-server/tsconfig.json +2 -3
- package/package.json +13 -92
- package/sitemap.xml +15 -9
- package/src/routing/advancedRouter.ts +101 -0
- package/src/routing/providerHealth.ts +234 -4
- package/src/routing/shadowSampler.ts +427 -0
- package/.github/ISSUE_TEMPLATE/checklist.md +0 -35
package/ARCHITECTURE.md
CHANGED
|
@@ -140,7 +140,7 @@ The routing engine (`sdk.ts` → `extractQueryFeatures`) classifies queries on 1
|
|
|
140
140
|
| requires_reasoning | Step-by-step reasoning triggers |
|
|
141
141
|
| domain | Detected domain (legal, medical, security, finance, devops, data) |
|
|
142
142
|
|
|
143
|
-
Classification routes to the `free` / `cheap` / `mid` / `premium` cost tier, targeting
|
|
143
|
+
Classification routes to the `free` / `cheap` / `mid` / `premium` cost tier, targeting 67% exact tier match (MMR-Bench) with 96% within 1 tier.
|
|
144
144
|
|
|
145
145
|
### 3. Memory System
|
|
146
146
|
|
package/README.md
CHANGED
|
@@ -1,245 +1,343 @@
|
|
|
1
1
|
# A3M Router
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Intelligent LLM routing across 47+ providers — saves 70-95% on AI costs.**
|
|
4
4
|
|
|
5
|
-
A3M Router
|
|
5
|
+
A3M Router automatically picks the cheapest capable model for each request. No code changes needed. Just swap your API endpoint.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## TL;DR — What Is This?
|
|
10
|
+
|
|
11
|
+
**Before:**
|
|
12
|
+
```python
|
|
13
|
+
# Pay GPT-4o prices for EVERY query
|
|
14
|
+
client = OpenAI(api_key="sk-...")
|
|
15
|
+
response = client.chat.completions.create(
|
|
16
|
+
model="gpt-4o",
|
|
17
|
+
messages=[{"role": "user", "content": "What is 2+2?"}]
|
|
18
|
+
) # Costs: $0.03
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**After:**
|
|
22
|
+
```python
|
|
23
|
+
# A3M Router picks the right model automatically
|
|
24
|
+
client = OpenAI(base_url="http://localhost:8787/v1", api_key="not-needed")
|
|
25
|
+
response = client.chat.completions.create(
|
|
26
|
+
model="auto", # ← Just change this
|
|
27
|
+
messages=[{"role": "user", "content": "What is 2+2?"}]
|
|
28
|
+
) # Routes to Groq/Mistral — costs: $0.0001
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Result:** Simple questions cost 300x less. Complex queries still go to premium models when needed.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Why A3M Router?
|
|
36
|
+
|
|
37
|
+
| Problem | Solution |
|
|
38
|
+
|---------|----------|
|
|
39
|
+
| GPT-4o is $15/1M tokens | A3M routes simple queries to $0.001/1K providers |
|
|
40
|
+
| Managing 47+ API keys is messy | One endpoint, A3M handles the rest |
|
|
41
|
+
| Provider goes down mid-request | Automatic failover to next best option |
|
|
42
|
+
| Need the best answer, cost doesn't matter | Parallel ensemble calls multiple providers |
|
|
8
43
|
|
|
9
44
|
---
|
|
10
45
|
|
|
11
46
|
## Quick Start
|
|
12
47
|
|
|
13
48
|
```bash
|
|
49
|
+
# Install
|
|
14
50
|
npm install adaptive-memory-multi-model-router
|
|
51
|
+
|
|
52
|
+
# Start server
|
|
15
53
|
npx a3m-router serve
|
|
16
54
|
```
|
|
17
55
|
|
|
56
|
+
Then use it like any OpenAI-compatible API:
|
|
57
|
+
|
|
18
58
|
```python
|
|
19
59
|
from openai import OpenAI
|
|
20
60
|
|
|
21
61
|
client = OpenAI(base_url="http://localhost:8787/v1", api_key="not-needed")
|
|
22
62
|
|
|
63
|
+
# Simple query → routes to cheapest capable (Groq, Mistral, etc.)
|
|
23
64
|
response = client.chat.completions.create(
|
|
24
|
-
model="auto",
|
|
25
|
-
messages=[{"role": "user", "content": "
|
|
65
|
+
model="auto",
|
|
66
|
+
messages=[{"role": "user", "content": "What is Python?"}]
|
|
26
67
|
)
|
|
27
68
|
```
|
|
28
69
|
|
|
29
|
-
That's it. `model="auto"` triggers routing. All other OpenAI SDK calls work unchanged.
|
|
30
|
-
|
|
31
70
|
---
|
|
32
71
|
|
|
33
|
-
##
|
|
72
|
+
## Parallel Ensemble — Best Answer, Any Provider
|
|
34
73
|
|
|
35
|
-
|
|
74
|
+
Need the best answer regardless of cost? Call multiple providers in parallel:
|
|
36
75
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
| **Domain** | Legal, medical, code, finance, ML keywords |
|
|
40
|
-
| **Task type** | Code generation, translation, analysis, creative |
|
|
41
|
-
| **Query structure** | Clause count, length, qualifier words |
|
|
42
|
-
| **Verb intensity** | "design/architect" → complex, "what/who" → simple |
|
|
43
|
-
| **Multi-step** | Explicit step markers (first...then, step 1/2/3) |
|
|
76
|
+
```python
|
|
77
|
+
from a3m.router import A3MRouter
|
|
44
78
|
|
|
45
|
-
|
|
79
|
+
router = A3MRouter(
|
|
80
|
+
model="auto",
|
|
81
|
+
parallel_ensemble=3, # ← Call 3 providers simultaneously
|
|
82
|
+
)
|
|
46
83
|
|
|
47
|
-
|
|
84
|
+
result = router.route(
|
|
85
|
+
messages=[{"role": "user", "content": "Explain quantum entanglement"}],
|
|
86
|
+
ensemble_timeout_ms=10000,
|
|
87
|
+
)
|
|
48
88
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
89
|
+
# result.content — winning response
|
|
90
|
+
# result.provider — which provider won
|
|
91
|
+
# result.scores — quality scores per provider
|
|
92
|
+
# result.all_results — all responses for comparison
|
|
93
|
+
```
|
|
53
94
|
|
|
54
|
-
|
|
95
|
+
**Real-world example:**
|
|
96
|
+
```python
|
|
97
|
+
# Call Groq (fast/cheap) + OpenAI (quality) + DeepSeek (cost-effective) in parallel
|
|
98
|
+
ensemble_result = router.route(
|
|
99
|
+
messages=[{"role": "user", "content": prompt}],
|
|
100
|
+
ensemble_config={
|
|
101
|
+
"providers": ["groq", "openai", "deepseek"],
|
|
102
|
+
"timeout_ms": 15000,
|
|
103
|
+
"score_weights": {"relevance": 0.4, "conciseness": 0.3, "accuracy": 0.3}
|
|
104
|
+
}
|
|
105
|
+
)
|
|
55
106
|
|
|
56
|
-
|
|
107
|
+
print(f"Best answer from: {ensemble_result.provider}")
|
|
108
|
+
print(f"Response: {ensemble_result.content}")
|
|
109
|
+
print(f"All scores: {ensemble_result.scores}")
|
|
110
|
+
```
|
|
57
111
|
|
|
58
|
-
|
|
112
|
+
---
|
|
59
113
|
|
|
60
|
-
|
|
114
|
+
## Multi-Agent Systems — CrewAI Example
|
|
61
115
|
|
|
62
|
-
|
|
63
|
-
LiteLLM routes by model name or requires you to specify which model to call. A3M's `model="auto"` mode analyzes the query content and picks the cheapest capable provider automatically. This is useful when you want cost efficiency without writing routing logic.
|
|
116
|
+
Powerful for multi-agent systems where different agents need different model capabilities:
|
|
64
117
|
|
|
65
|
-
|
|
66
|
-
|
|
118
|
+
```python
|
|
119
|
+
from crewai import Agent, Task, Crew
|
|
120
|
+
from crewai.llms import A3MCompletion
|
|
121
|
+
|
|
122
|
+
# Research agent — needs factual accuracy
|
|
123
|
+
researcher = Agent(
|
|
124
|
+
role="Research Analyst",
|
|
125
|
+
goal="Find accurate information",
|
|
126
|
+
backstory="Expert researcher",
|
|
127
|
+
llm=A3MCompletion(model="auto", temperature=0.3),
|
|
128
|
+
)
|
|
67
129
|
|
|
68
|
-
|
|
69
|
-
|
|
130
|
+
# Writer agent — needs creativity
|
|
131
|
+
writer = Agent(
|
|
132
|
+
role="Content Writer",
|
|
133
|
+
goal="Create engaging content",
|
|
134
|
+
backstory="Creative writer",
|
|
135
|
+
llm=A3MCompletion(model="auto", temperature=0.9),
|
|
136
|
+
)
|
|
70
137
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
)
|
|
78
|
-
// result.winner — which provider gave the best response
|
|
79
|
-
// result.scores — per-provider quality scores
|
|
80
|
-
// result.allResults — all responses preserved
|
|
81
|
-
```
|
|
138
|
+
# Critic agent — needs balance
|
|
139
|
+
critic = Agent(
|
|
140
|
+
role="Quality Critic",
|
|
141
|
+
goal="Ensure quality",
|
|
142
|
+
backstory="Detail editor",
|
|
143
|
+
llm=A3MCompletion(model="auto", temperature=0.5),
|
|
144
|
+
)
|
|
82
145
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
146
|
+
# Tasks with expected outputs
|
|
147
|
+
research_task = Task(
|
|
148
|
+
description="Research AI trends",
|
|
149
|
+
expected_output="Detailed report with citations",
|
|
150
|
+
agent=researcher,
|
|
151
|
+
)
|
|
89
152
|
|
|
90
|
-
|
|
153
|
+
crew = Crew(
|
|
154
|
+
agents=[researcher, writer, critic],
|
|
155
|
+
tasks=[research_task],
|
|
156
|
+
process="hierarchical",
|
|
157
|
+
manager_llm=A3MCompletion(model="auto"),
|
|
158
|
+
)
|
|
91
159
|
|
|
92
|
-
|
|
93
|
-
|
|
160
|
+
result = crew.kickoff()
|
|
161
|
+
```
|
|
94
162
|
|
|
95
163
|
---
|
|
96
164
|
|
|
97
|
-
##
|
|
165
|
+
## LangChain + LlamaIndex Adapters
|
|
98
166
|
|
|
99
|
-
|
|
100
|
-
Request → Guardrails → Cache → Router → Provider → Response
|
|
101
|
-
↓
|
|
102
|
-
Cost tracking
|
|
103
|
-
Metrics
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
**Guardrails** — Runs before any provider call: prompt injection detection, PII detection, content filtering. Rejects or sanitizes dangerous input.
|
|
167
|
+
Use A3M Router as a drop-in replacement:
|
|
107
168
|
|
|
108
|
-
|
|
169
|
+
```python
|
|
170
|
+
# LangChain
|
|
171
|
+
from a3m_adapter import A3MLangChainAdapter
|
|
109
172
|
|
|
110
|
-
|
|
173
|
+
llm = A3MLangChainAdapter(
|
|
174
|
+
model="auto",
|
|
175
|
+
temperature=0.7,
|
|
176
|
+
parallel_ensemble=2
|
|
177
|
+
)
|
|
111
178
|
|
|
112
|
-
|
|
179
|
+
# Works with any LangChain chain
|
|
180
|
+
from langchain import chain
|
|
181
|
+
result = llm.invoke("What is retrieval-augmented generation?")
|
|
113
182
|
|
|
114
|
-
|
|
183
|
+
# LlamaIndex
|
|
184
|
+
from a3m_adapter import A3MLlamaIndexAdapter
|
|
115
185
|
|
|
116
|
-
|
|
186
|
+
llm = A3MLlamaIndexAdapter(model="auto")
|
|
187
|
+
response = llm.complete("Explain transformer architecture")
|
|
188
|
+
```
|
|
117
189
|
|
|
118
|
-
|
|
119
|
-
|--------|----------|-------------|
|
|
120
|
-
| POST | `/v1/chat/completions` | OpenAI-compatible chat (streaming + non-streaming) |
|
|
121
|
-
| POST | `/v1/completions` | OpenAI completions |
|
|
122
|
-
| POST | `/v1/embeddings` | Text embeddings |
|
|
123
|
-
| POST | `/v1/route` | Get routing decision without calling an LLM |
|
|
124
|
-
| GET | `/v1/models` | Available models and pricing |
|
|
125
|
-
| GET | `/health` | Provider health, recent requests, cost totals |
|
|
126
|
-
| GET | `/metrics` | Prometheus-compatible metrics |
|
|
190
|
+
---
|
|
127
191
|
|
|
128
|
-
|
|
192
|
+
## How Routing Works
|
|
129
193
|
|
|
130
|
-
|
|
131
|
-
npx a3m-router serve # start proxy on port 8787
|
|
132
|
-
npx a3m-router route "query" # see routing decision for a query
|
|
133
|
-
npx a3m-router health # provider latency and availability
|
|
134
|
-
npx a3m-router benchmark # run local accuracy test (n=200)
|
|
135
|
-
```
|
|
194
|
+
For every request, A3M analyzes:
|
|
136
195
|
|
|
137
|
-
|
|
196
|
+
| Signal | Detects |
|
|
197
|
+
|--------|---------|
|
|
198
|
+
| **Domain** | Legal, medical, code, finance, ML keywords |
|
|
199
|
+
| **Task type** | Code, translation, analysis, creative |
|
|
200
|
+
| **Complexity** | Clause count, multi-step markers |
|
|
201
|
+
| **Verb intensity** | "design/architect" → complex, "what/who" → simple |
|
|
138
202
|
|
|
139
|
-
|
|
203
|
+
Then maps to a tier:
|
|
140
204
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
205
|
+
| Tier | Providers | Use When |
|
|
206
|
+
|------|-----------|----------|
|
|
207
|
+
| **Free** | Ollama, Llama.cpp | Experimentation |
|
|
208
|
+
| **Cheap** | Groq, DeepSeek, Mistral | Simple Q&A, short code |
|
|
209
|
+
| **Mid** | GPT-4o-mini, Claude-haiku | Standard tasks |
|
|
210
|
+
| **Premium** | GPT-4o, Claude-sonnet, Gemini | Complex reasoning |
|
|
147
211
|
|
|
148
|
-
|
|
212
|
+
---
|
|
149
213
|
|
|
150
|
-
|
|
151
|
-
import { BudgetManager } from 'adaptive-memory-multi-model-router/billing';
|
|
214
|
+
## Cost Comparison
|
|
152
215
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
216
|
+
| Query Type | GPT-4o Cost | A3M Router Cost | Savings |
|
|
217
|
+
|------------|-------------|-----------------|---------|
|
|
218
|
+
| "What is 2+2?" | $0.03 | $0.0001 (Groq) | **99.7%** |
|
|
219
|
+
| "Write a Python function" | $0.05 | $0.002 (DeepSeek) | **96%** |
|
|
220
|
+
| "Design a database schema" | $0.15 | $0.008 (Mixed) | **95%** |
|
|
221
|
+
| "Complex multi-step reasoning" | $0.15 | $0.15 (GPT-4o) | **0%** (correctly routed) |
|
|
158
222
|
|
|
159
|
-
|
|
223
|
+
---
|
|
160
224
|
|
|
161
|
-
|
|
162
|
-
import { RetryManager } from 'adaptive-memory-multi-model-router/retry';
|
|
225
|
+
## Memory & Context
|
|
163
226
|
|
|
164
|
-
|
|
165
|
-
providers: {
|
|
166
|
-
'openai': { timeout: 30000, maxRetries: 3, baseDelay: 1000 },
|
|
167
|
-
'groq': { timeout: 15000, maxRetries: 2, baseDelay: 500 },
|
|
168
|
-
},
|
|
169
|
-
});
|
|
170
|
-
```
|
|
227
|
+
A3M Router includes **semantic memory** capabilities:
|
|
171
228
|
|
|
172
|
-
|
|
229
|
+
```python
|
|
230
|
+
# Enable conversation memory
|
|
231
|
+
router = A3MRouter(
|
|
232
|
+
model="auto",
|
|
233
|
+
memory={
|
|
234
|
+
"type": "semantic", # Embeddings-based
|
|
235
|
+
"window": 10, # Last 10 exchanges
|
|
236
|
+
"similarity_threshold": 0.85,
|
|
237
|
+
}
|
|
238
|
+
)
|
|
173
239
|
|
|
174
|
-
|
|
175
|
-
|
|
240
|
+
# First call — caches the context
|
|
241
|
+
result1 = router.route(
|
|
242
|
+
messages=[{"role": "user", "content": "I'm building a Python web app"}]
|
|
243
|
+
)
|
|
176
244
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
245
|
+
# Second call — uses cached context automatically
|
|
246
|
+
result2 = router.route(
|
|
247
|
+
messages=[{"role": "user", "content": "What framework should I use?"}]
|
|
248
|
+
)
|
|
249
|
+
# A3M knows "Python web app" from previous context
|
|
182
250
|
```
|
|
183
251
|
|
|
252
|
+
**Memory features:**
|
|
253
|
+
- **Semantic cache** — Instant responses for similar queries
|
|
254
|
+
- **Conversation context** — Maintains history across requests
|
|
255
|
+
- **Cross-session memory** — Remembers important facts
|
|
256
|
+
- **Adaptive forgetting** — Auto-evicts stale information
|
|
257
|
+
|
|
184
258
|
---
|
|
185
259
|
|
|
186
260
|
## Provider Coverage
|
|
187
261
|
|
|
188
262
|
| Provider | Tiers | Notes |
|
|
189
263
|
|----------|-------|-------|
|
|
190
|
-
| OpenAI |
|
|
191
|
-
| Anthropic |
|
|
192
|
-
| Google |
|
|
193
|
-
| Groq |
|
|
194
|
-
| DeepSeek |
|
|
195
|
-
| Mistral |
|
|
196
|
-
| NVIDIA |
|
|
197
|
-
|
|
|
198
|
-
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
| AWS Bedrock | premium, mid | enterprise |
|
|
202
|
-
|
|
203
|
-
47+ providers total. Availability is checked at runtime.
|
|
264
|
+
| OpenAI | Premium, Mid | GPT-4o, GPT-4o-mini |
|
|
265
|
+
| Anthropic | Premium, Mid | Claude-3.5-sonnet, Claude-3-haiku |
|
|
266
|
+
| Google | Premium, Mid | Gemini-1.5-pro, Gemini-1.5-flash |
|
|
267
|
+
| Groq | Cheap | Llama-3.3-70b (fastest) |
|
|
268
|
+
| DeepSeek | Cheap, Mid | DeepSeek-chat, DeepSeek-coder |
|
|
269
|
+
| Mistral | Cheap, Mid | Mistral-large, Mistral-small |
|
|
270
|
+
| NVIDIA | Premium | Nemotron |
|
|
271
|
+
| Ollama | All | Self-hosted models |
|
|
272
|
+
| vLLM | All | Self-hosted OpenAI-compatible |
|
|
273
|
+
|
|
274
|
+
**47+ providers total.** Availability checked at runtime.
|
|
204
275
|
|
|
205
276
|
---
|
|
206
277
|
|
|
207
|
-
##
|
|
278
|
+
## CLI Commands
|
|
208
279
|
|
|
209
|
-
|
|
280
|
+
```bash
|
|
281
|
+
npx a3m-router serve # Start server (port 8787)
|
|
282
|
+
npx a3m-router route "query" # See routing decision
|
|
283
|
+
npx a3m-router health # Provider status
|
|
284
|
+
npx a3m-router benchmark # Local accuracy test
|
|
285
|
+
```
|
|
210
286
|
|
|
211
|
-
|
|
287
|
+
---
|
|
212
288
|
|
|
213
|
-
|
|
214
|
-
import { RouteContext } from '../router';
|
|
289
|
+
## Architecture
|
|
215
290
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
291
|
+
```
|
|
292
|
+
Request → Guardrails → Semantic Cache → Router → Provider → Response
|
|
293
|
+
↓
|
|
294
|
+
Memory Layer
|
|
295
|
+
(optional)
|
|
219
296
|
```
|
|
220
297
|
|
|
221
|
-
**
|
|
298
|
+
- **Guardrails** — Prompt injection detection, PII filtering
|
|
299
|
+
- **Semantic Cache** — Instant hits for repeated queries (zero cost)
|
|
300
|
+
- **Router** — Scores query, selects tier, picks cheapest healthy provider
|
|
301
|
+
- **Ensemble** — Optional parallel calls for best-answer mode
|
|
222
302
|
|
|
223
|
-
|
|
224
|
-
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Installation
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# npm
|
|
309
|
+
npm install adaptive-memory-multi-model-router
|
|
225
310
|
|
|
226
|
-
|
|
227
|
-
|
|
311
|
+
# Python
|
|
312
|
+
pip install adaptive-memory-multi-model-router
|
|
313
|
+
|
|
314
|
+
# Docker
|
|
315
|
+
docker run -p 8787:8787 ghcr.io/das-rebel/a3m-router
|
|
228
316
|
```
|
|
229
317
|
|
|
230
|
-
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## Independent Benchmark
|
|
321
|
+
|
|
322
|
+
**RouterArena Evaluation:**
|
|
323
|
+
- **Accuracy:** 96.77%
|
|
324
|
+
- **Cost:** $0.0768/1K tokens
|
|
325
|
+
- **Robustness:** 1.0000
|
|
326
|
+
- **Queries tested:** 8,400
|
|
231
327
|
|
|
232
328
|
---
|
|
233
329
|
|
|
234
330
|
## Project Stats
|
|
235
331
|
|
|
236
|
-
- **
|
|
237
|
-
- **
|
|
238
|
-
- **
|
|
239
|
-
- **
|
|
332
|
+
- **npm downloads:** ~5,400/month
|
|
333
|
+
- **Providers:** 47+
|
|
334
|
+
- **License:** MIT
|
|
335
|
+
- **Stars:** 10
|
|
240
336
|
|
|
241
337
|
---
|
|
242
338
|
|
|
243
|
-
##
|
|
339
|
+
## Need Help?
|
|
244
340
|
|
|
245
|
-
|
|
341
|
+
- 📖 [Documentation](docs/)
|
|
342
|
+
- 🐛 [Issues](https://github.com/Das-rebel/a3m-router/issues)
|
|
343
|
+
- 💬 [Discussions](https://github.com/Das-rebel/a3m-router/discussions)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# A3M Router Adapters
|
|
2
|
+
|
|
3
|
+
Drop-in adapters for LangChain and LlamaIndex to integrate with A3M Router for intelligent model routing.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install a3m_adapter
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or install with extras:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install a3m_adapter[langchain] # With LangChain support
|
|
15
|
+
pip install a3m_adapter[llamaindex] # With LlamaIndex support
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### LangChain
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from a3m_adapter import A3MLangChainAdapter
|
|
24
|
+
|
|
25
|
+
llm = A3MLangChainAdapter(model="auto", temperature=0.7)
|
|
26
|
+
result = llm.invoke("What is the capital of France?")
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### LlamaIndex
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from a3m_adapter import A3MLlamaIndexAdapter
|
|
33
|
+
|
|
34
|
+
llm = A3MLlamaIndexAdapter(model="auto")
|
|
35
|
+
response = llm.complete("What is the capital of France?")
|
|
36
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""
|
|
2
|
+
A3M Router Adapter Package
|
|
3
|
+
|
|
4
|
+
This package provides drop-in adapters to integrate A3M Router
|
|
5
|
+
with popular LLM frameworks including LangChain, LlamaIndex, and more.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
from adapters import A3MLangChainAdapter, A3MLlamaIndexAdapter, A3MConfig
|
|
9
|
+
|
|
10
|
+
# LangChain
|
|
11
|
+
llm = A3MLangChainAdapter(model="auto", temperature=0.7)
|
|
12
|
+
|
|
13
|
+
# LlamaIndex
|
|
14
|
+
llm = A3MLlamaIndexAdapter(model="auto")
|
|
15
|
+
|
|
16
|
+
# Configuration
|
|
17
|
+
config = A3MConfig(model="auto", parallel_ensemble=2)
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from .a3m_adapter.adapter.langchain import A3MLangChainAdapter
|
|
21
|
+
from .a3m_adapter.adapter.llamaindex import A3MLlamaIndexAdapter
|
|
22
|
+
from .a3m_adapter.adapter.config import A3MConfig
|
|
23
|
+
|
|
24
|
+
__all__ = ['A3MLangChainAdapter', 'A3MLlamaIndexAdapter', 'A3MConfig']
|
|
25
|
+
__version__ = '1.0.0'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""
|
|
2
|
+
A3M Router Adapters for LLM Frameworks.
|
|
3
|
+
|
|
4
|
+
Provides drop-in adapters for:
|
|
5
|
+
- LangChain (A3MLangChainAdapter)
|
|
6
|
+
- LlamaIndex (A3MLlamaIndexAdapter)
|
|
7
|
+
- Configuration management (A3MConfig)
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from .adapter.langchain import A3MLangChainAdapter
|
|
11
|
+
from .adapter.llamaindex import A3MLlamaIndexAdapter
|
|
12
|
+
from .adapter.config import A3MConfig
|
|
13
|
+
|
|
14
|
+
__all__ = ['A3MLangChainAdapter', 'A3MLlamaIndexAdapter', 'A3MConfig']
|
|
15
|
+
__version__ = '1.0.0'
|