A simple yet powerful web application built using Django that integrates with the ChatGPT API. This project allows users to interact with an AI assistant by chatting through a clean and responsive web interface. Users can sign up, log in, and view their chat history on a personal dashboard. This project showcases Django's core features like authentication, ORM, templates, and API integration with OpenAI.
-
Chat with ChatGPT:
Engage in interactive conversations with the AI assistant powered by OpenAI's ChatGPT API (gpt-3.5-turbo). -
User Authentication:
Sign up, log in, and log out functionalities to keep your chat history safe. -
Chat History:
Save and view past conversations through a user-friendly dashboard (only for logged-in users). -
Responsive Design:
Built using Bootstrap 5.3 to provide a clean and user-friendly interface on all devices. -
Error Handling:
Gracefully manage API errors and validate user inputs to ensure smooth interaction.
- Backend: Django 4.2
- Frontend: HTML, Bootstrap 5.3
- API: OpenAI ChatGPT API (gpt-3.5-turbo)
- Database: SQLite (for development)
- Dependencies:
openai,python-dotenv
- Python 3.8+
- Git
- OpenAI API Key (Get it from OpenAI Platform)
git clone https://github.com/majid-abedi/chatbot-web.git
cd chatbot-webpython -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windowspip install -r requirements.txt- Create a
.envfile in the project root:touch .env
- Add your OpenAI API Key:
OPENAI_API_KEY=sk-your-openai-api-key
python manage.py migratepython manage.py createsuperuserpython manage.py runserver- Open
http://127.0.0.1:8000/in your browser.
-
Chat Page (
/):
Start chatting by entering your message and clicking send. -
Sign Up (
/signup/):
Create an account to save your chat history. -
Login (
/login/):
Access your saved chats and personalized dashboard. -
Dashboard (
/dashboard/):
View past conversations and manage your account. -
Logout (
/logout/):
Securely log out and clear your session.
-
Multi-User Chat Support:
Allow users to chat with multiple AI models. -
Advanced Chat Categorization:
Automatically categorize conversations based on topics. -
Extended Storage Options:
Integrate with databases like PostgreSQL for production.
- The OpenAI API Key used during development may exceed its quota. A placeholder response is used if the API quota is exceeded.
- Ensure your API Key is valid and has sufficient quota.
- This project can be extended with features like chat categorization, improved UI, or additional API integrations.
Feel free to fork this repository, submit issues, or create pull requests. Contributions are always welcome!
This project is licensed under the MIT License.