Upload a PDF and ask questions about its content using Gemini AI!
Built with Streamlit, this app uses LangChain, FAISS, and Google Generative AI to provide accurate answers based on your document.
- 📚 Upload any PDF and ask context-aware questions
- 🧠 Powered by Google Gemini-Pro (via LangChain)
- 🧾 Custom prompt template support
- ⚡ Fast text extraction and vector search with FAISS
- 🐞 Debug Mode to view internal operations
- 🌐 Clean and responsive Streamlit UI
- Frontend: Streamlit
- AI Model: Gemini-Pro (Google Generative AI)
- Text Extraction: PyPDF2
- Vector Store: FAISS
- RAG Chain: LangChain
- Environment: Python, dotenv
git clone https://github.com/your-username/pdf-chatbot.git
cd pdf-chatbot# Linux/macOS
python -m venv venv
source venv/bin/activate
# Windows
python -m venv venv
venv\Scripts\activatepip install -r requirements.txtMake sure your .env is configured (see below), then run:
streamlit run app.pyCreate a .env file in the root directory:
GOOGLE_API_KEY=your-google-api-key-here✅ To get your API key, enable the Google Generative AI API and generate one in Google Cloud Console.
pdf-chatbot/
├── app.py # Main Streamlit app
├── requirements.txt # Python dependencies
├── .env.example # Sample environment file
├── modules/
│ ├── pdf_loader.py # Extracts text from PDF
│ ├── vector_store.py # Embedding + FAISS index
│ └── rag_chain.py # LangChain QA logicstreamlit
langchain
faiss-cpu
PyMuPDF
langchain-google-genai
langchain-huggingface
langchain-community
langchain-text-splitters
tf-keras
- Upload a PDF via the interface.
- Ask questions in natural language.
- Get context-aware answers based on your document.
- Use Debug Mode (sidebar) to view extracted text, vector store status, and response time.
-
GOOGLE_API_KEY not set
Make sure.envexists and contains your key. -
No response or timeouts
Gemini may take a few seconds. Use Debug Mode to trace errors. -
FAISS import issues
Runpip install faiss-cpu(Windows/Linux/macOS supported).
Customize your prompt in the sidebar:
You are a helpful assistant. Answer the question based on the following document context.
Context:
{context}
Question: {question}
MIT License. Use freely and contribute back if you like it! 🤝
Open issues, suggest ideas, or submit pull requests! Let's build better AI tools together.
