This is a full-stack Gen AI application that functions as a PDF context-aware chatbot. Users can upload PDF documents and ask questions related to their content. The application leverages a Large Language Model (LLM) to provide relevant answers based on the PDF context.
For Backend:
- Navigate to the backend directory:
cd backend - Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
- Windows:
venv\Scripts\activate
- Linux:
source venv/bin/activate
- Windows:
- Install the required dependencies:
pip install -r requirements.txt
- Run the FastAPI application:
uvicorn main:app --reload --host 0.0.0.0 --port 8000
For Frontend:
- Navigate to the frontend directory:
cd frontend - Install the npm dependencies:
npm install
- Start the development server:
npm run dev
/upload (POST)
- Receives files via a POST request.
- Extracts text content from the uploaded PDF using
pymupdf. - Divides the extracted text into smaller chunks.
- Generates vector embeddings for each chunk using Langchain.
- The text extraction and embedding processes are executed in separate threads to handle large files and CPU-intensive tasks efficiently.
- Stores file metadata (e.g., filename, upload timestamp) in a SQLite database.
- Saves the generated vector embeddings in the Fasis vector database.
/ask (POST)
- Retrieves relevant vector embeddings from the Fasis index based on the user's question.
- Receives the user's question via the POST request body.
- Combines the retrieved context (from the PDF) and the user's question.
- Sends this combined information to the LLM.
- Returns the LLM's response to the user.
- Frontend:
- Vite: A fast build tool and development server.
- Tailwind CSS: A utility-first CSS framework.
- React: A JavaScript library for building user interfaces.
- Backend:
- Database: