Spaces:
Sleeping
Sleeping
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.
|