A powerful chatbot application that allows users to upload multiple PDF documents and interact with their content through natural language queries. Built with OpenAI API, LangChain, and Streamlit for an intuitive user experience.
- 📄 Multiple PDF Support: Upload and process multiple PDF documents simultaneously
- 💬 Interactive Chat Interface: Ask questions about your documents in natural language
- 🔍 Intelligent Search: Uses vector embeddings for accurate content retrieval
- 🤖 OpenAI Integration: Powered by OpenAI's language models for contextual responses
- 📊 User-Friendly Interface: Clean and intuitive Streamlit web interface
- LangChain: Framework for building LLM applications
- Streamlit: Web application framework for the user interface
- OpenAI: Language model for generating responses
- PyPDF2: PDF processing and text extraction
- FAISS: Vector database for efficient similarity search
- Tiktoken: Token counting for OpenAI models
- Python 3.10.11
- OpenAI API key
-
Clone the repository
git clone <repository-url> cd multipdf-chat-app
-
Create a virtual environment (recommended)
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install langchain PyPDF2 python-dotenv streamlit openai faiss-cpu altair tiktoken langchain-community
-
Set up environment variables Create a
.envfile in the root directory:OPENAI_API_KEY=your_openai_api_key_here
-
Start the application
streamlit run app.py
-
Access the web interface Open your browser and navigate to
http://localhost:8501 -
Upload PDF documents
- Use the file uploader to select one or multiple PDF files
- Wait for the documents to be processed
-
Start chatting
- Type your questions about the uploaded documents
- Get intelligent responses based on the document content
- Document Processing: PDFs are uploaded and text is extracted using PyPDF2
- Text Chunking: Large documents are split into manageable chunks
- Embeddings: Text chunks are converted to vector embeddings
- Vector Storage: Embeddings are stored in FAISS for efficient retrieval
- Query Processing: User questions are embedded and matched against document vectors
- Response Generation: Relevant document sections are sent to OpenAI for contextual answers
Add your demo GIF file to showcase the application in action
OPENAI_API_KEY: Your OpenAI API key (required)
-
API Key Error
- Ensure your OpenAI API key is correctly set in the
.envfile - Verify the key has sufficient credits
- Ensure your OpenAI API key is correctly set in the
-
PDF Processing Issues
- Check that PDF files are not password-protected
- Ensure PDFs contain extractable text (not just images)
-
Memory Issues
- For large PDFs, consider reducing chunk size
- Monitor system memory usage
-
Dependency Conflicts
- Use a virtual environment to avoid package conflicts
- Ensure Python version 3.10.11 is being used
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for providing the language model API
- LangChain community for the excellent framework
- Streamlit team for the user-friendly web framework
If you encounter any issues or have questions, please:
- Check the troubleshooting section above
- Search existing issues in the repository
- Create a new issue with detailed information about your problem
Note: Remember to keep your OpenAI API key secure and never commit it to version control.
