๐ง NLP Query Engine โ Complete Setup Guide ๐ Overview
This project is a Smart NLP Query Engine that supports:
โ Normal Queries (like โcount employeesโ, โlist all IT department employeesโ)
๐ค Hybrid Queries (mix of natural and structured queries)
๐ PDF Upload Support โ Extracts data from uploaded PDFs and allows querying on it
โก Fast Response Time displayed on frontend
๐พ Cache System (HIT / MISS) for performance tracking
๐งฎ Styled Table Output for better readability
๐๏ธ Project Structure nlp_query_engine_submit/ โ โโโ backend/ โ โโโ main.py โ โโโ data/ โ โโโ uploads/ โ โโโ requirements.txt โ โโโ frontend/ โ โโโ app.py โ โโโ pages/ โ โโโ README.md
โ๏ธ Backend Setup 1๏ธโฃ Navigate to backend folder cd backend
2๏ธโฃ Create and activate virtual environment For Windows PowerShell: python -m venv venv .\venv\Scripts\Activate.ps1
For CMD: python -m venv venv venv\Scripts\activate
3๏ธโฃ Install dependencies pip install fastapi uvicorn python-multipart pandas PyPDF2
4๏ธโฃ Run the backend server
Make sure main.py contains:
from fastapi import FastAPI app = FastAPI()
Then run:
uvicorn main:app --reload
If running from root directory:
uvicorn backend.main:app --reload
Backend will start at: ๐ http://127.0.0.1:8000
๐ฅ๏ธ Frontend Setup 1๏ธโฃ Navigate to frontend folder cd ../frontend
2๏ธโฃ Install Streamlit and dependencies pip install streamlit pandas requests
If any extra package missing:
pip install streamlit-extras
3๏ธโฃ Run the frontend app streamlit run app.py
Frontend will start at: ๐ http://localhost:8501
๐ Full Workflow
Run backend โ uvicorn main:app --reload
Run frontend โ streamlit run app.py
Upload PDF file (optional)
Enter your normal or hybrid query
See instant output with:
Cache info (HIT / MISS)
Response time
Table view results
๐งฉ PDF Query Example
Upload a PDF like:
Employee_Name | Department | Salary Ravi IT 50000 Sneha HR 60000
Then query:
list all employees in IT department
โ Output: List of employees from IT department with salaries.
๐ง Troubleshooting Error Solution Error loading ASGI app Make sure app = FastAPI() exists in main.py No module named 'PyPDF2' Run pip install PyPDF2 streamlit_extras not found Run pip install streamlit-extras Access denied while activating venv Run PowerShell as Administrator No detailed results found Check PDF format or ensure backend connected properly