{"id":21966401,"url":"https://github.com/rahul-404/chat_with_multiple_pdf_using_langchain_and_llms","last_synced_at":"2026-04-11T07:02:58.061Z","repository":{"id":262151311,"uuid":"886253728","full_name":"Rahul-404/Chat_With_Multiple_PDF_Using_LangChain_And_LLMs","owner":"Rahul-404","description":"📄 PDF Conversational Interface: Upload PDFs, extract content, and interact with it via a conversational interface 🤖. Powered by Google Gemini \u0026 LangChain, users can ask questions and receive detailed answers based on the text, all within a sleek Streamlit app 💬.","archived":false,"fork":false,"pushed_at":"2024-11-29T08:23:33.000Z","size":1167,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T21:43:54.712Z","etag":null,"topics":["docker","generative-ai","langchain-python","llm","ollama","python","streamlit-webapp"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rahul-404.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-10T15:43:58.000Z","updated_at":"2024-12-09T04:56:42.000Z","dependencies_parsed_at":"2024-11-10T21:25:51.156Z","dependency_job_id":"3d3eed23-93e7-47e1-87dc-9798f72c152e","html_url":"https://github.com/Rahul-404/Chat_With_Multiple_PDF_Using_LangChain_And_LLMs","commit_stats":null,"previous_names":["rahul-404/chat_with_multiple_pdf_using_langchain_and_llms"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rahul-404%2FChat_With_Multiple_PDF_Using_LangChain_And_LLMs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rahul-404%2FChat_With_Multiple_PDF_Using_LangChain_And_LLMs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rahul-404%2FChat_With_Multiple_PDF_Using_LangChain_And_LLMs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rahul-404%2FChat_With_Multiple_PDF_Using_LangChain_And_LLMs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rahul-404","download_url":"https://codeload.github.com/Rahul-404/Chat_With_Multiple_PDF_Using_LangChain_And_LLMs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245026002,"owners_count":20549067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","generative-ai","langchain-python","llm","ollama","python","streamlit-webapp"],"created_at":"2024-11-29T13:15:54.558Z","updated_at":"2026-04-11T07:02:58.051Z","avatar_url":"https://github.com/Rahul-404.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Chat with PDF Using Gemini - Streamlit App**\n\nThis project enables users to upload PDF files, extract their content, and interact with the extracted data via a conversational interface powered by **Google Generative AI** (Gemini) and **LangChain**. Using **Streamlit**, this application allows you to ask questions about the contents of PDF documents, and it will generate detailed answers based on the PDF text.\n\n---\n\n## **Table of Contents**\n\n- [Installation](#installation)\n- [Project Structure](#project-structure)\n- [How to Run the Project](#how-to-run-the-project)\n- [Features](#features)\n- [Usage](#usage)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## **Installation**\n\nFollow these steps to install and run the project:\n\n1. **Clone the repository**:\n\n    ```bash\n    git clone https://github.com/Rahul-404/Chat_With_Multiple_PDF_Using_LangChain_And_LLMs.git\n    cd Chat_With_Multiple_PDF_Using_LangChain_And_LLMs\n    ```\n\n2. **Create and activate a virtual environment** (recommended):\n\n    ```bash\n    python -m venv venv\n    source venv/bin/activate  # On Windows: venv\\Scripts\\activate\n    ```\n\n3. **Install dependencies**:\n\n    ```bash\n    pip install -r requirements.txt\n    ```\n\n4. **Set up environment variables**:\n\n    Ensure you have a `.env` file with the following content:\n\n    ```\n    GOOGLE_API_KEY=your_google_api_key_here\n    ```\n\n    Replace `your_google_api_key_here` with your actual Google API key. You can obtain the key by visiting the [**Google AI Studio**](https://aistudio.google.com/app/prompts/new_chat) and enabling the **Get API key**.\n\n---\n\n## **Project Structure**\n\nThe project is organized as follows:\n\n```\nChat_With_Multiple_PDF_Using_LangChain_And_LLMs/\n│\n├── app.py                 # Streamlit frontend (User interface for interacting with PDFs)\n├── logger.py              # Logging utility\n├── exception.py           # Custom exceptions\n├── requirements.txt       # Python dependencies\n├── .env                   # Environment variables (GOOGLE_API_KEY)\n└── README.md              # Project documentation\n```\n\n- **`app.py`**: This file is the Streamlit-based frontend that allows users to upload PDFs, interact with the extracted data, and ask questions.\n- **`logger.py`**: Contains logging utilities for debugging and tracking the application's execution.\n- **`exception.py`**: Custom exceptions for error handling throughout the app.\n\n---\n\n## **How to Run the Project**\n\n### 1. **Run the Streamlit Frontend**\n\nOnce the dependencies are installed, you can start the Streamlit-based app by running:\n\n```bash\nstreamlit run app.py\n```\n\nThis will launch the app in your browser (usually at `http://localhost:8501`), where you can interact with the PDF files.\n\n---\n\n## **Features**\n\n- **PDF Upload and Text Extraction**: Upload PDF files through the sidebar. The text content will be extracted using the **PyMuPDF** library.\n- **Text Chunking**: Large documents are chunked into smaller parts to make it easier for the model to process.\n- **Google Generative AI (Gemini) for Conversational AI**: Uses the **Gemini** model for answering questions based on the extracted PDF content.\n- **Embeddings and Vector Store**: Converts the extracted text into embeddings using **Google Generative AI Embeddings** and stores the vectors in a **FAISS** index for fast similarity search.\n- **Question-Answering**: Users can input questions related to the uploaded PDFs, and the app will generate detailed answers based on the context.\n\n---\n\n## **Usage**\n\n1. **Upload a PDF**:\n   - Go to the **sidebar** and click on the **\"Upload your PDF Files\"** button.\n   - Select the PDF file you want to interact with.\n\n2. **Submit and Process the PDF**:\n   - After uploading the PDF, click on **Submit \u0026 Process**. The app will extract the text, chunk it, and generate embeddings using the Google Generative AI model.\n\n3. **Ask Questions**:\n   - Once the PDF is processed, go to the **main input** area and type your question regarding the contents of the PDF.\n   - The app will use a **Conversational Chain** to process your question and generate an answer based on the context of the uploaded document.\n\n4. **View the Answer**:\n   - The answer generated by the model will be displayed below the question input field.\n\n---\n\n## **How the App Works**\n\n- **PDF Text Extraction**: The `get_pdf_text()` function uses the `PyMuPDF` library (`fitz`) to read and extract text from each page of the PDF document.\n- **Text Chunking**: Large documents are split into smaller chunks using the `RecursiveCharacterTextSplitter` from **LangChain**.\n- **Embeddings Generation**: Text chunks are converted into embeddings using **Google Generative AI** embeddings.\n- **Similarity Search**: When a user asks a question, a similarity search is performed using the **FAISS** index to retrieve relevant context.\n- **Question Answering**: The `get_conversational_chain()` function sets up a prompt and uses **Google Generative AI (Gemini)** to answer the user's question based on the retrieved context.\n\n---\n\n## **Logging and Error Handling**\n\n- **Logging**: Logs are created for each step of the process (text extraction, chunking, embedding, question answering) for easier debugging and tracking.\n- **Error Handling**: Custom exceptions are used throughout the app for better error handling. In case of an error, the system logs the exception and raises a custom exception for more details.\n\n---\n\n## **Project Demo**\n\nTo understand how this project works, watch the demo video below, which walks through the entire process of uploading a PDF, processing it, and interacting with the extracted content.\n\n### **Project Demo Video**\n\n[![Project Demo](https://img.youtube.com/vi/Z83Y36jqufg/0.jpg)](https://youtu.be/Z83Y36jqufg)\n\nIn this video, you'll see:\n- How to upload a PDF and process it\n- How the app extracts and chunks text from the document\n- How users can ask questions and get answers based on the PDF content\n\n---\n\n## **Contributing**\n\nWe welcome contributions! If you'd like to contribute to this project, please follow these steps:\n\n1. Fork the repository.\n2. Clone your fork to your local machine.\n3. Create a new branch for your feature or bugfix.\n4. Make your changes and test them locally.\n5. Push your changes to your fork.\n6. Open a pull request with a clear description of your changes.\n\n---\n\n## **License**\n\nThis project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahul-404%2Fchat_with_multiple_pdf_using_langchain_and_llms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahul-404%2Fchat_with_multiple_pdf_using_langchain_and_llms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahul-404%2Fchat_with_multiple_pdf_using_langchain_and_llms/lists"}