A Streamlit-based application that allows users to chat with multiple PDF documents using LangChain and OpenAI.
- Upload multiple PDF documents
- Extract text from PDFs
- Process and chunk the text
- Create vector embeddings
- Chat with the documents using OpenAI's GPT model
- Maintain conversation history
- Python 3.8 or higher
- OpenAI API key
- Clone the repository:
git clone <repository-url>
cd LLM-Multi-PDF-Chat- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate- Install required packages:
pip install streamlit python-dotenv pypdf2 langchain openai faiss-cpu huggingface_hub- Create a
.envfile in the project root and add your OpenAI API key:
OPENAI_API_KEY=your_api_key_here
- Make sure your virtual environment is activated
- Run the Streamlit app:
streamlit run app.py- Open your web browser and navigate to the URL shown in the terminal (typically http://localhost:8501)
- Upload one or more PDF documents using the file uploader in the sidebar
- Click the "Process" button to process the documents
- Enter your questions in the text input field
- View the conversation history with the AI assistant
app.py: Main application file containing the Streamlit interface and processing logichtmlTemplates.py: Contains HTML templates for chat messages.env: Environment variables file (create this yourself)venv/: Virtual environment directory (created during setup)
Make sure you have sufficient credits in your OpenAI account as this application uses the OpenAI API for generating responses.