BookLens AI is an AI-powered book recommender system that uses LLM-based embeddings, semantic vector search, and emotion-aware filtering to help users discover books that match both topic and mood.
Built using the LangChain ecosystem, ChromaDB, and Google’s embedding-001 model, the app provides an intuitive UI via Gradio for real-time, personalized recommendations.
- 🧬 Semantic Search: Matches user queries with book descriptions using AI-powered embeddings.
- 📂 Category & Emotion Filters: Narrow down results by genre and emotional tone (Joy, Fear, Anger, etc.).
- 🧱 Google Generative AI Embeddings: Captures deep semantic meaning of queries and descriptions.
- 💾 Chroma Vector Database: Efficient similarity search powered by LangChain.
- 🎨 Interactive Gradio UI: Simple and intuitive user interface to explore recommendations visually.
- 🎭 Thumbnail & Metadata Display: Clean book previews with titles and summaries
- 📘 Books are embedded using Google’s
embedding-001viaLangChain - 🗃️ ChromaDB stores these embeddings for fast semantic retrieval
- 🧠 User inputs a query (e.g., “A cozy mystery involving cats”)
- 🧮 Top-k similar descriptions are retrieved via vector similarity
- 🎯 Emotion & category filters are applied for final ranking
- 🖼️ Results displayed as book covers with title, author, and blurb
- Python 3.11.0
- Required Python packages (listed in
requirements.txt) - Google API Key for accessing the Gemini AI services
-
Clone the repository:
git clone https://github.com/Vish501/Book-Recommender.git
cd Book-Recommender -
Install dependencies:
It's recommended to use a virtual environment to manage dependencies. You can create and activate one using:
conda create -p venv python=3.11.0 -y
conda activate venv/
Then, install the required packages:
pip install -r requirements.txt
To use the Gemini API, you need to set up your GOOGLE_API_KEY:
-
Obtain your Google API Key from the Google Cloud Console.
-
Add the API key to your environment:
- Locally (Linux/macOS):
export GOOGLE_API_KEY="your-api-key-here" - Locally (Windows - Command Prompt):
set GOOGLE_API_KEY="your-api-key-here" - Locally (Windows - PowerShell):
$env:GOOGLE_API_KEY="your-api-key-here"
- Locally (Linux/macOS):
-
If you are using GitHub Codespaces, store the API key as a GitHub repository secret:
- Go to your GitHub repository
- Navigate to Settings > Secrets and variables > Actions
- Click New repository secret
- Set the name as
GOOGLE_API_KEYand paste your API key as the value - Click Add secret
-
Using a
.venvfile: Add the following line to your.venvfile in the root directory:GOOGLE_API_KEY=your_google_api_key_here
This will allow the project to authenticate and communicate with the Gemini API securely.
To ensure the app can locate and load the dataset correctly, you need to set the WORKING_DIRECTORY environment variable. This should point to the root directory of the project (where app.py and the data/ folder are located).
-
Determine the absolute path of your project directory.
-
Set the
WORKING_DIRECTORYenvironment variable:- Locally (Linux/macOS):
export WORKING_DIRECTORY="/absolute/path/to/Book-Recommender" - Locally (Windows - Command Prompt):
set WORKING_DIRECTORY="C:\path\to\Book-Recommender" - Locally (Windows - PowerShell):
$env:WORKING_DIRECTORY="C:\path\to\Book-Recommender"
- Locally (Linux/macOS):
-
Using GitHub Codespaces or GitHub Actions:
- Store the working directory as a secret or variable:
- Go to your GitHub repository
- Navigate to Settings > Secrets and variables > Actions
- Click New repository secret
- Set the name as
WORKING_DIRECTORYand the value as your project path - Click Add secret
- Store the working directory as a secret or variable:
-
Using a
.venvfile: Add the following line to your.venvfile in the root directory:WORKING_DIRECTORY=/absolute/path/to/Book-Recommender
To run the application:
python app.pyThis will launch the application, which will provide you with a link in the terminal that needs to be pasted into your browser.
app.py: Main application file for Gardio.data: CSV datasets used in the project.requirements.txt: List of required Python packages.setup.py: Setup configuration for the project.template.py: Contains template code to create the basic project structure.research/: Directory for research-related and data-cleaning files.src/: Source code directory containing modules and packages..venv: Environment variables (not tracked in Git)
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to contribute to this project by submitting issues or pull requests. For any questions or suggestions, please contact Vish501.