File size: 3,701 Bytes
f21759d
 
 
 
 
 
bdae06b
f21759d
 
 
 
 
fc2ec8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25b98ba
fc2ec8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25b98ba
 
fc2ec8a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224

---
title: Chat API - Multi Mode AI
emoji: πŸ€–
colorFrom: blue
colorTo: purple
sdk: docker
app_file: app.py
pinned: false
---


# πŸ€– Multimodal AI Chatbot API (FastAPI + Hugging Face + Qwen2.5)

This project is a **FastAPI-based AI chatbot backend** designed for deployment on **Google Colab + Hugging Face Spaces**. It uses a lightweight LLM (`Qwen2.5-1.5B-Instruct`) and provides multiple domain-specific AI endpoints.


## πŸš€ Features

* ⚑ FastAPI backend for high-performance inference
* 🧠 Powered by `Qwen2.5-1.5B-Instruct` (lightweight LLM)
* 🌐 Multiple specialized AI modes:

  * English assistant
  * Bangla assistant
  * Math solver
  * Physics tutor
* πŸ”— REST API ready for frontend integration
* πŸ“¦ Hugging Face / Colab deployment friendly

---

## πŸ“ Project Structure

```
main.py        # FastAPI backend
requirements.txt
README.md
```

---

## 🧠 AI Modes / Endpoints

| Mode    | Endpoint   | Description                       |
| ------- | ---------- | --------------------------------- |
| General | `/chat`    | General AI assistant              |
| English | `/english` | Grammar, writing, correction      |
| Bangla  | `/bangla`  | Bangla language assistant         |
| Math    | `/math`    | Step-by-step problem solving      |
| Physics | `/physics` | Physics explanations & numericals |

---

## βš™οΈ Installation (Local / Colab)

### 1️⃣ Install dependencies

```bash
pip install fastapi uvicorn transformers torch accelerate sentencepiece
```

---

### 2️⃣ Run server

```bash
uvicorn main:app --host 0.0.0.0 --port 8000
```

For Colab:

```bash
nohup uvicorn main:app --host 0.0.0.0 --port 8000 &
```

---

## 🌐 API Usage

### πŸ”Ή General Chat

```bash
POST /chat
```

```json
{
  "message": "Hello, what is AI?",
  "mode": "none"
}
```

---

### πŸ”Ή English Mode

```bash
POST /english
```

```json
{
  "message": "Correct this sentence: I has a book"
}
```

---

### πŸ”Ή Bangla Mode

```bash
POST /bangla
```

```json
{
  "message": "বাংলা ব্যাকরণ কি?"
}
```

---

### πŸ”Ή Math Mode

```bash
POST /math
```

```json
{
  "message": "Solve: 2x + 5 = 15"
}
```

---

### πŸ”Ή Physics Mode

```bash
POST /physics
```

```json
{
  "message": "Explain Newton's second law"
}
```

---

## 🧾 Response Format

```json
{
  "mode": "math",
  "response": "Step-by-step solution..."
}
```

---

## πŸ“Œ Disclaimer (Included in every response)

Each response automatically includes:

> The chat interface is built by MD Saib Hossain.
> For AI systems, RAG pipelines, or Agentic AI development contact:
> [https://www.linkedin.com/in/saib-hossain-182834229/](https://www.linkedin.com/in/saib-hossain-182834229/)

---

## πŸš€ Deployment (Hugging Face Spaces)

1. Create a new Space
2. Choose **Docker or Gradio SDK**
3. Upload `main.py`
4. Set runtime to Python 3.10+
5. Add dependencies in `requirements.txt`

---

## πŸ”₯ Tech Stack

* FastAPI
* Hugging Face Transformers
* PyTorch
* Qwen2.5 LLM
* Google Colab (for development)

---

## πŸ“ˆ Future Improvements

* πŸ”₯ Streaming responses (token-by-token)
* πŸ”₯ LangGraph-based routing
* πŸ”₯ RAG integration (PDF + web data)
* πŸ”₯ Memory-based chat system
* πŸ”₯ Frontend React UI integration

---

## πŸ‘¨β€πŸ’» Author

**MD Saib Hossain**
AI/ML Engineer | Agentic AI & RAG Systems Builder

πŸ”— LinkedIn: [https://www.linkedin.com/in/saib-hossain-182834229/](https://www.linkedin.com/in/saib-hossain-182834229/)

---

## ⭐ If you like this project

You can extend it into:

* AI tutor system
* Multilingual chatbot
* Exam preparation assistant
* Medical/education RAG system

---

πŸš€ Built for scalable AI experimentation on lightweight infrastructure.