swordfish7412 commited on
Commit
022559f
·
verified ·
1 Parent(s): 055b656

Add detailed local installation guide for beginners

Browse files
Files changed (1) hide show
  1. INSTALLATION.md +727 -0
INSTALLATION.md ADDED
@@ -0,0 +1,727 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Amihan 1.2 - Complete Local Installation Guide
2
+
3
+ **For Complete Beginners - Step by Step**
4
+
5
+ This guide will help you run Amihan (and optionally Bandila + Amigo) on your own computer.
6
+
7
+ ---
8
+
9
+ ## What You're Installing
10
+
11
+ **Amihan 1.2** - The intelligent orchestrator that coordinates between specialists.
12
+
13
+ **Optional Specialists:**
14
+ - **Bandila 1.0** - Reasoning specialist (for architecture, DevOps, strategy)
15
+ - **Amigo 1.0** - Coding specialist (for programming, debugging, algorithms)
16
+
17
+ **Note:** You can run Amihan alone, or with the full Trio for better results.
18
+
19
+ ---
20
+
21
+ ## System Requirements
22
+
23
+ ### Minimum (Amihan Only):
24
+ - 8GB RAM
25
+ - 10GB free disk space
26
+ - Any CPU (Intel, AMD, Apple Silicon)
27
+ - Internet connection (for initial download)
28
+
29
+ ### Recommended (Full Trio):
30
+ - 16GB RAM (32GB ideal)
31
+ - 30GB free disk space
32
+ - NVIDIA GPU with 8GB+ VRAM (optional, makes it faster)
33
+ - Internet connection
34
+
35
+ ### Operating Systems:
36
+ - Windows 10/11
37
+ - macOS (Intel or Apple Silicon M1/M2/M3)
38
+ - Linux (Ubuntu, Fedora, Debian, etc.)
39
+
40
+ ---
41
+
42
+ ## Installation Steps
43
+
44
+ ### Step 1: Install Python
45
+
46
+ Python is the programming language needed to run the models.
47
+
48
+ #### Windows:
49
+ 1. Go to: https://www.python.org/downloads/
50
+ 2. Click the big yellow "Download Python 3.11" button
51
+ 3. Run the downloaded file
52
+ 4. **IMPORTANT**: Check the box "Add Python to PATH"
53
+ 5. Click "Install Now"
54
+ 6. Wait for installation to complete
55
+ 7. Click "Close"
56
+
57
+ #### macOS:
58
+ Open Terminal (Applications → Utilities → Terminal) and paste:
59
+ ```bash
60
+ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
61
+ brew install python@3.11
62
+ ```
63
+
64
+ #### Linux (Ubuntu/Debian):
65
+ Open Terminal and paste:
66
+ ```bash
67
+ sudo apt update
68
+ sudo apt install python3.11 python3.11-venv python3-pip git
69
+ ```
70
+
71
+ #### Linux (Fedora):
72
+ ```bash
73
+ sudo dnf install python3.11 python3-pip git
74
+ ```
75
+
76
+ **Verify Python is installed:**
77
+ Open Terminal/Command Prompt and type:
78
+ ```bash
79
+ python --version
80
+ ```
81
+ You should see: `Python 3.11.x` or similar.
82
+
83
+ If you see "command not found", try:
84
+ ```bash
85
+ python3 --version
86
+ ```
87
+
88
+ ---
89
+
90
+ ### Step 2: Create a Project Folder
91
+
92
+ This is where all the AI models will be stored.
93
+
94
+ #### Windows:
95
+ 1. Open File Explorer
96
+ 2. Go to your Documents folder
97
+ 3. Right-click in empty space
98
+ 4. Click "New" → "Folder"
99
+ 5. Name it: `amihan-ai`
100
+ 6. Open Command Prompt:
101
+ - Press `Windows Key + R`
102
+ - Type: `cmd`
103
+ - Press Enter
104
+ 7. Type this and press Enter:
105
+ ```cmd
106
+ cd %USERPROFILE%\Documents\amihan-ai
107
+ ```
108
+
109
+ #### macOS/Linux:
110
+ Open Terminal and paste:
111
+ ```bash
112
+ mkdir ~/amihan-ai
113
+ cd ~/amihan-ai
114
+ ```
115
+
116
+ ---
117
+
118
+ ### Step 3: Set Up Python Environment
119
+
120
+ This creates an isolated space for the AI models.
121
+
122
+ **Copy and paste this entire block** into your Terminal/Command Prompt:
123
+
124
+ #### Windows:
125
+ ```cmd
126
+ python -m venv venv
127
+ venv\Scripts\activate
128
+ ```
129
+
130
+ #### macOS/Linux:
131
+ ```bash
132
+ python3 -m venv venv
133
+ source venv/bin/activate
134
+ ```
135
+
136
+ You should now see `(venv)` at the start of your command line.
137
+
138
+ ---
139
+
140
+ ### Step 4: Install Required Software
141
+
142
+ **Copy and paste this** (it will take 5-10 minutes):
143
+
144
+ ```bash
145
+ pip install --upgrade pip
146
+ pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
147
+ pip install transformers peft accelerate gradio huggingface-hub bitsandbytes
148
+ ```
149
+
150
+ **If you have an NVIDIA GPU** (for faster performance), use this instead:
151
+ ```bash
152
+ pip install --upgrade pip
153
+ pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
154
+ pip install transformers peft accelerate gradio huggingface-hub bitsandbytes
155
+ ```
156
+
157
+ **Wait for it to finish.** You'll see lots of text scrolling. This is normal.
158
+
159
+ ---
160
+
161
+ ### Step 5: Download the Models
162
+
163
+ You have two options: Amihan only, or the full Trio.
164
+
165
+ #### Option A: Amihan Only (Faster, Smaller)
166
+
167
+ Create a file called `download_amihan.py`:
168
+
169
+ **Windows:** Right-click in folder → New → Text Document → Rename to `download_amihan.py`
170
+
171
+ **macOS/Linux:** In Terminal, type: `nano download_amihan.py`
172
+
173
+ **Paste this code:**
174
+
175
+ ```python
176
+ from huggingface_hub import snapshot_download
177
+ import os
178
+
179
+ print("=" * 60)
180
+ print("DOWNLOADING AMIHAN 1.2")
181
+ print("=" * 60)
182
+ print()
183
+ print("This will download about 8GB of data.")
184
+ print("Estimated time: 10-20 minutes (depends on internet speed)")
185
+ print()
186
+
187
+ # Create models directory
188
+ os.makedirs("models", exist_ok=True)
189
+
190
+ # Download Amihan orchestrator model
191
+ print("Downloading Amihan 1.2 (Phi-3-mini + LoRA adapter)...")
192
+ snapshot_download(
193
+ repo_id="swordfish7412/Amihan_1.2",
194
+ local_dir="models/amihan",
195
+ local_dir_use_symlinks=False
196
+ )
197
+
198
+ print()
199
+ print("=" * 60)
200
+ print("AMIHAN 1.2 DOWNLOADED SUCCESSFULLY!")
201
+ print("=" * 60)
202
+ print()
203
+ print("Next step: Run 'python run_amihan.py'")
204
+ ```
205
+
206
+ Save and close. Then run:
207
+ ```bash
208
+ python download_amihan.py
209
+ ```
210
+
211
+ #### Option B: Full Trio (Amihan + Bandila + Amigo)
212
+
213
+ Create a file called `download_trio.py`:
214
+
215
+ ```python
216
+ from huggingface_hub import snapshot_download
217
+ import os
218
+
219
+ print("=" * 60)
220
+ print("DOWNLOADING SWORDFISH AI TRIO")
221
+ print("=" * 60)
222
+ print()
223
+ print("This will download about 28GB of data.")
224
+ print("Estimated time: 30-60 minutes (depends on internet speed)")
225
+ print()
226
+
227
+ # Create models directory
228
+ os.makedirs("models", exist_ok=True)
229
+
230
+ # Download Amihan
231
+ print("1/3 Downloading Amihan 1.2 (Orchestrator)...")
232
+ snapshot_download(
233
+ repo_id="swordfish7412/Amihan_1.2",
234
+ local_dir="models/amihan",
235
+ local_dir_use_symlinks=False
236
+ )
237
+ print("✓ Amihan downloaded!")
238
+ print()
239
+
240
+ # Download Bandila
241
+ print("2/3 Downloading Bandila 1.0 (Reasoning Specialist)...")
242
+ snapshot_download(
243
+ repo_id="swordfish7412/Bandila_1.0",
244
+ local_dir="models/bandila",
245
+ local_dir_use_symlinks=False
246
+ )
247
+ print("✓ Bandila downloaded!")
248
+ print()
249
+
250
+ # Download Amigo
251
+ print("3/3 Downloading Amigo 1.0 (Coding Specialist)...")
252
+ snapshot_download(
253
+ repo_id="swordfish7412/Amigo_1.0",
254
+ local_dir="models/amigo",
255
+ local_dir_use_symlinks=False
256
+ )
257
+ print("✓ Amigo downloaded!")
258
+ print()
259
+
260
+ print("=" * 60)
261
+ print("ALL MODELS DOWNLOADED SUCCESSFULLY!")
262
+ print("=" * 60)
263
+ print()
264
+ print("Next step: Run 'python run_trio.py'")
265
+ ```
266
+
267
+ Save and run:
268
+ ```bash
269
+ python download_trio.py
270
+ ```
271
+
272
+ **Go make coffee.** This takes a while.
273
+
274
+ ---
275
+
276
+ ### Step 6: Create the Run Script
277
+
278
+ #### Option A: Run Amihan Only
279
+
280
+ Create a file called `run_amihan.py`:
281
+
282
+ ```python
283
+ """
284
+ Amihan 1.2 - Standalone Mode
285
+ Runs without Bandila and Amigo specialists
286
+ """
287
+
288
+ import torch
289
+ from transformers import AutoTokenizer, AutoModelForCausalLM
290
+ from peft import PeftModel
291
+ import gradio as gr
292
+
293
+ print("=" * 60)
294
+ print("LOADING AMIHAN 1.2 - STANDALONE MODE")
295
+ print("=" * 60)
296
+ print()
297
+
298
+ # Detect device
299
+ device = "cuda" if torch.cuda.is_available() else "cpu"
300
+ print(f"Device: {device}")
301
+ print()
302
+
303
+ # Load Amihan orchestrator model
304
+ print("Loading Amihan 1.2 (Phi-3-mini + LoRA)...")
305
+ MODEL_NAME = "microsoft/Phi-3-mini-4k-instruct"
306
+
307
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, trust_remote_code=True)
308
+ tokenizer.pad_token = tokenizer.eos_token
309
+
310
+ base_model = AutoModelForCausalLM.from_pretrained(
311
+ MODEL_NAME,
312
+ torch_dtype=torch.float16 if device == "cuda" else torch.float32,
313
+ device_map="auto",
314
+ trust_remote_code=True,
315
+ low_cpu_mem_usage=True
316
+ )
317
+
318
+ model = PeftModel.from_pretrained(base_model, "models/amihan")
319
+ model.eval()
320
+
321
+ print("✓ Amihan loaded!")
322
+ print()
323
+ print("=" * 60)
324
+ print("AMIHAN 1.2 READY!")
325
+ print("=" * 60)
326
+ print()
327
+
328
+ def generate_response(message):
329
+ """Generate response using Amihan's brain"""
330
+ prompt = f"""You are Amihan, an intelligent AI assistant. Answer this question:
331
+
332
+ Question: {message}
333
+
334
+ Provide a helpful, detailed response.
335
+
336
+ Response:"""
337
+
338
+ inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=1024)
339
+ inputs = {k: v.to(model.device) for k, v in inputs.items()}
340
+
341
+ with torch.no_grad():
342
+ outputs = model.generate(
343
+ **inputs,
344
+ max_new_tokens=512,
345
+ temperature=0.7,
346
+ top_p=0.9,
347
+ do_sample=True,
348
+ pad_token_id=tokenizer.eos_token_id
349
+ )
350
+
351
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
352
+
353
+ if "Response:" in response:
354
+ response = response.split("Response:")[-1].strip()
355
+
356
+ return response
357
+
358
+ def chat(message, history):
359
+ """Chat function for Gradio"""
360
+ if not message.strip():
361
+ return "Please enter a message."
362
+
363
+ response = generate_response(message)
364
+ return response
365
+
366
+ # Create Gradio interface
367
+ with gr.Blocks(theme=gr.themes.Soft(), title="Amihan 1.2 - Standalone") as demo:
368
+ gr.Markdown("""
369
+ # Amihan 1.2 - Standalone Mode
370
+
371
+ **Running locally on your computer**
372
+
373
+ Amihan is running in standalone mode without the specialist models.
374
+ For full Trio capabilities, download and run Bandila + Amigo.
375
+
376
+ Ask any technical question!
377
+ """)
378
+
379
+ chatbot = gr.Chatbot(height=500, show_label=False)
380
+
381
+ with gr.Row():
382
+ msg = gr.Textbox(
383
+ placeholder="Ask me anything...",
384
+ show_label=False,
385
+ scale=4
386
+ )
387
+ submit = gr.Button("Send", scale=1, variant="primary")
388
+
389
+ gr.Examples(
390
+ examples=[
391
+ "What is your name?",
392
+ "Explain microservices architecture",
393
+ "Write a Python function to sort a list"
394
+ ],
395
+ inputs=msg
396
+ )
397
+
398
+ def respond(message, chat_history):
399
+ bot_message = chat(message, chat_history)
400
+ chat_history.append((message, bot_message))
401
+ return "", chat_history
402
+
403
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
404
+ submit.click(respond, [msg, chatbot], [msg, chatbot])
405
+
406
+ if __name__ == "__main__":
407
+ print("Starting Gradio interface...")
408
+ print("Open your browser and go to: http://localhost:7860")
409
+ print()
410
+ demo.launch(server_name="127.0.0.1", server_port=7860, share=False)
411
+ ```
412
+
413
+ #### Option B: Run Full Trio
414
+
415
+ Create a file called `run_trio.py`:
416
+
417
+ ```python
418
+ """
419
+ Swordfish AI Trio - Complete Local Installation
420
+ Amihan + Bandila + Amigo working together
421
+ """
422
+
423
+ import torch
424
+ from transformers import AutoTokenizer, AutoModelForCausalLM
425
+ from peft import PeftModel
426
+ import gradio as gr
427
+
428
+ print("=" * 60)
429
+ print("LOADING SWORDFISH AI TRIO")
430
+ print("=" * 60)
431
+ print()
432
+ print("This may take 3-5 minutes on first run...")
433
+ print()
434
+
435
+ # Detect device
436
+ device = "cuda" if torch.cuda.is_available() else "cpu"
437
+ print(f"Device: {device}")
438
+ print()
439
+
440
+ # Load Amihan (Orchestrator)
441
+ print("1/3 Loading Amihan 1.2 (Orchestrator)...")
442
+ amihan_tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True)
443
+ amihan_tokenizer.pad_token = amihan_tokenizer.eos_token
444
+
445
+ amihan_base = AutoModelForCausalLM.from_pretrained(
446
+ "microsoft/Phi-3-mini-4k-instruct",
447
+ torch_dtype=torch.float16 if device == "cuda" else torch.float32,
448
+ device_map="auto",
449
+ trust_remote_code=True,
450
+ low_cpu_mem_usage=True
451
+ )
452
+ amihan_model = PeftModel.from_pretrained(amihan_base, "models/amihan")
453
+ amihan_model.eval()
454
+ print("✓ Amihan loaded!")
455
+ print()
456
+
457
+ # Load Bandila (Reasoning Specialist)
458
+ print("2/3 Loading Bandila 1.0 (Reasoning)...")
459
+ bandila_base = AutoModelForCausalLM.from_pretrained(
460
+ "mistralai/Mistral-7B-v0.1",
461
+ torch_dtype=torch.float16 if device == "cuda" else torch.float32,
462
+ device_map="auto",
463
+ low_cpu_mem_usage=True
464
+ )
465
+ bandila_model = PeftModel.from_pretrained(bandila_base, "models/bandila")
466
+ bandila_tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1")
467
+ bandila_tokenizer.pad_token = bandila_tokenizer.eos_token
468
+ bandila_model.eval()
469
+ print("✓ Bandila loaded!")
470
+ print()
471
+
472
+ # Load Amigo (Coding Specialist)
473
+ print("3/3 Loading Amigo 1.0 (Coding)...")
474
+ amigo_base = AutoModelForCausalLM.from_pretrained(
475
+ "codellama/CodeLlama-7b-hf",
476
+ torch_dtype=torch.float16 if device == "cuda" else torch.float32,
477
+ device_map="auto",
478
+ low_cpu_mem_usage=True
479
+ )
480
+ amigo_model = PeftModel.from_pretrained(amigo_base, "models/amigo")
481
+ amigo_tokenizer = AutoTokenizer.from_pretrained("codellama/CodeLlama-7b-hf")
482
+ amigo_tokenizer.pad_token = amigo_tokenizer.eos_token
483
+ amigo_model.eval()
484
+ print("✓ Amigo loaded!")
485
+ print()
486
+
487
+ print("=" * 60)
488
+ print("SWORDFISH AI TRIO READY!")
489
+ print("=" * 60)
490
+ print()
491
+
492
+ # Routing logic
493
+ CODING_KEYWORDS = [
494
+ 'code', 'function', 'class', 'method', 'algorithm', 'program', 'script',
495
+ 'debug', 'error', 'bug', 'fix', 'implement', 'write', 'create',
496
+ 'python', 'javascript', 'java', 'c++', 'rust', 'go', 'sql',
497
+ 'api', 'endpoint', 'route', 'controller', 'model', 'view'
498
+ ]
499
+
500
+ def route_request(message):
501
+ """Use Amihan to decide which specialist to use"""
502
+ message_lower = message.lower()
503
+
504
+ # Check for coding keywords
505
+ coding_score = sum(1 for kw in CODING_KEYWORDS if kw in message_lower)
506
+
507
+ if coding_score >= 2:
508
+ return "amigo"
509
+ elif any(word in message_lower for word in ['architecture', 'design', 'strategy', 'devops', 'infrastructure']):
510
+ return "bandila"
511
+ elif 'write' in message_lower or 'create' in message_lower:
512
+ return "amigo"
513
+ else:
514
+ return "bandila"
515
+
516
+ def generate_response(model, tokenizer, message):
517
+ """Generate response from a specialist model"""
518
+ prompt = f"### Instruction:\n{message}\n\n### Response:\n"
519
+
520
+ inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=2048)
521
+ inputs = {k: v.to(model.device) for k, v in inputs.items()}
522
+
523
+ with torch.no_grad():
524
+ outputs = model.generate(
525
+ **inputs,
526
+ max_new_tokens=512,
527
+ temperature=0.7,
528
+ top_p=0.9,
529
+ do_sample=True,
530
+ pad_token_id=tokenizer.eos_token_id
531
+ )
532
+
533
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
534
+
535
+ if "### Response:" in response:
536
+ response = response.split("### Response:")[-1].strip()
537
+
538
+ return response
539
+
540
+ def chat(message, history):
541
+ """Main chat function - routes to appropriate specialist"""
542
+ if not message.strip():
543
+ return "Please enter a message."
544
+
545
+ # Route the request
546
+ specialist = route_request(message)
547
+
548
+ if specialist == "amigo":
549
+ print(f"→ Routing to Amigo (Coding)")
550
+ response = generate_response(amigo_model, amigo_tokenizer, message)
551
+ return f"**[Amigo - Coding Specialist]**\n\n{response}"
552
+ else:
553
+ print(f"→ Routing to Bandila (Reasoning)")
554
+ response = generate_response(bandila_model, bandila_tokenizer, message)
555
+ return f"**[Bandila - Reasoning Specialist]**\n\n{response}"
556
+
557
+ # Create Gradio interface
558
+ with gr.Blocks(theme=gr.themes.Soft(), title="Swordfish AI Trio") as demo:
559
+ gr.Markdown("""
560
+ # Swordfish AI Trio - Local Installation
561
+
562
+ **Running locally on your computer**
563
+
564
+ **Amihan 1.2:** Intelligent orchestrator
565
+ **Bandila 1.0:** Reasoning specialist
566
+ **Amigo 1.0:** Coding specialist
567
+
568
+ Ask any technical question - Amihan will route it to the right specialist!
569
+ """)
570
+
571
+ chatbot = gr.Chatbot(height=500, show_label=False)
572
+
573
+ with gr.Row():
574
+ msg = gr.Textbox(
575
+ placeholder="Ask about code, architecture, DevOps...",
576
+ show_label=False,
577
+ scale=4
578
+ )
579
+ submit = gr.Button("Send", scale=1, variant="primary")
580
+
581
+ gr.Examples(
582
+ examples=[
583
+ "What is your name?",
584
+ "Write a Python function to calculate Fibonacci",
585
+ "Explain microservices architecture best practices",
586
+ "Debug this code: def add(a,b) return a+b"
587
+ ],
588
+ inputs=msg
589
+ )
590
+
591
+ def respond(message, chat_history):
592
+ bot_message = chat(message, chat_history)
593
+ chat_history.append((message, bot_message))
594
+ return "", chat_history
595
+
596
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
597
+ submit.click(respond, [msg, chatbot], [msg, chatbot])
598
+
599
+ if __name__ == "__main__":
600
+ print("Starting Gradio interface...")
601
+ print("Open your browser and go to: http://localhost:7860")
602
+ print()
603
+ demo.launch(server_name="127.0.0.1", server_port=7860, share=False)
604
+ ```
605
+
606
+ ---
607
+
608
+ ### Step 7: Run It!
609
+
610
+ **For Amihan Only:**
611
+ ```bash
612
+ python run_amihan.py
613
+ ```
614
+
615
+ **For Full Trio:**
616
+ ```bash
617
+ python run_trio.py
618
+ ```
619
+
620
+ **First run takes 2-5 minutes to load models into memory.**
621
+
622
+ When you see:
623
+ ```
624
+ AMIHAN 1.2 READY!
625
+ Running on local URL: http://127.0.0.1:7860
626
+ ```
627
+
628
+ **Open your browser and go to:** http://localhost:7860
629
+
630
+ ---
631
+
632
+ ## Usage Tips
633
+
634
+ ### Response Times:
635
+ - **With GPU**: 2-5 seconds per response
636
+ - **Without GPU (CPU)**: 30-90 seconds per response
637
+
638
+ ### Best Questions:
639
+ - "Write a Python function to..."
640
+ - "Explain the concept of..."
641
+ - "How do I design a..."
642
+ - "Debug this code: [paste code]"
643
+
644
+ ### Stopping the Server:
645
+ Press `Ctrl + C` in the Terminal/Command Prompt
646
+
647
+ ### Running Again:
648
+ 1. Open Terminal/Command Prompt
649
+ 2. Navigate to folder: `cd ~/amihan-ai` (or `cd %USERPROFILE%\Documents\amihan-ai` on Windows)
650
+ 3. Activate environment: `source venv/bin/activate` (or `venv\Scripts\activate` on Windows)
651
+ 4. Run: `python run_amihan.py` or `python run_trio.py`
652
+
653
+ ---
654
+
655
+ ## Troubleshooting
656
+
657
+ ### "Out of memory" error:
658
+ Your system doesn't have enough RAM. Try:
659
+ 1. Close other applications
660
+ 2. Run Amihan only (not full Trio)
661
+ 3. Restart your computer and try again
662
+
663
+ ### "torch not found" error:
664
+ Reinstall PyTorch:
665
+ ```bash
666
+ pip uninstall torch
667
+ pip install torch --index-url https://download.pytorch.org/whl/cpu
668
+ ```
669
+
670
+ ### Very slow responses:
671
+ This is normal on CPU. To speed up:
672
+ 1. Get a computer with NVIDIA GPU
673
+ 2. Or use the online version: https://huggingface.co/spaces/swordfish7412/Amihan
674
+
675
+ ### "Python command not found":
676
+ Try using `python3` instead of `python`:
677
+ ```bash
678
+ python3 run_amihan.py
679
+ ```
680
+
681
+ ---
682
+
683
+ ## Uninstalling
684
+
685
+ To remove everything:
686
+
687
+ 1. Deactivate environment:
688
+ ```bash
689
+ deactivate
690
+ ```
691
+
692
+ 2. Delete the folder:
693
+ - **Windows**: Delete `Documents\amihan-ai` folder
694
+ - **macOS/Linux**: `rm -rf ~/amihan-ai`
695
+
696
+ ---
697
+
698
+ ## Getting Help
699
+
700
+ - **Online Demo**: https://huggingface.co/spaces/swordfish7412/Amihan
701
+ - **Model Page**: https://huggingface.co/swordfish7412/Amihan_1.2
702
+ - **Email**: janfrancisisrael@gmail.com
703
+
704
+ ---
705
+
706
+ ## Summary
707
+
708
+ **Easiest Option:**
709
+ Just use online: https://huggingface.co/spaces/swordfish7412/Amihan
710
+
711
+ **Local Installation Steps:**
712
+ 1. Install Python 3.11
713
+ 2. Create project folder
714
+ 3. Set up virtual environment
715
+ 4. Install dependencies (5-10 min)
716
+ 5. Download models (10-60 min depending on option)
717
+ 6. Run the script
718
+ 7. Open http://localhost:7860
719
+
720
+ **Total Time:** 30-90 minutes (mostly downloading)
721
+
722
+ ---
723
+
724
+ **Created by:** Jan Israel
725
+ **Part of:** The Swordfish Project
726
+ **Version:** 1.2 (November 2025)
727
+