adaptive-memory-multi-model-router 2.15.3 → 2.15.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/.github/workflows/adapters-ci.yml +142 -0
- package/.github/workflows/ci.yml +2 -5
- package/.github/workflows/pypi-publish.yml +102 -0
- package/CHANGELOG.md +7 -1
- package/README.md +260 -137
- package/README_ja.md +2 -2
- package/README_zh.md +1 -1
- package/adapters/README.md +36 -0
- package/adapters/__init__.py +25 -0
- package/adapters/a3m_adapter/__init__.py +51 -0
- package/adapters/a3m_adapter/adapter/__init__.py +22 -0
- package/adapters/a3m_adapter/adapter/autogen.py +169 -0
- package/adapters/a3m_adapter/adapter/config.py +100 -0
- package/adapters/a3m_adapter/adapter/haystack.py +197 -0
- package/adapters/a3m_adapter/adapter/langchain.py +155 -0
- package/adapters/a3m_adapter/adapter/langgraph.py +196 -0
- package/adapters/a3m_adapter/adapter/llamaindex.py +162 -0
- package/adapters/a3m_adapter/adapter/pinecone.py +217 -0
- package/adapters/a3m_adapter/adapter/vercel.py +188 -0
- package/adapters/a3m_adapter/tests/__init__.py +1 -0
- package/adapters/a3m_adapter/tests/test_adapters.py +118 -0
- package/adapters/a3m_adapter/tests/test_integration.py +80 -0
- package/adapters/requirements-dev.txt +6 -0
- package/adapters/requirements.txt +4 -0
- package/adapters/setup.py +23 -0
- package/apps/cost-calculator/README.md +72 -0
- package/apps/cost-calculator/calculator.css +280 -0
- package/apps/cost-calculator/calculator.js +150 -0
- package/apps/cost-calculator/index.html +321 -0
- package/apps/cost-calculator/package.json +13 -0
- package/articles/ANNOUNCEMENT_reddit_ml.md +76 -0
- package/articles/ANNOUNCEMENT_vc/347/244/276/345/214/272.md +71 -0
- package/articles/ANNOUNCEMENT_vercel.md +85 -0
- package/demo.py +251 -0
- package/dist/providers/providerConfig.d.ts +5 -1
- package/dist/providers/providerConfig.js +1006 -1
- package/dist/providers/providerConfig.js.map +1 -1
- package/docker-compose.yml +84 -60
- package/docs/comparison.md +2 -2
- package/docs/llms-full.txt +360 -138
- package/docs/llms.txt +70 -71
- package/docs-site/index.html +9 -9
- package/llms.txt +70 -62
- package/package.json +41 -91
- package/packages/a3m-vercel-ai/README.md +161 -0
- package/packages/a3m-vercel-ai/dist/a3m-language-model.d.ts +12 -0
- package/packages/a3m-vercel-ai/dist/a3m-language-model.d.ts.map +1 -0
- package/packages/a3m-vercel-ai/dist/a3m-language-model.js +289 -0
- package/packages/a3m-vercel-ai/dist/a3m-language-model.js.map +1 -0
- package/packages/a3m-vercel-ai/dist/index.d.ts +82 -0
- package/packages/a3m-vercel-ai/dist/index.d.ts.map +1 -0
- package/packages/a3m-vercel-ai/dist/index.js +79 -0
- package/packages/a3m-vercel-ai/dist/index.js.map +1 -0
- package/packages/a3m-vercel-ai/dist/types.d.ts +97 -0
- package/packages/a3m-vercel-ai/dist/types.d.ts.map +1 -0
- package/packages/a3m-vercel-ai/dist/types.js +5 -0
- package/packages/a3m-vercel-ai/dist/types.js.map +1 -0
- package/packages/a3m-vercel-ai/package-lock.json +969 -0
- package/packages/a3m-vercel-ai/package.json +46 -0
- package/packages/a3m-vercel-ai/src/a3m-language-model.ts +381 -0
- package/packages/a3m-vercel-ai/src/index.ts +104 -0
- package/packages/a3m-vercel-ai/src/types.ts +116 -0
- package/packages/a3m-vercel-ai/tsconfig.json +20 -0
- package/packages/agentkit-adapter/LICENSE +21 -0
- package/packages/agentkit-adapter/README.md +126 -0
- package/packages/agentkit-adapter/examples/agentkit-example.ts +139 -0
- package/packages/agentkit-adapter/package.json +57 -0
- package/packages/agentkit-adapter/src/adapter.ts +381 -0
- package/packages/agentkit-adapter/src/index.ts +36 -0
- package/packages/agentkit-adapter/src/types.ts +105 -0
- package/packages/agentkit-adapter/src/util.ts +13 -0
- package/packages/agentkit-adapter/tsconfig.json +22 -0
- package/prometheus.yml +8 -0
- package/python/README.md +92 -65
- package/python/a3m/__init__.py +32 -3
- package/python/a3m/adapters/__init__.py +21 -0
- package/python/a3m/adapters/langchain.py +190 -0
- package/python/a3m/adapters/llamaindex.py +249 -0
- package/python/a3m/adapters/qdrant.py +240 -0
- package/python/a3m/adapters/weaviate.py +263 -0
- package/python/a3m/client.py +5 -0
- package/python/a3m_router.egg-info/PKG-INFO +172 -0
- package/python/a3m_router.egg-info/SOURCES.txt +17 -0
- package/python/a3m_router.egg-info/dependency_links.txt +1 -0
- package/python/a3m_router.egg-info/requires.txt +24 -0
- package/python/a3m_router.egg-info/top_level.txt +1 -0
- package/python/build_verify.sh +32 -0
- package/python/dist/a3m_router-2.2.1-py3-none-any.whl +0 -0
- package/python/dist/a3m_router-2.2.1.tar.gz +0 -0
- package/python/dist/a3m_router-2.2.2-py3-none-any.whl +0 -0
- package/python/dist/a3m_router-2.2.2.tar.gz +0 -0
- package/python/mcp-server/README.md +172 -0
- package/python/mcp-server/a3m_mcp/__init__.py +15 -0
- package/python/mcp-server/a3m_mcp/__main__.py +15 -0
- package/python/mcp-server/a3m_mcp/server.py +339 -0
- package/python/mcp-server/pyproject.toml +24 -0
- package/python/pyproject.toml +56 -5
- package/python/setup.py +3 -28
- package/src/providers/providerConfig.ts +1053 -1
- package/summary.txt +38 -0
- package/tsconfig.build.json +1 -2
package/README.md
CHANGED
|
@@ -1,215 +1,338 @@
|
|
|
1
|
-
#
|
|
1
|
+
# A3M Router
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Intelligent LLM routing across 47+ providers — saves 70-95% on AI costs.**
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
<img src="https://img.shields.io/npm/v/adaptive-memory-multi-model-router?style=flat-square" alt="npm">
|
|
7
|
-
<img src="https://img.shields.io/github/stars/Das-rebel/a3m-router?style=flat-square" alt="stars">
|
|
8
|
-
<img src="https://img.shields.io/npm/dm/adaptive-memory-multi-model-router?style=flat-square" alt="downloads">
|
|
9
|
-
</p>
|
|
5
|
+
A3M Router automatically picks the cheapest capable model for each request. No code changes needed. Just swap your API endpoint.
|
|
10
6
|
|
|
11
7
|
---
|
|
12
8
|
|
|
13
|
-
##
|
|
9
|
+
## TL;DR — What Is This?
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
```
|
|
21
20
|
|
|
22
|
-
|
|
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
|
+
```
|
|
23
30
|
|
|
24
31
|
---
|
|
25
32
|
|
|
26
|
-
##
|
|
33
|
+
## Why A3M Router?
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
| Problem | Solution |
|
|
36
|
+
|---------|----------|
|
|
37
|
+
| GPT-4o is $15/1M tokens | A3M routes simple queries to $0.001/1K providers |
|
|
38
|
+
| Managing 47+ API keys is messy | One endpoint, A3M handles the rest |
|
|
39
|
+
| Provider goes down mid-request | Automatic failover to next best option |
|
|
40
|
+
| Need the best answer, cost doesn't matter | Parallel ensemble calls multiple providers |
|
|
33
41
|
|
|
34
42
|
---
|
|
35
43
|
|
|
36
|
-
##
|
|
44
|
+
## Framework Adapters
|
|
37
45
|
|
|
38
|
-
|
|
46
|
+
A3M Router has drop-in adapters for **8 major frameworks**:
|
|
47
|
+
|
|
48
|
+
| Framework | Adapter | Example |
|
|
49
|
+
|-----------|---------|---------|
|
|
50
|
+
| **LangChain** | `A3MLangChainAdapter` | `pip install adapters/langchain` |
|
|
51
|
+
| **LlamaIndex** | `A3MLlamaIndexAdapter` | `pip install adapters/llamaindex` |
|
|
52
|
+
| **AutoGen** | `A3MAutoGenAdapter` | Multi-agent conversations |
|
|
53
|
+
| **Vercel AI SDK** | `A3MVercelAdapter` | Next.js apps |
|
|
54
|
+
| **Haystack** | `A3MHaystackAdapter` | RAG pipelines |
|
|
55
|
+
| **Pinecone** | `A3MPineconeAdapter` | Vector search + RAG |
|
|
56
|
+
| **LangGraph** | `A3MLangGraphAdapter` | Stateful agents |
|
|
57
|
+
| **CrewAI** | `A3MCompletion` | Multi-agent systems |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Quick Start
|
|
39
62
|
|
|
40
63
|
```bash
|
|
64
|
+
# Install
|
|
41
65
|
npm install adaptive-memory-multi-model-router
|
|
42
|
-
```
|
|
43
66
|
|
|
44
|
-
|
|
45
|
-
|
|
67
|
+
# Start server
|
|
68
|
+
npx a3m-router serve
|
|
69
|
+
```
|
|
46
70
|
|
|
47
|
-
|
|
48
|
-
const router = new A3MRouter({
|
|
49
|
-
model: 'auto',
|
|
50
|
-
stealth: true, // Enable anti-detection
|
|
51
|
-
parallelEnsemble: 3, // Run multiple for reliability
|
|
52
|
-
browserOptimized: true, // Browser-specific optimizations
|
|
53
|
-
});
|
|
71
|
+
---
|
|
54
72
|
|
|
55
|
-
|
|
56
|
-
const result = await router.route({
|
|
57
|
-
task: 'Extract name, email, phone from this job application form',
|
|
58
|
-
context: 'browser_automation',
|
|
59
|
-
});
|
|
73
|
+
## Installation
|
|
60
74
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
### Python Adapters
|
|
76
|
+
```bash
|
|
77
|
+
pip install adapters/
|
|
64
78
|
```
|
|
65
79
|
|
|
66
|
-
###
|
|
67
|
-
|
|
80
|
+
### Docker
|
|
68
81
|
```bash
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
docker-compose up -d
|
|
83
|
+
```
|
|
71
84
|
|
|
72
|
-
|
|
73
|
-
|
|
85
|
+
### npm
|
|
86
|
+
```bash
|
|
87
|
+
npm install adaptive-memory-multi-model-router
|
|
74
88
|
```
|
|
75
89
|
|
|
76
90
|
---
|
|
77
91
|
|
|
78
|
-
##
|
|
92
|
+
## Framework Examples
|
|
79
93
|
|
|
80
|
-
|
|
94
|
+
### LangChain
|
|
95
|
+
```python
|
|
96
|
+
from a3m_adapter import A3MLangChainAdapter
|
|
81
97
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
| Data extraction | claude-sonnet | Good at structure |
|
|
86
|
-
| Complex scraping | gpt-4o | Handles edge cases |
|
|
87
|
-
| Anti-detection | provider_rotation | Automatic |
|
|
98
|
+
llm = A3MLangChainAdapter(model="auto", temperature=0.7)
|
|
99
|
+
result = llm.invoke("What is retrieval-augmented generation?")
|
|
100
|
+
```
|
|
88
101
|
|
|
89
|
-
###
|
|
102
|
+
### LlamaIndex
|
|
103
|
+
```python
|
|
104
|
+
from a3m_adapter import A3MLlamaIndexAdapter
|
|
90
105
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
106
|
+
llm = A3MLlamaIndexAdapter(model="auto")
|
|
107
|
+
response = llm.complete("Explain transformer architecture")
|
|
108
|
+
```
|
|
94
109
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
parallelEnsemble: 3,
|
|
99
|
-
});
|
|
110
|
+
### AutoGen (Microsoft)
|
|
111
|
+
```python
|
|
112
|
+
from a3m_adapter import A3MAutoGenAdapter
|
|
100
113
|
|
|
101
|
-
|
|
102
|
-
const browser = await chromium.launch();
|
|
103
|
-
const page = await browser.newPage();
|
|
104
|
-
|
|
105
|
-
await page.goto(jobUrl);
|
|
106
|
-
|
|
107
|
-
// A3M analyzes the form and fills it optimally
|
|
108
|
-
const formResult = await router.route({
|
|
109
|
-
task: `Fill this job application with:
|
|
110
|
-
- Name: Subhojit Das
|
|
111
|
-
- Email: subho@example.com
|
|
112
|
-
- Phone: +91-7977110915`,
|
|
113
|
-
context: 'form_filling',
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
// Submit and track cost
|
|
117
|
-
await page.click('button[type="submit"]');
|
|
118
|
-
console.log(`Applied! Cost: $${router.getCost()}`);
|
|
119
|
-
|
|
120
|
-
await browser.close();
|
|
121
|
-
}
|
|
122
|
-
```
|
|
114
|
+
llm = A3MAutoGenAdapter(model="auto", parallel_ensemble=2)
|
|
123
115
|
|
|
124
|
-
|
|
116
|
+
config = llm.create_agent_config()
|
|
117
|
+
assistant = ConversableAgent(name="assistant", llm_config=config)
|
|
118
|
+
```
|
|
125
119
|
|
|
126
|
-
|
|
120
|
+
### Vercel AI SDK
|
|
121
|
+
```python
|
|
122
|
+
from a3m_adapter import A3MVercelAdapter, createA3MProvider
|
|
127
123
|
|
|
128
|
-
|
|
124
|
+
result = await generateText({
|
|
125
|
+
model: createA3MProvider({"model": "auto", "parallel_ensemble": 2}),
|
|
126
|
+
prompt: "What is 2+2?",
|
|
127
|
+
})
|
|
128
|
+
```
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
### Haystack (RAG)
|
|
131
|
+
```python
|
|
132
|
+
from a3m_adapter import A3MHaystackAdapter
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
llm: new A3MRouter({ model: 'auto', stealth: true }),
|
|
137
|
-
});
|
|
134
|
+
adapter = A3MHaystackAdapter(model="auto")
|
|
135
|
+
result = adapter.predict(query="What is AI?", documents=retrieved_docs)
|
|
138
136
|
```
|
|
139
137
|
|
|
140
|
-
###
|
|
138
|
+
### Pinecone (Vector Search)
|
|
139
|
+
```python
|
|
140
|
+
from a3m_adapter import A3MPineconeAdapter
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
adapter = A3MPineconeAdapter(model="auto")
|
|
143
|
+
embedding = adapter.embed_query("What is quantum computing?")
|
|
144
|
+
|
|
145
|
+
results = index.query(vector=embedding, top_k=5)
|
|
144
146
|
```
|
|
145
147
|
|
|
146
|
-
|
|
148
|
+
### LangGraph (Stateful Agents)
|
|
149
|
+
```python
|
|
150
|
+
from a3m_adapter import A3MLangGraphAdapter
|
|
151
|
+
|
|
152
|
+
adapter = A3MLangGraphAdapter(model="auto", parallel_ensemble=2)
|
|
153
|
+
agent = create_react_agent(adapter, tools=[...])
|
|
154
|
+
|
|
155
|
+
result = agent.invoke({"messages": [{"role": "user", "content": "Hello"}]})
|
|
156
|
+
```
|
|
147
157
|
|
|
148
|
-
###
|
|
158
|
+
### CrewAI (Multi-Agent)
|
|
159
|
+
```python
|
|
160
|
+
from crewai.llms import A3MCompletion
|
|
149
161
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
162
|
+
researcher = Agent(
|
|
163
|
+
role="Researcher",
|
|
164
|
+
goal="Find accurate information",
|
|
165
|
+
llm=A3MCompletion(model="auto"),
|
|
166
|
+
)
|
|
153
167
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// Ultimate combination for reliable automation
|
|
168
|
+
crew = Crew(agents=[researcher], tasks=[task])
|
|
169
|
+
result = crew.kickoff()
|
|
157
170
|
```
|
|
158
171
|
|
|
159
172
|
---
|
|
160
173
|
|
|
161
|
-
##
|
|
174
|
+
## Parallel Ensemble — Best Answer, Any Provider
|
|
162
175
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
176
|
+
Need the best answer regardless of cost? Call multiple providers in parallel:
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from a3m.router import A3MRouter
|
|
180
|
+
|
|
181
|
+
router = A3MRouter(
|
|
182
|
+
model="auto",
|
|
183
|
+
parallel_ensemble=3, # ← Call 3 providers simultaneously
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
result = router.route(
|
|
187
|
+
messages=[{"role": "user", "content": "Explain quantum entanglement"}],
|
|
188
|
+
ensemble_config={
|
|
189
|
+
"providers": ["groq", "openai", "deepseek"],
|
|
190
|
+
"timeout_ms": 15000,
|
|
191
|
+
"score_weights": {"relevance": 0.4, "conciseness": 0.3, "accuracy": 0.3}
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
print(f"Best answer from: {result.provider}")
|
|
196
|
+
print(f"Response: {result.content}")
|
|
197
|
+
print(f"All scores: {result.scores}")
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Memory & Context
|
|
203
|
+
|
|
204
|
+
A3M Router includes **semantic memory** capabilities:
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
router = A3MRouter(
|
|
208
|
+
model="auto",
|
|
209
|
+
memory={
|
|
210
|
+
"type": "semantic",
|
|
211
|
+
"window": 10,
|
|
212
|
+
"similarity_threshold": 0.85,
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
# First call — caches context
|
|
217
|
+
result1 = router.route(
|
|
218
|
+
messages=[{"role": "user", "content": "I'm building a Python web app"}]
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
# Second call — uses cached context
|
|
222
|
+
result2 = router.route(
|
|
223
|
+
messages=[{"role": "user", "content": "What framework should I use?"}]
|
|
224
|
+
)
|
|
225
|
+
# A3M knows "Python web app" from context
|
|
226
|
+
```
|
|
171
227
|
|
|
172
228
|
---
|
|
173
229
|
|
|
174
230
|
## How Routing Works
|
|
175
231
|
|
|
176
|
-
For every request, A3M
|
|
232
|
+
For every request, A3M analyzes:
|
|
177
233
|
|
|
178
|
-
| Signal |
|
|
179
|
-
|
|
234
|
+
| Signal | Detects |
|
|
235
|
+
|--------|---------|
|
|
180
236
|
| **Domain** | Legal, medical, code, finance, ML keywords |
|
|
181
|
-
| **Task type** | Code
|
|
182
|
-
| **
|
|
237
|
+
| **Task type** | Code, translation, analysis, creative |
|
|
238
|
+
| **Complexity** | Clause count, multi-step markers |
|
|
183
239
|
| **Verb intensity** | "design/architect" → complex, "what/who" → simple |
|
|
184
|
-
| **Multi-step** | Explicit step markers (first...then, step 1/2/3) |
|
|
185
240
|
|
|
186
|
-
|
|
241
|
+
Then maps to a tier:
|
|
242
|
+
|
|
243
|
+
| Tier | Providers | Use When |
|
|
244
|
+
|------|-----------|----------|
|
|
245
|
+
| **Free** | Ollama, Llama.cpp | Experimentation |
|
|
246
|
+
| **Cheap** | Groq, DeepSeek, Mistral | Simple Q&A, short code |
|
|
247
|
+
| **Mid** | GPT-4o-mini, Claude-haiku | Standard tasks |
|
|
248
|
+
| **Premium** | GPT-4o, Claude-sonnet, Gemini | Complex reasoning |
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Cost Comparison
|
|
253
|
+
|
|
254
|
+
| Query Type | GPT-4o Cost | A3M Router Cost | Savings |
|
|
255
|
+
|------------|-------------|-----------------|---------|
|
|
256
|
+
| "What is 2+2?" | $0.03 | $0.0001 (Groq) | **99.7%** |
|
|
257
|
+
| "Write a Python function" | $0.05 | $0.002 (DeepSeek) | **96%** |
|
|
258
|
+
| "Design a database schema" | $0.15 | $0.008 (Mixed) | **95%** |
|
|
259
|
+
| "Complex multi-step reasoning" | $0.15 | $0.15 (GPT-4o) | **0%** (correctly routed) |
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Provider Coverage
|
|
264
|
+
|
|
265
|
+
| Provider | Tiers | Example Models |
|
|
266
|
+
|----------|-------|---------------|
|
|
267
|
+
| OpenAI | Premium, Mid | GPT-4o, GPT-4o-mini |
|
|
268
|
+
| Anthropic | Premium, Mid | Claude-3.5-sonnet, Claude-3-haiku |
|
|
269
|
+
| Google | Premium, Mid | Gemini-1.5-pro, Gemini-1.5-flash |
|
|
270
|
+
| Groq | Cheap | Llama-3.3-70b (fastest) |
|
|
271
|
+
| DeepSeek | Cheap, Mid | DeepSeek-chat, DeepSeek-coder |
|
|
272
|
+
| Mistral | Cheap, Mid | Mistral-large, Mistral-small |
|
|
273
|
+
| NVIDIA | Premium | Nemotron |
|
|
274
|
+
| Ollama | All | Local models |
|
|
275
|
+
| vLLM | All | Self-hosted |
|
|
276
|
+
|
|
277
|
+
**47+ providers total.**
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## CLI Commands
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
npx a3m-router serve # Start server (port 8787)
|
|
285
|
+
npx a3m-router route "query" # See routing decision
|
|
286
|
+
npx a3m-router health # Provider status
|
|
287
|
+
npx a3m-router benchmark # Local accuracy test
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## Architecture
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
Request → Guardrails → Semantic Cache → Router → Provider → Response
|
|
296
|
+
↓
|
|
297
|
+
Memory Layer
|
|
298
|
+
(optional)
|
|
299
|
+
```
|
|
187
300
|
|
|
188
301
|
---
|
|
189
302
|
|
|
190
|
-
##
|
|
303
|
+
## Demo
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
# Start server
|
|
307
|
+
npx a3m-router serve
|
|
191
308
|
|
|
192
|
-
|
|
309
|
+
# Run demo
|
|
310
|
+
python demo.py
|
|
311
|
+
```
|
|
193
312
|
|
|
194
|
-
|
|
313
|
+
---
|
|
195
314
|
|
|
196
|
-
|
|
315
|
+
## Independent Benchmark
|
|
197
316
|
|
|
198
|
-
**
|
|
317
|
+
**RouterArena Evaluation:**
|
|
318
|
+
- **Accuracy:** 96.77%
|
|
319
|
+
- **Cost:** $0.0768/1K tokens
|
|
320
|
+
- **Robustness:** 1.0000
|
|
321
|
+
- **Queries tested:** 8,400
|
|
199
322
|
|
|
200
323
|
---
|
|
201
324
|
|
|
202
|
-
##
|
|
325
|
+
## Project Stats
|
|
203
326
|
|
|
204
|
-
-
|
|
205
|
-
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
- [sota-browser](https://github.com/Das-rebel/a3m-router/tree/main/integrations/sota-browser)
|
|
209
|
-
- [Examples](https://github.com/Das-rebel/a3m-router/tree/main/examples)
|
|
327
|
+
- **npm downloads:** ~5,400/month
|
|
328
|
+
- **Providers:** 47+
|
|
329
|
+
- **Framework adapters:** 8
|
|
330
|
+
- **License:** MIT
|
|
210
331
|
|
|
211
332
|
---
|
|
212
333
|
|
|
213
|
-
##
|
|
334
|
+
## Need Help?
|
|
214
335
|
|
|
215
|
-
|
|
336
|
+
- 📖 [Documentation](docs/)
|
|
337
|
+
- 🐛 [Issues](https://github.com/Das-rebel/a3m-router/issues)
|
|
338
|
+
- 💬 [Discussions](https://github.com/Das-rebel/a3m-router/discussions)
|
package/README_ja.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# A3M Router 🔀 — 成本最优的LLMRouter & 并行执行
|
|
2
2
|
|
|
3
|
-
**💰 $0.0768/1Kリクエスト ·
|
|
3
|
+
**💰 $0.0768/1Kリクエスト · 80+プロバイダー · メモリ付きルーティング**
|
|
4
4
|
|
|
5
5
|
[English](./README.md) | [中文](./README_zh.md) | [日本語](./README_ja.md)
|
|
6
6
|
|
|
@@ -40,7 +40,7 @@ A3M: モデルA ║ モデルB ║ モデルC → スコアリングで最良
|
|
|
40
40
|
- 🔄 **セマンティックキャッシュ** — 30%+ヒット率コスト節約
|
|
41
41
|
- 🛡️ **予算強制** — クエリごとコスト追跡,超過防止
|
|
42
42
|
- ⚡ **高速起動** — <100ms、19.5KB、ML依存なし
|
|
43
|
-
- 🌐 **
|
|
43
|
+
- 🌐 **80+プロバイダー** — OpenAI, Anthropic, DeepSeek, Groq, NVIDIA等
|
|
44
44
|
|
|
45
45
|
## クイックスタート
|
|
46
46
|
|
package/README_zh.md
CHANGED
|
@@ -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,51 @@
|
|
|
1
|
+
"""
|
|
2
|
+
A3M Router Adapters for LLM Frameworks.
|
|
3
|
+
|
|
4
|
+
Provides drop-in adapters to integrate A3M Router with popular frameworks:
|
|
5
|
+
- LangChain (A3MLangChainAdapter)
|
|
6
|
+
- LlamaIndex (A3MLlamaIndexAdapter)
|
|
7
|
+
- AutoGen (A3MAutoGenAdapter)
|
|
8
|
+
- Vercel AI SDK (A3MVercelAdapter)
|
|
9
|
+
- Haystack (A3MHaystackAdapter)
|
|
10
|
+
- Pinecone (A3MPineconeAdapter)
|
|
11
|
+
- LangGraph (A3MLangGraphAdapter)
|
|
12
|
+
- Configuration management (A3MConfig)
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
from a3m_adapter import (
|
|
16
|
+
A3MLangChainAdapter,
|
|
17
|
+
A3MLlamaIndexAdapter,
|
|
18
|
+
A3MAutoGenAdapter,
|
|
19
|
+
A3MVercelAdapter,
|
|
20
|
+
A3MHaystackAdapter,
|
|
21
|
+
A3MPineconeAdapter,
|
|
22
|
+
A3MLangGraphAdapter,
|
|
23
|
+
A3MConfig,
|
|
24
|
+
)
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
from .adapter.langchain import A3MLangChainAdapter
|
|
28
|
+
from .adapter.llamaindex import A3MLlamaIndexAdapter
|
|
29
|
+
from .adapter.autogen import A3MAutoGenAdapter
|
|
30
|
+
from .adapter.vercel import A3MVercelAdapter, createA3MProvider
|
|
31
|
+
from .adapter.haystack import A3MHaystackAdapter
|
|
32
|
+
from .adapter.pinecone import A3MPineconeAdapter
|
|
33
|
+
from .adapter.langgraph import A3MLangGraphAdapter
|
|
34
|
+
from .adapter.config import A3MConfig
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
# Core adapters
|
|
38
|
+
'A3MLangChainAdapter',
|
|
39
|
+
'A3MLlamaIndexAdapter',
|
|
40
|
+
'A3MAutoGenAdapter',
|
|
41
|
+
'A3MVercelAdapter',
|
|
42
|
+
'A3MHaystackAdapter',
|
|
43
|
+
'A3MPineconeAdapter',
|
|
44
|
+
'A3MLangGraphAdapter',
|
|
45
|
+
# Config
|
|
46
|
+
'A3MConfig',
|
|
47
|
+
# Utilities
|
|
48
|
+
'createA3MProvider',
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
__version__ = '2.0.0'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""A3M Router adapter implementations."""
|
|
2
|
+
|
|
3
|
+
from .langchain import A3MLangChainAdapter
|
|
4
|
+
from .llamaindex import A3MLlamaIndexAdapter
|
|
5
|
+
from .autogen import A3MAutoGenAdapter
|
|
6
|
+
from .vercel import A3MVercelAdapter, createA3MProvider
|
|
7
|
+
from .haystack import A3MHaystackAdapter
|
|
8
|
+
from .pinecone import A3MPineconeAdapter
|
|
9
|
+
from .langgraph import A3MLangGraphAdapter
|
|
10
|
+
from .config import A3MConfig
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
'A3MLangChainAdapter',
|
|
14
|
+
'A3MLlamaIndexAdapter',
|
|
15
|
+
'A3MAutoGenAdapter',
|
|
16
|
+
'A3MVercelAdapter',
|
|
17
|
+
'createA3MProvider',
|
|
18
|
+
'A3MHaystackAdapter',
|
|
19
|
+
'A3MPineconeAdapter',
|
|
20
|
+
'A3MLangGraphAdapter',
|
|
21
|
+
'A3MConfig',
|
|
22
|
+
]
|