A simple yet powerful web-based chatbot that enables users to interact with their own PDF documents using natural language. Powered by OpenAI's GPT models and enhanced with Retrieval-Augmented Generation (RAG) capabilities, the chatbot understands context from user-uploaded PDFs and answers questions accurately and concisely.
It features vector storage with FAISS, and history-aware memory, making the experience more conversational and contextually intelligent. The app is built with Streamlit, providing an intuitive and responsive user interface for seamless interactions.
- PDF Upload & Parsing: Upload single or multiple PDFs and automatically extract structured content using
PyPDFLoader. - Text Chunking: Split documents using
RecursiveCharacterTextSplitterfor improved retrieval accuracy. - FAISS Vector Store: Store and retrieve document embeddings for fast similarity search.
- OpenAI-powered QA: Answer user questions by combining document knowledge and GPT responses via LangChainβs QA chain.
- Chat History Memory: Maintain per-session conversation history using
RunnableWithMessageHistoryandInMemoryChatMessageHistory. - Streamlit UI: Clean sidebar for uploading PDFs, and chat-like interface for asking questions and viewing responses.
- π Go to the app: Click here to open the app
- π Upload your PDF file
- β Wait for the document to be processed, util the text box to ask questions is displayed
- β Ask question about your PDF, and wait the answer
- βͺοΈ You can even ask follow up question, See the message log in the side bar, and restart the session
- Clone the repository
git clone https://github.com/roissyahf/chat-with-your-pdf.git
cd chat-with-your-pdf- Create virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Create API Key
Visit https://platform.openai.com/api-keys to get OPENAI API KEY, then placed inside .env for security reason
- Run the Streamlit app
streamlit run app.py