|
1 | | -```bash |
2 | | -pip3 install faiss-cpu google-generativeai python-dotenv fastapi uvicorn pydantic |
3 | | -``` |
4 | | - |
5 | | -## For Web UI |
6 | | -```bash |
7 | | -pip3 install flask |
8 | | -``` |
9 | | -```bash |
10 | | -python3 web.py |
11 | | -``` |
| 1 | +# Yuhasa - History Tutor Chatbot |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +* **Python:** Version 3.10 or higher recommended. |
| 8 | +* **pip:** Python package installer. |
| 9 | +* **Google AI API Key:** You need an API key from Google AI Studio (or Google Cloud Vertex AI) for the Gemini models. |
| 10 | +* **Git:** (Optional) If cloning the repository. |
| 11 | + |
| 12 | +## Setup |
| 13 | + |
| 14 | +1. **Clone the Repository (if applicable):** |
| 15 | + ```bash |
| 16 | + git clone <repository-url> |
| 17 | + cd <repository-directory> |
| 18 | + ``` |
| 19 | + |
| 20 | +2. **Install Dependencies:** |
| 21 | + It's recommended to use a virtual environment: |
| 22 | + ```bash |
| 23 | + python -m venv venv |
| 24 | + # On Windows |
| 25 | + .\venv\Scripts\activate |
| 26 | + # On macOS/Linux |
| 27 | + source venv/bin/activate |
| 28 | +
|
| 29 | + pip install -r requirements.txt |
| 30 | + ``` |
| 31 | + *(Note: The `requirements.txt` file lists the necessary dependencies: `flask`, `google-generativeai`, `faiss-cpu`, `pypdf`, `python-dotenv`, `numpy`)* |
| 32 | +
|
| 33 | +3. **Configure API Key:** |
| 34 | + * Create a file named `.env` in the root project directory. |
| 35 | + * Add your Google AI API key to the `.env` file: |
| 36 | + ``` |
| 37 | + GOOGLE_API_KEY=YOUR_API_KEY_HERE |
| 38 | + ``` |
| 39 | + * The `config.py` file likely loads this key. |
| 40 | +
|
| 41 | +4. **Process the PDF (if not already done):** |
| 42 | + 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. Check `main.py`, `embed_store.py`, or `pdf_chunker.py` for clues. If a specific script exists (e.g., `python embed_store.py`), run it: |
| 43 | + ```bash |
| 44 | + python faiss_store.py |
| 45 | + ``` |
| 46 | + This will create the `faiss_index.index` and `faiss_metadata.pkl` files (or similar). |
| 47 | +
|
| 48 | +## Running the Application |
| 49 | +
|
| 50 | +There seem to be multiple ways to interact with the chatbot: |
| 51 | +
|
| 52 | +1. **Web Interface (Recommended):** |
| 53 | + * Run the Flask web server: |
| 54 | + ```bash |
| 55 | + python web.py |
| 56 | + ``` |
| 57 | + * Open your web browser and navigate to the address provided (usually `http://127.0.0.1:5000` or similar). |
| 58 | +
|
| 59 | +2. **Command-Line Interface:** |
| 60 | + * Run the CLI script: |
| 61 | + ```bash |
| 62 | + python cli_chat.py |
| 63 | + ``` |
| 64 | + * Interact with the bot directly in your terminal. Type 'exit' or 'quit' to end the session. |
| 65 | +
|
| 66 | +## Project Structure Overview |
| 67 | +
|
| 68 | +* `web.py`: Runs the Flask web server for the GUI. |
| 69 | +* `cli_chat.py`: Provides a command-line interface. |
| 70 | +* `config.py`: Handles configuration (like API keys). |
| 71 | +* `faiss_store.py`: Manages the creation and querying of the FAISS vector store. |
| 72 | +* `gemini_utils.py`: Contains helper functions for interacting with the Gemini API. |
| 73 | +* `pdf_chunker.py`: Responsible for reading and splitting the PDF document. |
| 74 | +* `agents/`: Directory containing different components (agents) of the RAG pipeline (Retriever, Generator, Orchestrator, etc.). |
| 75 | +* `templates/index.html`: The HTML structure for the web interface. |
| 76 | +* `chats/`: Stores conversation history (JSON files). |
| 77 | +* `grade-11-history-text-book.pdf`: The source document. |
| 78 | +* `faiss_index.index`, `faiss_metadata.pkl`: The generated vector store files. |
| 79 | +* `requirements.txt`: Lists the project dependencies. |
| 80 | +* `README.md`: This file. |
| 81 | +* `PROJECT_EXPLANATION.md`: Detailed explanation of the project architecture. |
0 commit comments