Skip to content

A RAG-powered chatbot that explains algorithms using content from the CLRS - Introduction to Algorithms textbook.

Notifications You must be signed in to change notification settings

srutysaha/AlgoBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 AlgoBot – Talk to CLRS with AI

AlgoBot is an interactive Retrieval-Augmented Generation (RAG) powered chatbot that helps you understand algorithms directly from the CLRS textbook. Introduction to Algorithms is a book on computer programming by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The book is described by its publisher as "the leading algorithms text in universities worldwide as well as the standard reference for professionals". Ask algorithmic questions, and AlgoBot retrieves relevant sections from the book and explains them clearly using AI.

Built with Streamlit, LangChain, ChromaDB, HuggingFace embeddings, and Google Gemini.


✨ Features

  • 📘 CLRS-powered Q&A – Answers are grounded in textbook content
  • 🔍 Semantic Search using vector embeddings
  • 🧠 Context-aware conversations (uses recent chat history)
  • 🔁 Regenerate answers for better explanations
  • ⌨️ Typing animation for a ChatGPT-like experience
  • 💾 Persistent Vector Store (ChromaDB)
  • 🧹 Clear chat anytime from the sidebar

🧠 How It Works (RAG Pipeline)

  1. CLRS PDF is loaded and split into chunks

  2. Chunks are converted into vector embeddings

  3. Stored locally in ChromaDB

  4. On user query:

    • Relevant chunks are retrieved
    • Passed to Gemini LLM with a structured prompt
    • AI generates a grounded, textbook-based answer

🛠️ Tech Stack

  • Frontend: Streamlit
  • LLM: Google Gemini (gemini-2.5-pro)
  • Framework: LangChain
  • Embeddings: BAAI/bge-base-en-v1.5
  • Vector Database: ChromaDB
  • PDF Loader: PyMuPDF
  • Language: Python

📂 Project Structure

.
├── app.py              # Streamlit UI & chat logic
├── rag.py              # RAG pipeline (vectorstore + chain)
├── chroma_db/          # Persistent Chroma vector database
├── .env                # Environment variables
├── requirements.txt
└── README.md

⚙️ Setup & Installation

1️⃣ Clone the Repository

git clone https://github.com/your-username/algobot.git
cd algobot

2️⃣ Create Virtual Environment (Recommended)

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

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Add Environment Variables

Create a .env file:

GOOGLE_API_KEY=your_google_gemini_api_key

▶️ Running the App

streamlit run app.py

Open in browser: 👉 http://localhost:8501


💬 Example Questions

  • What is the difference between Divide and Conquer and Dynamic Programming?
  • Explain Quick Sort with time complexity
  • What is amortized analysis?
  • Why is Red-Black Tree height bounded?

🙌 Acknowledgements

  • Introduction to Algorithms – CLRS
  • LangChain
  • Google Gemini
  • HuggingFace
  • Streamlit

⭐ Support

If you like this project, consider giving it a ⭐ on GitHub! Feel free to fork, improve, and experiment 🚀

About

A RAG-powered chatbot that explains algorithms using content from the CLRS - Introduction to Algorithms textbook.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages