adaptive-memory-multi-model-router 2.13.17 → 2.13.18
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.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Welcome to A3M Router Discussions!
|
|
2
|
+
|
|
3
|
+
## 🎯 What is A3M Router?
|
|
4
|
+
A3M Router is an open-source LLM router that runs queries across **47+ providers in parallel**, scores responses by confidence, and returns the best result. No sequential fallback. No vendor lock-in.
|
|
5
|
+
|
|
6
|
+
## 💬 Discussion Categories
|
|
7
|
+
- **Show and Tell** — Share what you've built with A3M Router
|
|
8
|
+
- **Q&A** — Ask questions about usage, configuration, deployment
|
|
9
|
+
- **Ideas** — Feature requests and suggestions
|
|
10
|
+
- **Announcements** — Release notes and updates
|
|
11
|
+
|
|
12
|
+
## 🔗 Quick Links
|
|
13
|
+
- [GitHub](https://github.com/Das-rebel/a3m-router)
|
|
14
|
+
- [npm](https://www.npmjs.com/package/adaptive-memory-multi-model-router)
|
|
15
|
+
- [Documentation](https://github.com/Das-rebel/a3m-router#readme)
|
|
16
|
+
- [Benchmark Results](https://github.com/Das-rebel/a3m-router/blob/main/docs/BENCHMARK.md)
|
|
17
|
+
|
|
18
|
+
## 🚀 Getting Started
|
|
19
|
+
```bash
|
|
20
|
+
npx a3m-router "What is the meaning of life?"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or install globally:
|
|
24
|
+
```bash
|
|
25
|
+
npm install -g adaptive-memory-multi-model-router
|
|
26
|
+
a3m "Explain quantum computing in simple terms"
|
|
27
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: A3M Router Demo
|
|
3
|
+
emoji: 🔀
|
|
4
|
+
colorFrom: blue
|
|
5
|
+
colorTo: purple
|
|
6
|
+
sdk: gradio
|
|
7
|
+
sdk_version: 5.0.0
|
|
8
|
+
app_file: app.py
|
|
9
|
+
pinned: false
|
|
10
|
+
license: mit
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# A3M Router — Parallel Multi-LLM Execution Demo
|
|
14
|
+
|
|
15
|
+
Try A3M Router's parallel execution: send a query to 3+ LLM providers simultaneously and see which response wins by confidence scoring.
|
|
16
|
+
|
|
17
|
+
## How to use
|
|
18
|
+
1. Enter your prompt
|
|
19
|
+
2. See responses from multiple providers in parallel
|
|
20
|
+
3. View the confidence-scored best result
|
|
21
|
+
|
|
22
|
+
[Learn more on GitHub](https://github.com/Das-rebel/a3m-router)
|
package/hf-space/app.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import gradio as gr
|
|
2
|
+
import json, time, os, httpx
|
|
3
|
+
|
|
4
|
+
# Sample responses for demo (no API keys needed)
|
|
5
|
+
DEMO_RESPONSES = {
|
|
6
|
+
"hello": {
|
|
7
|
+
"GPT-4o mini": "Hello! How can I help you today?",
|
|
8
|
+
"Claude 3.5 Sonnet": "Hi there! I'm ready to assist you with any questions.",
|
|
9
|
+
"Llama 3.3 70B": "Hey! What can I do for you today?",
|
|
10
|
+
},
|
|
11
|
+
"default": {
|
|
12
|
+
"GPT-4o mini": "That's a great question! Here's what I know about it...",
|
|
13
|
+
"Claude 3.5 Sonnet": "I'd be happy to help with that. Let me share some insights...",
|
|
14
|
+
"Llama 3.3 70B": "Great question! Based on my knowledge, here's what I think...",
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
def simulate_parallel(query):
|
|
19
|
+
"""Simulate parallel LLM execution with confidence scoring."""
|
|
20
|
+
responses = DEMO_RESPONSES.get("default")
|
|
21
|
+
if query.lower() in DEMO_RESPONSES:
|
|
22
|
+
responses = DEMO_RESPONSES[query.lower()]
|
|
23
|
+
|
|
24
|
+
results = []
|
|
25
|
+
for provider, response in responses.items():
|
|
26
|
+
# Simulate some delay per provider
|
|
27
|
+
latency = round(0.1 + hash(query + provider) % 300 / 1000, 2)
|
|
28
|
+
confidence = round(0.75 + hash(query + provider) % 20 / 100, 2)
|
|
29
|
+
results.append({
|
|
30
|
+
"provider": provider,
|
|
31
|
+
"response": response,
|
|
32
|
+
"latency": f"{latency}s",
|
|
33
|
+
"confidence": confidence
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
# Sort by confidence
|
|
37
|
+
results.sort(key=lambda x: x["confidence"], reverse=True)
|
|
38
|
+
|
|
39
|
+
return results
|
|
40
|
+
|
|
41
|
+
def process_query(query):
|
|
42
|
+
if not query.strip():
|
|
43
|
+
return "Please enter a query.", "", ""
|
|
44
|
+
|
|
45
|
+
start = time.time()
|
|
46
|
+
results = simulate_parallel(query)
|
|
47
|
+
elapsed = time.time() - start
|
|
48
|
+
|
|
49
|
+
# Format results
|
|
50
|
+
table = "| Provider | Response | Latency | Confidence |\n|----------|----------|---------|------------|\n"
|
|
51
|
+
for r in results:
|
|
52
|
+
table += f"| {r['provider']} | {r['response'][:50]}... | {r['latency']} | {r['confidence']} |\n"
|
|
53
|
+
|
|
54
|
+
winner = results[0]
|
|
55
|
+
summary = f"🏆 **Winner: {winner['provider']}** (confidence: {winner['confidence']})\n\nTotal time: {elapsed:.2f}s | Providers: {len(results)} in parallel\n\n**Best response:** {winner['response']}"
|
|
56
|
+
|
|
57
|
+
return table, summary, json.dumps(results, indent=2)
|
|
58
|
+
|
|
59
|
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
60
|
+
gr.Markdown("# 🔀 A3M Router — Parallel LLM Demo")
|
|
61
|
+
gr.Markdown("See how A3M Router runs multiple providers **in parallel** and picks the best response by confidence scoring.")
|
|
62
|
+
|
|
63
|
+
with gr.Row():
|
|
64
|
+
query = gr.Textbox(label="Your Query", placeholder="Enter a question...", scale=3)
|
|
65
|
+
submit = gr.Button("🚀 Execute", variant="primary", scale=1)
|
|
66
|
+
|
|
67
|
+
with gr.Row():
|
|
68
|
+
with gr.Column():
|
|
69
|
+
gr.Markdown("### 📊 Results Table")
|
|
70
|
+
results_table = gr.Dataframe(
|
|
71
|
+
headers=["Provider", "Response", "Latency", "Confidence"],
|
|
72
|
+
label="Parallel Results"
|
|
73
|
+
)
|
|
74
|
+
with gr.Column():
|
|
75
|
+
gr.Markdown("### 🏆 Best Result")
|
|
76
|
+
best_result = gr.Markdown()
|
|
77
|
+
|
|
78
|
+
with gr.Row():
|
|
79
|
+
with gr.Accordion("Raw JSON Output", open=False):
|
|
80
|
+
raw_output = gr.JSON()
|
|
81
|
+
|
|
82
|
+
gr.Markdown("---\n### ⚡ In production, A3M Router runs on 47+ providers with real API calls")
|
|
83
|
+
gr.Markdown("[📖 GitHub](https://github.com/Das-rebel/a3m-router) | [📦 npm](https://www.npmjs.com/package/adaptive-memory-multi-model-router) | 19.5 KB | Zero ML | MIT")
|
|
84
|
+
|
|
85
|
+
submit.click(
|
|
86
|
+
fn=process_query,
|
|
87
|
+
inputs=query,
|
|
88
|
+
outputs=[results_table, best_result, raw_output]
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
gr.Examples(
|
|
92
|
+
examples=[["Hello, how are you?"], ["What is machine learning?"], ["Explain quantum computing"]],
|
|
93
|
+
inputs=query
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
if __name__ == "__main__":
|
|
97
|
+
demo.launch()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adaptive-memory-multi-model-router",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.18",
|
|
4
4
|
"shortName": "A3M Router",
|
|
5
5
|
"displayName": "A3M Router - Adaptive Memory Multi-Model Router",
|
|
6
6
|
"description": "🔥 Fastest-growing npm LLM router — 0 to 10K downloads in 14 days. Parallel multi-LLM execution with independent benchmark validation (138ms baseline, +96ms proxy overhead), 47+ providers, 99.5% routing accuracy, 62% cost savings. Open-source AI gateway with ensemble voting, semantic cache, budget enforcement. 19.5 KB, zero ML.",
|
|
Binary file
|