sankya — a modern, ChatGPT-style AI assistant that runs entirely locally using open-source Hugging Face models. No cloud APIs, no API keys required for the core model.
- What is This?
- Features
- Prerequisites
- Installation
- Configuration
- Running the App
- Verifying Installation
- Using the App
- Development Mode
- Project Structure
- Troubleshooting
- FAQ
This is sankya, a fully local AI assistant that runs on your own machine. It uses:
- Qwen2.5-1.5B-Instruct - A powerful open-source language model
- FastAPI - Modern Python backend
- React - Beautiful frontend interface
- Docker - Easy deployment with GPU support
No internet required after first download. No API keys. No subscriptions.
| Feature | Description |
|---|---|
| 💬 Local LLM | Qwen2.5-1.5B-Instruct runs on your GPU/CPU |
| ⚡ Streaming | Real-time token-by-token responses like ChatGPT |
| 🛠️ AI Tools | Date/time, calculator, weather, web search |
| 📄 RAG | Upload PDFs/DOCX and ask questions about them |
| 💾 Memory | Persistent conversations and user preferences |
| 🎨 Dark/Light Mode | Beautiful ChatGPT-style UI with theme toggle |
| 🔍 Search | Search through your conversation history |
| 📱 Responsive | Works on desktop, tablet, and mobile |
- OS: Windows 10/11, macOS 12+, or Linux
- RAM: 8GB (16GB recommended)
- GPU: NVIDIA GPU with 4GB+ VRAM (optional, but recommended)
- Disk: 10GB free space
- Docker: Docker Desktop with NVIDIA Container Toolkit (for GPU)
The app works on CPU only, but responses will be slower (~5-10 seconds per message).
This is the easiest method and works on Windows, Mac, and Linux.
Windows:
- Install Docker Desktop
- Go to Settings → Resources → WSL Integration → Enable
- Restart Docker Desktop
Mac:
brew install --cask dockerLinux:
sudo apt update
sudo apt install docker.io docker-compose
sudo systemctl start docker
sudo systemctl enable docker- Install NVIDIA Container Toolkit
- Verify GPU access:
docker run --rm --gpus all nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 nvidia-smiMac users: Skip this step. Apple Silicon uses different architecture.
git clone https://github.com/Mohitverma-code7/sankya.git
cd ai-chatbotCreate a .env file in the backend folder:
# Windows (PowerShell)
Copy-Item backend\.env.example backend\.env
# Mac/Linux
cp backend/.env.example backend/.envEdit backend/.env:
# Database
DATABASE_URL=sqlite:///./chatbot.db
# Optional: API keys (leave empty if not needed)
HF_TOKEN=
TAVILY_API_KEY=
SEARCH_API_KEY=
WEATHER_API_KEY=
# Model settings
MODEL_NAME=Qwen/Qwen2.5-1.5B-Instruct
MAX_NEW_TOKENS=256
TEMPERATURE=0.3
# Server
PORT=8000
ENVIRONMENT=productiondocker compose up --buildFirst run will take 10-15 minutes to:
- Build the CUDA-enabled backend image
- Build the frontend
- Download the Qwen2.5-1.5B-Instruct model (~1.5GB)
If you don't want to use Docker, you can run the backend and frontend directly.
cd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# Mac/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txtcd frontend
npm installcd backend
uvicorn main:app --reloadBackend runs on http://localhost:8000
cd frontend
npm run devFrontend runs on http://localhost:5173
All configuration is done through the .env file in the backend folder:
| Variable | Required | Default | Description |
|---|---|---|---|
ENVIRONMENT |
No | production |
App environment (production or development) |
PORT |
No | 8000 |
Backend server port |
DATABASE_URL |
No | sqlite:///./chatbot.db |
Database URL (SQLite or PostgreSQL) |
MODEL_NAME |
No | Qwen/Qwen2.5-1.5B-Instruct |
Hugging Face model ID |
HF_TOKEN |
No | (empty) | Hugging Face token for private models |
TAVILY_API_KEY |
No | (empty) | Tavily search API key (better than DuckDuckGo) |
SEARCH_API_KEY |
No | (empty) | Alternative search API key |
WEATHER_API_KEY |
No | (empty) | Open-Meteo key (free, usually not needed) |
MAX_NEW_TOKENS |
No | 256 |
Maximum tokens per response |
TEMPERATURE |
No | 0.3 |
Response creativity (0.1 = focused, 1.0 = creative) |
TOP_P |
No | 0.85 |
Nucleus sampling parameter |
REPETITION_PENALTY |
No | 1.1 |
Penalty for repeating text |
The app automatically detects and uses CUDA if available. No configuration needed.
CPU-only mode:
# Force CPU mode (not recommended)
CUDA_VISIBLE_DEVICES=""# Start in background
docker compose up -d
# View logs
docker compose logs -f backend
docker compose logs -f frontend
# Stop (preserves data)
docker compose down
# Stop and delete all data
docker compose down -vTerminal 1 (Backend):
cd backend
uvicorn main:app --reloadTerminal 2 (Frontend):
cd frontend
npm run devOpen browser or curl:
curl http://localhost/api/healthExpected response:
{
"status": "ok",
"model_loaded": true,
"model_name": "Qwen/Qwen2.5-1.5B-Instruct",
"cuda_available": true,
"cuda_device": "NVIDIA GeForce RTX 3050 Laptop GPU",
"gpu_memory_allocated_mb": 2945.3,
"gpu_memory_total_mb": 4095.5
}Open http://localhost in your browser.
Send a message: "Hello, how are you?"
The response should appear token by token, like ChatGPT.
- Type a message in the input box
- Press Enter to send
- Press Shift+Enter for new line
- Click the stop button to cancel generation
- Click the Sun/Moon icon in the navbar or sidebar
- Theme preference is saved automatically
- New Chat: Click "New Chat" in sidebar
- Rename: Hover over conversation → Click edit icon
- Delete: Hover over conversation → Click trash icon
- Search: Use the search box in sidebar
The chatbot automatically detects and uses tools:
| Try saying... | What happens |
|---|---|
| "What is today's date?" | Returns exact date/time |
| "234 * 56" | Returns calculator result |
| "Weather in Delhi" | Returns current weather |
| "Latest AI news" | Searches web and summarizes |
| "Explain React hooks" | Normal AI response |
- Click the upload button (if implemented in frontend)
- Select a PDF, DOCX, or TXT file
- Ask questions about the document
The chatbot remembers:
- Your name ("My name is Mohit")
- Your preferences ("I prefer short answers")
- Conversation history
cd backend
# Install dependencies
pip install -r requirements.txt
# Run with auto-reload
uvicorn main:app --reload
# API docs available at
# http://localhost:8000/api/docscd frontend
# Install dependencies
npm install
# Run dev server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview| Method | Endpoint | Description |
|---|---|---|
| GET | /api/health |
Health check with GPU info |
| POST | /api/chat |
Send message (non-streaming) |
| POST | /api/chat/stream |
Send message (streaming) |
| POST | /api/documents/upload |
Upload document for RAG |
| GET | /api/documents |
List uploaded documents |
| DELETE | /api/documents/{id} |
Delete document |
| POST | /api/memory?user_id={id} |
Set user memory |
| GET | /api/memory/{user_id} |
Get user memory |
| POST | /api/users |
Create user |
| GET | /api/users/{id}/profile |
Get user profile |
| PATCH | /api/users/{id}/profile |
Update user profile |
ai-chatbot/
├── backend/
│ ├── main.py # FastAPI routes & startup
│ ├── model.py # Model loading & generation
│ ├── chatbot.py # Intent routing & tool orchestration
│ ├── config.py # Settings & environment variables
│ ├── database.py # SQLAlchemy setup
│ ├── streaming.py # SSE streaming handler
│ ├── tools/
│ │ ├── datetime_tool.py # Python datetime (no LLM)
│ │ ├── calculator.py # Safe AST math (no LLM)
│ │ ├── weather.py # Open-Meteo weather API
│ │ ├── search.py # DuckDuckGo / Tavily search
│ │ └── __init__.py
│ ├── router/
│ │ └── intent_router.py # Regex-based intent detection
│ ├── services/
│ │ ├── tool_service.py # Tool execution layer
│ │ ├── memory_service.py # SQLAlchemy CRUD
│ │ └── streaming.py # SSE streaming handler
│ ├── models/
│ │ └── __init__.py # SQLAlchemy ORM models
│ ├── rag/
│ │ ├── __init__.py
│ │ ├── document_loader.py # PDF/DOCX/TXT parsing
│ │ ├── embeddings.py # Sentence-transformers wrapper
│ │ ├── vectorstore.py # ChromaDB persistence
│ │ └── retriever.py # Chunking + retrieval
│ ├── requirements.txt
│ ├── Dockerfile
│ ├── .dockerignore
│ └── .env.example
├── frontend/
│ ├── src/
│ │ ├── components/ # UI components
│ │ │ ├── Sidebar.tsx
│ │ │ ├── ChatArea.tsx
│ │ │ ├── InputArea.tsx
│ │ │ ├── MessageBubble.tsx
│ │ │ ├── WelcomeScreen.tsx
│ │ │ └── theme/ # Theme system
│ │ ├── pages/
│ │ │ └── ChatPage.tsx # Main chat page
│ │ ├── hooks/
│ │ │ └── useChat.ts # Chat state management
│ │ ├── services/
│ │ │ └── api.ts # API client
│ │ ├── types/
│ │ │ └── index.ts # TypeScript interfaces
│ │ ├── App.tsx
│ │ └── main.tsx
│ ├── package.json
│ ├── Dockerfile
│ ├── nginx.conf
│ ├── vite.config.ts
│ └── tailwind.config.js
├── docker-compose.yml
├── .gitignore
└── README.md
Problem: docker build fails with CUDA or PyTorch errors
Solution:
# Ensure NVIDIA Container Toolkit is installed
docker run --rm --gpus all nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 nvidia-smi
# If it fails, install toolkit:
# Windows/Mac: Docker Desktop Settings → Enable GPU
# Linux: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.htmlProblem: First run gets stuck downloading model
Solution:
# Pre-download the model
docker compose run --rm backend python -c "from model import load_model; load_model()"
# Or manually download from Hugging Face:
# https://huggingface.co/Qwen/Qwen2.5-1.5B-InstructProblem: GPU runs out of memory
Solution:
- Reduce
MAX_NEW_TOKENSin.env:MAX_NEW_TOKENS=128
- Close other GPU applications
- Restart Docker
Problem: http://localhost shows blank page
Solution:
# Check frontend logs
docker compose logs frontend
# Rebuild frontend
docker compose up --build frontend
# Clear browser cache and reloadProblem: Frontend can't connect to backend
Solution:
# Check backend is running
curl http://localhost:8000/health
# Check docker compose
docker compose ps
# Restart services
docker compose restartProblem: AI takes too long to respond
Solution:
- Ensure GPU is being used (check
/api/health) - Reduce
MAX_NEW_TOKENSto 128 - Reduce
MAX_HISTORY_MESSAGESinconfig.py - Use a smaller model (e.g.,
Qwen/Qwen2.5-0.5B-Instruct)
No. The app runs completely locally. Optional API keys (Tavily, etc.) are only for enhanced features.
Yes. Everything runs on your machine. No data is sent to the cloud.
Yes, but it will be slower. CPU-only mode works fine for testing.
- Model: ~1.5GB
- Docker images: ~8GB
- Database: ~100MB
- Total: ~10GB recommended
Yes. Change MODEL_NAME in .env:
MODEL_NAME=Qwen/Qwen2.5-0.5B-Instruct # Smaller, faster
MODEL_NAME=Qwen/Qwen2.5-1.5B-Instruct # Default
MODEL_NAME=Qwen/Qwen2.5-7B-Instruct # Larger, smarter (needs 8GB+ VRAM)git pull origin main
docker compose up --build -dYes. Copy these files:
backend/chatbot.db(conversations)backend/.env(configuration)- Docker volume
huggingface-cache(model cache)
Yes. 100% free and open source. No costs, no subscriptions.
┌─────────────┐ /api/* ┌──────────────┐
│ Browser │ ◄──────────────► │ Nginx │
│ (React) │ │ (Frontend) │
└─────────────┘ └──────┬───────┘
│
│ proxy
▼
┌─────────────────────────────────────────────────────┐
│ Docker Compose │
│ │
│ ┌──────────────┐ ┌───────────────────────────┐ │
│ │ Backend │ │ Frontend │ │
│ │ (FastAPI) │ │ (Nginx + React) │ │
│ │ │ │ │ │
│ │ ┌────────┐ │ │ /api/chat ──────────► │ │
│ │ │ Model │ │ │ /api/stream ─────────► │ │
│ │ │ Qwen │ │ │ /api/health ─────────► │ │
│ │ │ 2.5B │ │ │ │ │
│ │ └────────┘ │ │ │ │
│ │ │ │ │ │
│ │ ┌────────┐ │ │ │ │
│ │ │ RAG │ │ │ │ │
│ │ │ChromaDB│ │ │ │ │
│ │ └────────┘ │ │ │ │
│ │ │ │ │ │
│ │ ┌────────┐ │ │ │ │
│ │ │ Tools │ │ │ │ │
│ │ │Datetime │ │ │ │ │
│ │ │Weather │ │ │ │ │
│ │ │Search │ │ │ │ │
│ │ │Calc │ │ │ │ │
│ │ └────────┘ │ │ │ │
│ │ │ │ │ │
│ │ ┌────────┐ │ │ │ │
│ │ │ Database│ │ │ │ │
│ │ │ SQLite │ │ │ │ │
│ │ └────────┘ │ │ │ │
│ └──────────────┘ └───────────────────────────┘ │
│ ▲ │
│ │ persistent │
│ ▼ │
│ ┌─────────────────┐ │
│ │ HuggingFace │ │
│ │ Model Cache │ │
│ │ (/cache/hf) │ │
│ └─────────────────┘ │
└─────────────────────────────────────────────────────┘
The chatbot uses a lightweight router to decide whether to use tools or the LLM:
| Intent | Trigger | Action |
|---|---|---|
datetime |
"what date", "today", "current time" | Returns exact Python datetime, bypasses LLM |
calculator |
Pure math expression like 234 * 56 |
Safe AST eval, bypasses LLM |
weather |
"weather in Delhi", "temperature" | Open-Meteo API + LLM summary |
search |
"latest news", "search for" | DuckDuckGo/Tavily + LLM summary |
normal |
Everything else | Qwen2.5-1.5B-Instruct |
# Start services
docker compose up --build
# Health check
curl http://localhost/api/health
# Chat
curl -X POST http://localhost/api/chat \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "Hello"}]}'
# Streaming
curl -X POST http://localhost/api/chat/stream \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "Hello"}]}'# Backend health
curl http://localhost:8000/health
# Chat
curl -X POST http://localhost:8000/chat \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "What is 234 * 56?"}]}'MIT
If you encounter issues:
- Check Troubleshooting section
- Search existing GitHub Issues
- Create a new issue with:
- OS and version
- GPU model (if applicable)
- Docker version
- Full error logs
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Qwen2.5 - The local LLM
- FastAPI - Backend framework
- React - Frontend library
- Tailwind CSS - Styling
- Nginx - Frontend proxy & static serving
- Docker - Containerization
- ChromaDB - Vector storage
- Sentence Transformers - Embeddings
If this project helps you, please give it a ⭐️ on GitHub!