Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📄 PDF BOT - Chat with Your PDFs

A simple RAG (Retrieval-Augmented Generation) chatbot built with Streamlit, LangChain, and Google Gemini that allows you to upload a PDF and ask questions about its contents.


🚀 Features

  • 📂 Upload any PDF document
  • ✂️ Automatically splits the document into chunks
  • 🔍 Creates embeddings using Google's Gemini Embedding model
  • 🗂️ Stores embeddings in an in-memory vector database
  • 💬 Chat interface powered by Streamlit
  • 🤖 Answers questions using Gemini Flash with Retrieval-Augmented Generation (RAG)

🛠️ Tech Stack

  • Python
  • Streamlit
  • LangChain
  • Google Gemini API
  • PyPDFLoader
  • RecursiveCharacterTextSplitter
  • InMemoryVectorStore

📁 Project Structure

.
├── app.py
├── .env
├── .gitignore
├── requirements.txt
├── README.md
└── uploaded_document.pdf   # Generated after upload

⚙️ Installation

1. Clone the repository

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

2. Create a virtual environment

Mac/Linux

python3 -m venv venv
source venv/bin/activate

Windows

python -m venv venv
venv\Scripts\activate

3. Install dependencies

pip install -r requirements.txt

🔑 Environment Variables

Create a .env file in the project root.

GOOGLE_API_KEY=your_google_api_key

▶️ Running the Project

streamlit run app.py

Open the local URL shown in the terminal (usually http://localhost:8501).


🧠 How It Works

  1. Upload a PDF.
  2. The PDF is loaded using PyPDFLoader.
  3. The document is split into smaller chunks.
  4. Gemini Embeddings generate vector representations of each chunk.
  5. The vectors are stored in an in-memory vector database.
  6. When a question is asked:
    • The most relevant chunks are retrieved using similarity search.
    • Retrieved context and the user's question are sent to Gemini Flash.
    • The generated answer is displayed in the chat interface.

📸 Workflow

Upload PDF
      │
      ▼
Load PDF
      │
      ▼
Split into Chunks
      │
      ▼
Generate Embeddings
      │
      ▼
Store in Vector Database
      │
      ▼
User asks Question
      │
      ▼
Similarity Search
      │
      ▼
Gemini Flash
      │
      ▼
Answer

📦 Dependencies

  • streamlit
  • python-dotenv
  • langchain
  • langchain-community
  • langchain-google-genai
  • pypdf

Install them using:

pip install -r requirements.txt

🔮 Future Improvements

  • Support multiple PDF uploads
  • Persistent vector database (FAISS or Chroma)
  • Display source citations/pages
  • Conversation memory
  • PDF highlighting for retrieved answers
  • Support for DOCX and TXT files
  • Better prompt engineering
  • Deploy on Streamlit Cloud

Made with ❤️ using Streamlit, LangChain, and Google Gemini.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages