Skip to content

Vrinda999/Ask-PDF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ask-PDF

Contents

  1. About
  2. Structure
    1. Full Application
    2. Back-end
    3. Front-end
  3. Features
  4. Setup Instruction
    1. Backend
    2. Frontend
    3. MongoDB
  5. APIs
    1. /upload
    2. /ask
    3. /save-message
    4. /chat-history
  6. Architecture Overview
    1. Backend
    2. Frontend
    3. Model
    4. Database
  7. Dependencies
    1. Backend
    2. Frontend
  8. Outlook

About

Use natural language when interacting with PDF files.
Ask questions, and receive answers using a locally hosted LLaMA model.

Structure

Full Application

|-- backend/
|    |-- app/                   # FastAPI Endpoints
|    |-- models/                # Contains the LLaMA GGUF File
|    |-- uploads/               # Folder where Uploaded Files are Stored
|    |-- Dockerfile
|
|-- frontend/
|    |-- src/
|    |    |-- assets/           # Logo SVG
|    |    |-- components/
|    |-- App.jsx
|    |-- main.jsx
|
|    |-- Dockerfile
|    |-- package.json
|
|-- docker-compose.yml
|-- README.md
|-- requirements.txt

Backend

|-- app/
|    |-- main.py                # Intialises FastAPI
|    |-- api.py                 # Connection and Comunication with LLaMa and Database
|    |-- utils.py               # Utility Functions for User Interaction
|
|-- models/
|    |-- mistral-7b-instruct-v0.1.Q4_K_M.gguf
|
|-- uploads/
|    |-- Sample1.pdf
|    |-- Sample2.pdf
|
|-- .env
|
|-- Dockerfile

Frontend

|-- src/
|    |-- assets/
|    |    |-- logo.svg
|
|    |-- components/
|    |    |-- Components.jsx
|
|    |    |-- ChatSection.jsx               # Displays Chat + Text Box
|    |    |-- DarkModeToggle.jsx            # Light/Dark Mode
|    |    |-- ModalUpload.jsx               # Used for Uploading PDFs
|    |    |-- Navbar.jsx                    # Navigation bar with Logo and Utility Buttons.
|    |    |-- Sidebar.jsx                   # Shows the List of Uploaded PDFs
|
|    |-- App.css
|    |-- App.jsx
|    |-- index.css                          # Colour Palette Definition for Light/Dark Mode
|    |-- main.jsx
|
|-- .env
|-- .gitignore
|-- Dockerfile

Features

  • Upload your PDF documents.
  • Enquire about any Uploaded File in Plain Language.
  • Integration of LLaMA model (using mistral-7b-instruct).
  • The Per-File Chat History Enabled by MongoDB.
  • Dockerized Deployment.
  • Toggle between Light and Dark Mode.

Setup Instructions

Backend

cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload

Frontend

cd frontend
npm install
npm run dev

MongoDB Compass

Click on Connect to localhost:27017

In browser, open the Ask-PDF Website at localhost:5173


Post /upload

i/o type i/o Value
Request Form Data (File)
Response File Name

Post /ask

i/o type i/o Value
Request File Name, Query
Response Answer

Post /save-message

i/o type i/o Value
Request Sender, Text, File Name
Response Status (Saved)

Get /chat-history/{filename}

i/o type i/o Value
Request Internal Hit
Response [Sender, Text]

Architecture Overview

Backend (FastAPI + LLaMA)

  • Handles File Uploads and Text Extraction.
  • Uses llama_index with local LLaMA model (GGUF format).
  • Stores Chat History in MongoDB.

Frontend (React.js + Vite)

Feature File
Upload PDFs ModalUpload.jsx
Interact via Chat ChatSection.jsx
Sidebar displays List of PDFs Sidebar.jsx
Light/Dark Mode DarkModeToggle.jsx

Model

  • LLaMA Model: mistral-7b-instruct-v0.1.Q4_K_M.gguf
  • Loaded with llama-cpp-python.

Database

  • MongoDB container.
  • Stores Chat Messages per Filename.

Dependencies

Backend

  • fastapi
  • uvicorn
  • pymongo
  • llama-cpp-python

Install With:

$pip install -r requirements.txt

Frontend

  • axios
  • react
  • vite
  • tailwind

Install With:

$npm install

Outlook

Ask.PDF.Demo.mp4

Releases

No releases published

Packages

No packages published