Skip to content

majid-abedi/chatbot-web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatGPT Web Application with Django

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.


🚀 Features

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


🛠️ Tech Stack

  • 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

📝 Prerequisites


🚦 Getting Started

1. Clone the Repository:

git clone https://github.com/majid-abedi/chatbot-web.git
cd chatbot-web

2. Create and Activate a Virtual Environment:

python -m venv venv
source venv/bin/activate  # Linux/Mac
venv\Scripts\activate     # Windows

3. Install Dependencies:

pip install -r requirements.txt

4. Set Up Environment Variables:

  • Create a .env file in the project root:
    touch .env
  • Add your OpenAI API Key:
    OPENAI_API_KEY=sk-your-openai-api-key
    

5. Run Migrations:

python manage.py migrate

6. Create a Superuser (Optional):

python manage.py createsuperuser

7. Run the Development Server:

python manage.py runserver
  • Open http://127.0.0.1:8000/ in your browser.

💡 Usage

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


💡 Future Improvements

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


📝 Notes

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

🤝 Contributing

Feel free to fork this repository, submit issues, or create pull requests. Contributions are always welcome!


📄 License

This project is licensed under the MIT License.

About

A Django-based chatbot application integrated with ChatGPT API.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors