Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

34 Commits

Folders and files

Repository files navigation

PDF Copilot - Intelligent RAG Document Chatbot

Hugging Face Spaces

PDF Copilot is a powerful Retrieval-Augmented Generation (RAG) chatbot that allows users to seamlessly upload PDF documents and ask questions across them. It uses advanced machine learning models to extract paragraphs relevant to your questions and synthesizes natural language answers.

Try it out live here: https://huggingface.co/spaces/HYPERx54/PDF-Chatbot

Features

  • Multi-Document Support: Upload multiple PDFs and maintain an organized document library in the sidebar.
  • Global & Specific Scope:
    • Global Search: Ask questions across your entire library of uploaded PDFs simultaneously. The bot will intelligently fetch relevant sections from multiple documents to construct a comprehensive answer.
    • Specific Document Scope: Click on any document in your library to open a dedicated, side-by-side interactive PDF reader. Questions asked in this view are strictly isolated to the selected document.
  • Strict Fact-Binding: The AI is strictly prompted to only answer based on the provided document context. It will not hallucinate answers from its pre-trained knowledge base.
  • Beautiful Mathematical Rendering: Fully supports and elegantly renders complex mathematical formulas, equations, and expressions using KaTeX.
  • Session Privacy: Uploads and chat logs are completely isolated per session. When you close the browser tab, a cleanup beacon securely wipes your temporary files and vector embeddings.

Technology Stack

  • Backend Framework: FastAPI
  • LLM AI Provider: Google Gemini (Gemini 2.5 Flash) via langchain-google-genai
  • Embeddings: HuggingFace sentence-transformers/all-MiniLM-L6-v2 (Local generation)
  • Vector Database: ChromaDB
  • Frontend UI: Vanilla JavaScript, HTML, CSS with Lucide Icons and PDF.js

Local Installation

To run this project locally on your machine:

  1. Clone the repository:

    git clone https://github.com/ShantanuSaurav/AI_Chatbot.git
    cd AI_Chatbot
  2. Set up a virtual environment (Optional but recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows use: venv\Scripts\activate
  3. Install the dependencies:

    pip install -r requirements.txt
  4. Configure your API Keys: Create a folder named backend and a file inside it called .env.

    mkdir backend
    touch backend/.env

    Add your Google Gemini API key to the .env file:

    GEMINI_API_KEY=your_gemini_api_key_here
  5. Run the application:

    python app.py

    The app will start on http://127.0.0.1:8000.

Hugging Face Space Deployment

This application is fully compatible with Hugging Face Spaces using the Docker SDK. To deploy it:

  1. Create a new Space on Hugging Face (SDK: Docker).
  2. Push this repository's files to the Space.
  3. Go to the Space Settings -> Variables and secrets.
  4. Create a new Secret named GEMINI_API_KEY and paste your Google Gemini API key.
  5. The Space will automatically build and securely inject the keys into the application.

Current Limitations (Cons)

  • Vector Database Reset: The current implementation uses an ephemeral/local ChromaDB storage approach. When the server fully shuts down or restarts, previous document embeddings may be lost and require re-uploading.
  • Large PDF Processing Time: Very large PDFs (e.g., 100+ pages) might take slightly longer to chunk and embed upon the initial upload since embedding happens synchronously on the CPU.
  • Context Window Limitations: While the Global Search increases retrieval depth, extremely complex cross-document reasoning might still miss highly fragmented information if it falls outside the top 25 retrieved chunks.
  • Stateless AI Memory: To strictly ensure answers are bound to the document context, the chatbot does not retain conversational memory (chat history context) between different questions. Each question is treated independently against the document.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages