The PDF Explainer Agent is an AI-powered tool that reads and answers questions from PDF documents using LLMs. It's built using LangChain, OpenRouter (e.g., DeepSeek, Mixtral, etc.), and HuggingFace embeddings for semantic search.
- Load and process PDF files
- Embed text chunks using HuggingFace embeddings
- Search relevant content using FAISS vector store
- Answer user queries using an LLM via OpenRouter
- Interactive local UI using
streamlit
pdf_explainer_agent/
│
├── main.py # Entry point of the application
├── data.pdf # Your PDF file (replace as needed)
├── requirements.txt # Python dependencies
├── .env # API keys and config (OpenRouter, HuggingFace)
└── README.md # This file
git clone https://github.com/yourusername/pdf_explainer_agent.git
cd pdf_explainer_agent# Using Anaconda
conda create -n pdf-agent python=3.11
conda activate pdf-agentpip install -r requirements.txtCreate a .env file in the root directory:
OPENROUTER_API_KEY=your_openrouter_key_here
HUGGINGFACEHUB_API_TOKEN=your_huggingface_token_herestreamlit run main.pyThen, open your browser at http://localhost:8501
Key Python packages used:
langchainopenai(for OpenRouter)streamlitPyPDF2orpdfminer.sixfaiss-cpusentence-transformerspython-dotenv
Install them all using:
pip install -r requirements.txt- Upload or hardcode a PDF (
data.pdf) - Ask questions like:
- “What is the purpose of the report?”
- “Summarize section 3”
- The agent will retrieve relevant chunks and generate an answer.
- Do not commit your
.envfile. - Never expose API keys publicly.
- Use only trusted models in OpenRouter.
Built by Shreyas Mulay.
Need help? Open an issue or reach out directly.
MIT License – do whatever you want but give credit.