A Django + Django REST Framework-based AI chatbot that integrates HuggingFace models to hold memory-aware conversations. Frontend is designed to impress.
- Backend: Django, Django REST Framework
- Frontend: HTML/CSS + Bootstrap (or Gradio/React optional)
- AI Model: HuggingFace Transformers (e.g., DialoGPT, Falcon)
- Database: PostgreSQL (recommended for Render)
- Deployment: Render.com
git clone https://github.com/yourusername/smart-assistant.git
cd smart-assistant
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Create a .env
file:
SECRET_KEY=your-secret-key
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
HUGGINGFACE_MODEL=gpt2
python manage.py migrate
python manage.py runserver
Visit: http://127.0.0.1:8000
Endpoint | Method | Description |
---|---|---|
/api/start-session/ |
POST | Start a new chat session |
/api/chat/ |
POST | Send a message and receive AI response |
/api/history/ |
GET | View full message history |
In transformers_model/model.py
, you can load your model like this:
from transformers import pipeline
chatbot = pipeline("text-generation", model="gpt2")
Replace with DialoGPT
, Falcon
, or any supported conversational model.
Make sure your code is pushed to a public or private GitHub repo.
- Go to Render.com
- Click New Web Service
- Connect to your GitHub repo
- Use the following build settings:
Build Command:
pip install -r requirements.txt && python manage.py collectstatic --noinput && python manage.py migrate
Start Command:
gunicorn config.wsgi:application
Environment:
- Add environment variables in the Render dashboard (SECRET_KEY, DEBUG=False, DATABASE_URL, etc.)
PostgreSQL DB:
- Add a Render PostgreSQL service and connect
DATABASE_URL
to your Django settings.
smart_assistant/
├── manage.py
├── requirements.txt
├── README.md
├── config/ # Django project config
│ ├── __init__.py
│ ├── settings.py # Main settings
│ ├── urls.py # Project-level routing
│ └── wsgi.py / asgi.py
├── chatbot/ # Main app
│ ├── __init__.py
│ ├── apps.py
│ ├── models.py # DB models: Session, Message, UserMemory
│ ├── views.py # Django views
│ ├── api_views.py # Chat API endpoint
│ ├── urls.py # App-level URLs
│ ├── forms.py # Input forms (if using Django forms)
├── templates/ # HTML templates
│ ├── base.html # Layout base
│ └── chat.html # Chat interface
├── static/ # Static files (CSS, JS, images)
│ ├── css/
│ ├── js/
│ └── img/
├── transformers_model/ # AI Model logic
│ ├── __init__.py
│ ├── model.py # Load + respond using HuggingFace
├── tests/ # Unit and integration tests
│ ├── __init__.py
│ ├── test_models.py
│ ├── test_views.py
│ └── test_chatbot.py
├── .env # Secrets for local dev
└── .gitignore
- Implement models and API endpoints
- Add HuggingFace model integration
- Design sleek chat UI (Tailwind or Gradio)
- Deploy to Render with PostgreSQL
- Submit GitHub + live demo + README + short video
Make the assistant charming, like a product you want to show off. Think beyond basic Q&A: memory, personality, even jokes or Easter eggs!