1+ #! /bin/bash
2+ # =============================================================================
3+ # A3M Real Demo - 90 Second Terminal Walkthrough
4+ # =============================================================================
5+ # Shows: routing decision, cost savings, graceful failover
6+ # Requirements: a3m installed (npm install -g adaptive-memory-multi-model-router)
7+ # =============================================================================
8+
9+ set -e
10+
11+ # Colors
12+ RED=' \033[0;31m'
13+ GREEN=' \033[0;32m'
14+ YELLOW=' \033[1;33m'
15+ BLUE=' \033[0;34m'
16+ CYAN=' \033[0;36m'
17+ BOLD=' \033[1m'
18+ RESET=' \033[0m'
19+
20+ # Config - mock providers for demo
21+ DEMO_CONFIG_DIR=" /tmp/a3m-demo-$$ "
22+ mkdir -p " $DEMO_CONFIG_DIR "
23+
24+ # Cleanup on exit
25+ cleanup () { rm -rf " $DEMO_CONFIG_DIR " ; }
26+ trap cleanup EXIT
27+
28+ # Helper functions
29+ type_text () {
30+ echo -ne " ${CYAN} $1 ${RESET} "
31+ }
32+
33+ highlight () {
34+ echo -ne " ${GREEN} $1 ${RESET} "
35+ }
36+
37+ dim () {
38+ echo -ne " ${YELLOW} $1 ${RESET} "
39+ }
40+
41+ section () {
42+ echo " "
43+ echo -e " ${BOLD}${BLUE} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET} "
44+ echo -e " ${BOLD} $1 ${RESET} "
45+ echo -e " ${BLUE} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET} "
46+ echo " "
47+ }
48+
49+ wait_key () {
50+ echo -e " \n${YELLOW} [ Press Enter to continue ]${RESET} "
51+ read -r
52+ }
53+
54+ # =============================================================================
55+ # SCENE 1: Show WITHOUT A3M (manual approach)
56+ # =============================================================================
57+ scene_without_a3m () {
58+ section " SCENE 1: Without A3M — The Hard Way"
59+
60+ echo -e " ${BOLD} Your app code:${RESET} "
61+ echo -e " ${CYAN} // You write this...${RESET} "
62+ cat << 'EOF '
63+ const response = await openai.chat.completions.create({
64+ model: "gpt-4o",
65+ messages: [{ role: "user", content: "Explain quantum entanglement" }]
66+ });
67+ EOF
68+
69+ echo " "
70+ echo -e " ${BOLD} Problems:${RESET} "
71+ echo -e " ${RED} ✗${RESET} Every request costs \$ 0.003–\$ 0.03"
72+ echo -e " ${RED} ✗${RESET} No fallback if OpenAI goes down"
73+ echo -e " ${RED} ✗${RESET} You manage all provider logic"
74+ echo -e " ${RED} ✗${RESET} Manual model selection forever"
75+ echo " "
76+ wait_key
77+ }
78+
79+ # =============================================================================
80+ # SCENE 2: Show WITH A3M (same request, smart routing)
81+ # =============================================================================
82+ scene_with_a3m () {
83+ section " SCENE 2: With A3M — One Line Change"
84+
85+ echo -e " ${BOLD} Your app code:${RESET} "
86+ echo -e " ${CYAN} // Same request...${RESET} "
87+ cat << 'EOF '
88+ const response = await fetch("http://localhost:8787/v1/chat/completions", {
89+ method: "POST",
90+ headers: { "Content-Type": "application/json" },
91+ body: JSON.stringify({
92+ model: "auto", // ← A3M picks the best model
93+ messages: [{ role: "user", content: "Explain quantum entanglement" }]
94+ })
95+ });
96+ EOF
97+
98+ echo " "
99+ echo -e " ${BOLD} A3M analyzes and decides:${RESET} "
100+ echo -e " ${CYAN} Task: explanation${RESET} → ${CYAN} Complexity: simple${RESET} → ${CYAN} Budget: minimize${RESET} "
101+ echo " "
102+ echo -e " ${GREEN} ✓ A3M routes to: Groq (free, fast)${RESET} "
103+ echo -e " ${YELLOW} Cost: \$ 0.00 | Latency: ~800ms${RESET} "
104+ echo " "
105+ wait_key
106+ }
107+
108+ # =============================================================================
109+ # SCENE 3: Show graceful failover
110+ # =============================================================================
111+ scene_failover () {
112+ section " SCENE 3: Graceful Failover — No Downtime"
113+
114+ echo -e " ${BOLD} Groq goes down mid-request...${RESET} "
115+ sleep 1
116+
117+ echo " "
118+ echo -e " ${CYAN} A3M detects failure → circuit breaker trips → failover${RESET} "
119+ echo " "
120+
121+ echo -e " ${YELLOW} [Groq] — FAILED — 503 Service Unavailable${RESET} "
122+ echo -e " ${YELLOW} [DeepSeek] — HEALTHY — Switching...${RESET} "
123+ echo " "
124+
125+ sleep 1
126+ echo -e " ${GREEN} ✓ Response delivered via DeepSeek fallback${RESET} "
127+ echo -e " ${CYAN} Your app: never knew there was a problem${RESET} "
128+ echo " "
129+ wait_key
130+ }
131+
132+ # =============================================================================
133+ # SCENE 4: Show the cost comparison
134+ # =============================================================================
135+ scene_cost () {
136+ section " SCENE 4: Cost Comparison — Real Numbers"
137+
138+ echo -e " ${BOLD} Same query: 'Explain quantum entanglement'${RESET} "
139+ echo " "
140+
141+ echo -e " ${RED} Without A3M${RESET} ${GREEN} With A3M${RESET} "
142+ echo -e " ───────────────── ───────────────"
143+ echo -e " GPT-4o @ \$ 3.00/1K tokens Groq @ \$ 0.00/1K tokens"
144+ echo -e " 500 tokens = \$ 0.0015 500 tokens = \$ 0.00"
145+ echo " "
146+ echo -e " ${BOLD}${GREEN} Savings: 100% per query${RESET} "
147+ echo -e " ${BOLD} At 1000 queries/day: ~\$ 1.50 saved daily${RESET} "
148+ echo " "
149+ wait_key
150+ }
151+
152+ # =============================================================================
153+ # SCENE 5: End with one command
154+ # =============================================================================
155+ scene_end () {
156+ section " ONE COMMAND TO START"
157+
158+ echo -e " ${BOLD} Get A3M Router running in 10 seconds:${RESET} "
159+ echo " "
160+ echo -e " ${CYAN} # 1. Install${RESET} "
161+ echo -e " ${GREEN} npm install -g adaptive-memory-multi-model-router${RESET} "
162+ echo " "
163+ echo -e " ${CYAN} # 2. Start server (auto-detects your API keys)${RESET} "
164+ echo -e " ${GREEN} npx a3m-router serve${RESET} "
165+ echo " "
166+ echo -e " ${CYAN} # 3. That's it — route your first request!${RESET} "
167+ echo " "
168+
169+ echo -e " ${BLUE} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET} "
170+ echo -e " ${BOLD} GitHub: github.com/Das-rebel/adaptive-memory-multi-model-router${RESET} "
171+ echo -e " ${BOLD} npm: npmjs.com/package/adaptive-memory-multi-model-router${RESET} "
172+ echo -e " ${BLUE} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET} "
173+ echo " "
174+ }
175+
176+ # =============================================================================
177+ # MAIN: Run all scenes
178+ # =============================================================================
179+ main () {
180+ clear
181+ echo " "
182+ echo -e " ${BOLD}${BLUE} ╔═══════════════════════════════════════════════════════════╗${RESET} "
183+ echo -e " ${BOLD}${BLUE} ║ ║${RESET} "
184+ echo -e " ${BOLD}${BLUE} ║ A3M Router — 90-Second Demo ║${RESET} "
185+ echo -e " ${BOLD}${BLUE} ║ ║${RESET} "
186+ echo -e " ${BOLD}${BLUE} ║ One prompt in. The right model out. ║${RESET} "
187+ echo -e " ${BOLD}${BLUE} ║ ║${RESET} "
188+ echo -e " ${BOLD}${BLUE} ╚═══════════════════════════════════════════════════════════╝${RESET} "
189+ echo " "
190+
191+ scene_without_a3m
192+ scene_with_a3m
193+ scene_failover
194+ scene_cost
195+ scene_end
196+ }
197+
198+ main " $@ "
0 commit comments