Chat_API / README.md
saibhossain's picture
Deploy FastAPI chatbot with multi-mode endpoints
bdae06b
|
Raw History Blame Contribute Delete
3.7 kB
metadata
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

pip install fastapi uvicorn transformers torch accelerate sentencepiece

2️⃣ Run server

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

For Colab:

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

🌐 API Usage

πŸ”Ή General Chat

POST /chat
{
  "message": "Hello, what is AI?",
  "mode": "none"
}

πŸ”Ή English Mode

POST /english
{
  "message": "Correct this sentence: I has a book"
}

πŸ”Ή Bangla Mode

POST /bangla
{
  "message": "বাংলা ব্যাকরণ কি?"
}

πŸ”Ή Math Mode

POST /math
{
  "message": "Solve: 2x + 5 = 15"
}

πŸ”Ή Physics Mode

POST /physics
{
  "message": "Explain Newton's second law"
}

🧾 Response Format

{
  "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/


πŸš€ 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/


⭐ 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.