This project implements a Retrieval-Augmented Generation (RAG) chatbot focused on answering questions about a Grade 11 History textbook. It uses Google's Gemini AI for language understanding and generation, and FAISS for efficient information retrieval from the textbook content. The project intentionally uses minimal dependencies (Flask, FAISS, Gemini, PyPDF) for simplicity, speed, and maintainability.
- Python: Version 3.10 or higher recommended.
- pip: Python package installer.
- Google AI API Key: You need an API key from Google AI Studio (or Google Cloud Vertex AI) for the Gemini models.
- Git: (Optional) If cloning the repository.
-
Clone the Repository (if applicable):
git clone <repository-url> cd <repository-directory>
-
Install Dependencies: It's recommended to use a virtual environment:
python -m venv venv # On Windows .\venv\Scripts\activate # On macOS/Linux source venv/bin/activate pip install -r requirements.txt
(Note: The
requirements.txt
file lists the necessary dependencies:flask
,google-generativeai
,faiss-cpu
,pypdf
,python-dotenv
,numpy
) -
Configure API Key:
- Create a file named
.env
in the root project directory. - Add your Google AI API key to the
.env
file:GOOGLE_API_KEY=YOUR_API_KEY_HERE
- The
config.py
file likely loads this key.
- Create a file named
-
Process the PDF (if not already done): The project needs to process the
grade-11-history-text-book.pdf
into a vector store. There might be a script for this, or it might happen automatically on the first run. Checkmain.py
,embed_store.py
, orpdf_chunker.py
for clues. If a specific script exists (e.g.,python embed_store.py
), run it:python faiss_store.py
This will create the
faiss_index.index
andfaiss_metadata.pkl
files (or similar).
There seem to be multiple ways to interact with the chatbot:
-
Web Interface (Recommended):
- Run the Flask web server:
python web.py
- Open your web browser and navigate to the address provided (usually
http://127.0.0.1:5000
or similar).
- Run the Flask web server:
-
Command-Line Interface:
- Run the CLI script:
python cli_chat.py
- Interact with the bot directly in your terminal. Type 'exit' or 'quit' to end the session.
- Run the CLI script: