Chanakya AI Intelligent Solutions for a Smarter Future

Question-Answering-Project

This project is a Django web application that allows you to **upload a file** (TXT, PDF, DOCX), extract its text, and then **chat with a chatbot** powered by **Google Gemini** β€” with the conversation based entirely on the uploaded file’s content.

Language: JavaScript

Stars: 1

Forks: 2

Watchers: 1

View on GitHub

README


πŸ“„ File-Based Chatbot with Google Gemini

This project is a Django web application that allows you to upload a file (TXT, PDF, DOCX), extract its text, and then chat with a chatbot powered by Google Gemini β€” with the conversation based entirely on the uploaded file’s content.


πŸš€ Features


πŸ› οΈ Tech Stack


πŸ“¦ Installation

  1. Clone the repository ```bash git clone https://github.com/yourusername/gemini-file-chatbot.git cd gemini-file-chatbot

  2. Create and activate a virtual environment

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

  1. Install dependencies

bash pip install -r requirements.txt

  1. Set up environment variables Create a .env file in the project root and add:

env GOOGLE_API_KEY=your_google_gemini_api_key

  1. Run database migrations

bash python manage.py migrate

  1. Start the development server

bash python manage.py runserver


πŸ“„ Usage

  1. Go to http://127.0.0.1:8000/chatbot/
  2. Upload your file (.txt, .pdf, .docx).
  3. Once uploaded, an input box will appear.
  4. Type your questions β€” responses are based only on your uploaded file.

πŸ“‚ Project Structure

project_root/ β”‚ β”œβ”€β”€ app/ β”‚ β”œβ”€β”€ models.py # File model with text storage β”‚ β”œβ”€β”€ forms.py # Upload form β”‚ β”œβ”€β”€ views.py # Upload + chat logic β”‚ β”œβ”€β”€ gemini.py # Google Gemini API wrapper β”‚ β”œβ”€β”€ templates/ β”‚ β”‚ └── chatbot.html # Main chatbot page β”‚ β”œβ”€β”€ manage.py β”œβ”€β”€ requirements.txt β”œβ”€β”€ README.md


πŸ“œ Example

Upload File:

my_notes.pdf containing details about cars.

User:

"What does it say about electric cars?"

Bot:

"The file mentions that electric cars are environmentally friendly and have lower running costs compared to traditional gasoline vehicles."


⚠️ Notes


πŸ“„ License

This project is licensed under the MIT License.


πŸ’‘ Future Improvements