GitHub Actions commited on
Commit Β·
024013e
0
Parent(s):
Sync from GitHub 953b3d5
Browse files- .github/workflows/sync-to-hf.yml +31 -0
- .gitignore +30 -0
- Dockerfile +12 -0
- README.md +212 -0
- backend/.gitignore +0 -0
- backend/agent.py +74 -0
- backend/api.py +251 -0
- backend/backend.py +271 -0
- backend/ingest.py +136 -0
- backend/pdf_mapping.json +219 -0
- backend/requirements.txt +35 -0
- backend/scraper.py +132 -0
- backend/startup.sh +21 -0
- backend/voice_agent.py +22 -0
- frontend/.gitignore +24 -0
- frontend/README.md +16 -0
- frontend/eslint.config.js +29 -0
- frontend/index.html +13 -0
- frontend/package-lock.json +0 -0
- frontend/package.json +36 -0
- frontend/public/vite.svg +1 -0
- frontend/src/App.css +42 -0
- frontend/src/App.jsx +649 -0
- frontend/src/assets/react.svg +1 -0
- frontend/src/index.css +12 -0
- frontend/src/main.jsx +10 -0
- frontend/vite.config.js +11 -0
.github/workflows/sync-to-hf.yml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync to Hugging Face Space
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: [main]
|
| 6 |
+
workflow_dispatch:
|
| 7 |
+
|
| 8 |
+
jobs:
|
| 9 |
+
sync:
|
| 10 |
+
runs-on: ubuntu-latest
|
| 11 |
+
steps:
|
| 12 |
+
- name: Checkout working tree only
|
| 13 |
+
uses: actions/checkout@v4
|
| 14 |
+
with:
|
| 15 |
+
fetch-depth: 1
|
| 16 |
+
lfs: false
|
| 17 |
+
|
| 18 |
+
- name: Push clean single-commit tree to HF Space
|
| 19 |
+
env:
|
| 20 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 21 |
+
run: |
|
| 22 |
+
rm -rf .git
|
| 23 |
+
rm -f .gitattributes
|
| 24 |
+
git init
|
| 25 |
+
git config user.email "ci@github.actions"
|
| 26 |
+
git config user.name "GitHub Actions"
|
| 27 |
+
git add -A
|
| 28 |
+
git commit -m "Sync from GitHub ${GITHUB_SHA::7}"
|
| 29 |
+
git branch -M main
|
| 30 |
+
git remote add space https://Yashkute:$HF_TOKEN@huggingface.co/spaces/Yashkute/SPPU-Student-AI-Assistent
|
| 31 |
+
git push space main --force
|
.gitignore
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ==========================
|
| 2 |
+
# SYSTEM / OS
|
| 3 |
+
# ==========================
|
| 4 |
+
.DS_Store
|
| 5 |
+
|
| 6 |
+
# ==========================
|
| 7 |
+
# BACKEND (Python / AI)
|
| 8 |
+
# ==========================
|
| 9 |
+
# Virtual Environments
|
| 10 |
+
backend/.venv/
|
| 11 |
+
.venv/
|
| 12 |
+
backend/venv/
|
| 13 |
+
|
| 14 |
+
# Python Cache
|
| 15 |
+
__pycache__/
|
| 16 |
+
*.pyc
|
| 17 |
+
|
| 18 |
+
# Security / Environment Variables
|
| 19 |
+
.env
|
| 20 |
+
|
| 21 |
+
# RAG Database & Raw Files
|
| 22 |
+
chroma_db/
|
| 23 |
+
backend/data/
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# ==========================
|
| 27 |
+
# FRONTEND (React / Node)
|
| 28 |
+
# ==========================
|
| 29 |
+
frontend/node_modules/
|
| 30 |
+
frontend/dist/
|
Dockerfile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
RUN apt-get update && apt-get install -y \
|
| 4 |
+
gcc \
|
| 5 |
+
g++ \
|
| 6 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 7 |
+
COPY . .
|
| 8 |
+
RUN pip install --no-cache-dir -r backend/requirements.txt
|
| 9 |
+
RUN pip install --no-cache-dir gdown
|
| 10 |
+
RUN chmod +x backend/startup.sh
|
| 11 |
+
EXPOSE 7860
|
| 12 |
+
CMD ["/bin/bash", "backend/startup.sh"]
|
README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Student AI SPPU
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# π SPPU Student AI Assistant
|
| 11 |
+
|
| 12 |
+
**[βΆ Live Demo](https://student-ai-assistent-sppu.vercel.app)** Β· Agentic RAG Β· LangGraph Β· ChromaDB Β· FastAPI Β· React
|
| 13 |
+
|
| 14 |
+

|
| 15 |
+

|
| 16 |
+

|
| 17 |
+

|
| 18 |
+

|
| 19 |
+
|
| 20 |
+
An **agentic RAG** study assistant for Savitribai Phule Pune University (SPPU) engineering students. It decides for itself when to search the syllabus corpus, retrieves with a two-stage vector-search + cross-encoder pipeline, and returns answers with a clickable link to the exact source PDF and page number.
|
| 21 |
+
|
| 22 |
+
Built as a final-year engineering Major Project. Includes neural text-to-speech, a React chat interface, and a live scraper that pulls the newest university circulars into the knowledge base on demand.
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## π§ How It Works
|
| 27 |
+
|
| 28 |
+
The core is a **LangGraph ReAct agent** (`backend/agent.py`) that autonomously routes each question to one of two tools:
|
| 29 |
+
|
| 30 |
+
| Tool | When the agent picks it |
|
| 31 |
+
|---|---|
|
| 32 |
+
| `search_syllabus_notes` | Any syllabus, concept, definition, or lab-procedure question |
|
| 33 |
+
| `check_latest_sppu_notices` | Time-sensitive queries β exam dates, new circulars, announcements |
|
| 34 |
+
|
| 35 |
+
Retrieval runs in two stages:
|
| 36 |
+
|
| 37 |
+
1. **Recall** β `BAAI/bge-base-en-v1.5` embeddings pull the top 20 candidate chunks from ChromaDB.
|
| 38 |
+
2. **Precision** β a `BAAI/bge-reranker-base` cross-encoder rescores all 20 and keeps the best 4.
|
| 39 |
+
|
| 40 |
+
The reranked chunks carry their filename and page number as metadata, which is what powers the per-answer source citations. Generation runs on Groq's `openai/gpt-oss-120b`, with `qwen/qwen3.6-27b` handling image questions (diagrams, question papers).
|
| 41 |
+
|
| 42 |
+
**Why an agent instead of a fixed RAG chain:** a fixed chain retrieves on every single query, including "hi". The agent skips retrieval for small talk and triggers the live scraper on its own when a question is about dates β no manual button needed.
|
| 43 |
+
|
| 44 |
+
---
|
| 45 |
+
|
| 46 |
+
## β¨ Features
|
| 47 |
+
|
| 48 |
+
* **Cited answers.** Every RAG answer renders source chips underneath linking to the exact PDF and page, so nothing has to be taken on trust.
|
| 49 |
+
* **Two-stage retrieval.** Bi-encoder recall plus cross-encoder reranking, with filename injection into chunk text to survive the lexical-keyword blindspot.
|
| 50 |
+
* **Autonomous tool routing.** LangGraph ReAct loop chooses retrieval, live scraping, or a direct reply per query.
|
| 51 |
+
* **On-demand audio tutor.** Microsoft Azure Neural voices via Edge-TTS, streamed as lazy-loaded binary blobs to avoid browser memory pressure.
|
| 52 |
+
* **Live circular sync.** BeautifulSoup scraper fetches the newest SPPU notices, tags them temporally (`LATEST_NOTICE_`), and re-indexes them into the vector store.
|
| 53 |
+
* **Vision mode.** Upload a diagram or past question paper and ask about it directly.
|
| 54 |
+
|
| 55 |
+
---
|
| 56 |
+
|
| 57 |
+
## π οΈ Tech Stack
|
| 58 |
+
|
| 59 |
+
| Layer | Technology |
|
| 60 |
+
|---|---|
|
| 61 |
+
| Agent orchestration | LangGraph (ReAct), LangChain |
|
| 62 |
+
| LLM inference | Groq β `openai/gpt-oss-120b`, `qwen/qwen3.6-27b` |
|
| 63 |
+
| Embeddings | `BAAI/bge-base-en-v1.5` |
|
| 64 |
+
| Reranker | `BAAI/bge-reranker-base` (cross-encoder) |
|
| 65 |
+
| Vector store | ChromaDB |
|
| 66 |
+
| Backend | FastAPI, Uvicorn |
|
| 67 |
+
| Frontend | React, Vite, Tailwind CSS, Framer Motion |
|
| 68 |
+
| TTS | Edge-TTS (Azure Neural voices) |
|
| 69 |
+
| Deployment | Hugging Face Spaces (Docker) + Vercel |
|
| 70 |
+
|
| 71 |
+
---
|
| 72 |
+
|
| 73 |
+
## π Local Setup
|
| 74 |
+
|
| 75 |
+
### Prerequisites
|
| 76 |
+
1. Python 3.10 β [download](https://www.python.org/downloads/)
|
| 77 |
+
2. Node.js v18+ and npm β [download](https://nodejs.org/)
|
| 78 |
+
3. A free Groq API key β [console.groq.com](https://console.groq.com)
|
| 79 |
+
|
| 80 |
+
### Step 1 β Clone
|
| 81 |
+
|
| 82 |
+
```bash
|
| 83 |
+
git clone https://github.com/YashKutehub/Student-AI-Assistent--SPPU.git
|
| 84 |
+
cd Student-AI-Assistent--SPPU
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
### Step 2 β Backend
|
| 88 |
+
|
| 89 |
+
```bash
|
| 90 |
+
cd backend
|
| 91 |
+
python -m venv .venv
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
Activate it:
|
| 95 |
+
|
| 96 |
+
```bash
|
| 97 |
+
# Windows
|
| 98 |
+
.venv\Scripts\activate
|
| 99 |
+
|
| 100 |
+
# macOS / Linux
|
| 101 |
+
source .venv/bin/activate
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
Install dependencies:
|
| 105 |
+
|
| 106 |
+
```bash
|
| 107 |
+
pip install -r requirements.txt
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
Create a `.env` file inside `backend/`:
|
| 111 |
+
|
| 112 |
+
```env
|
| 113 |
+
GROQ_API_KEY=your_actual_api_key_here
|
| 114 |
+
TTS_VOICE_ID=en-US-AriaNeural
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
Start the server:
|
| 118 |
+
|
| 119 |
+
```bash
|
| 120 |
+
uvicorn api:app --reload
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
Leave this terminal running.
|
| 124 |
+
|
| 125 |
+
### Step 3 β Frontend
|
| 126 |
+
|
| 127 |
+
In a **new terminal**:
|
| 128 |
+
|
| 129 |
+
```bash
|
| 130 |
+
cd frontend
|
| 131 |
+
npm install
|
| 132 |
+
npm run dev
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
Opens at `http://localhost:5173`.
|
| 136 |
+
|
| 137 |
+
### Step 4 β Build the vector database
|
| 138 |
+
|
| 139 |
+
The assistant has no knowledge until you feed it documents.
|
| 140 |
+
|
| 141 |
+
1. Drop SPPU syllabus PDFs, notes, or lab manuals into `backend/data/`.
|
| 142 |
+
2. With the backend venv active, run the ingestion script:
|
| 143 |
+
|
| 144 |
+
```bash
|
| 145 |
+
cd backend
|
| 146 |
+
python ingest.py
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
The script auto-detects CUDA and falls back to CPU. It skips already-processed files, so re-running it only indexes what's new.
|
| 150 |
+
|
| 151 |
+
**Verify it worked** β hit the health endpoint:
|
| 152 |
+
|
| 153 |
+
```bash
|
| 154 |
+
curl http://localhost:8000/health
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
A non-zero `chunks_in_db` means retrieval is live. A zero means the database is empty and the assistant will fall back to general knowledge.
|
| 158 |
+
|
| 159 |
+
**Alternative:** click **Live Sync** in the frontend header to scrape and index the latest SPPU circulars automatically.
|
| 160 |
+
|
| 161 |
+
---
|
| 162 |
+
|
| 163 |
+
## π Project Architecture
|
| 164 |
+
|
| 165 |
+
```text
|
| 166 |
+
SPPU-AI-ASSISTANT/
|
| 167 |
+
β
|
| 168 |
+
βββ backend/ # Python API & AI logic
|
| 169 |
+
β βββ api.py # FastAPI endpoints (/chat, /speak, /sync-notices, /health)
|
| 170 |
+
β βββ agent.py # LangGraph ReAct agent + tool definitions
|
| 171 |
+
β βββ backend.py # Groq routing, embeddings, cross-encoder reranking
|
| 172 |
+
β βββ ingest.py # PDF chunking, metadata injection, vector DB build
|
| 173 |
+
β βββ scraper.py # BeautifulSoup SPPU multi-board circular scraper
|
| 174 |
+
β βββ voice_agent.py # Edge-TTS audio stream generation
|
| 175 |
+
β βββ startup.sh # Container entrypoint: builds DB, then serves
|
| 176 |
+
β βββ requirements.txt # Python dependencies
|
| 177 |
+
β βββ .env # API keys (gitignored)
|
| 178 |
+
β βββ data/ # Raw PDF storage (gitignored)
|
| 179 |
+
β βββ chroma_db/ # Vector database (gitignored)
|
| 180 |
+
β
|
| 181 |
+
βββ frontend/ # React UI
|
| 182 |
+
β βββ src/
|
| 183 |
+
β β βββ App.jsx # Chat interface, source chips, blob audio player
|
| 184 |
+
β β βββ main.jsx # React entry point
|
| 185 |
+
β βββ package.json
|
| 186 |
+
β
|
| 187 |
+
βββ .github/workflows/
|
| 188 |
+
β βββ sync-to-hf.yml # CD: pushes a clean tree to the HF Space on merge
|
| 189 |
+
βββ Dockerfile # HF Spaces container definition
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
---
|
| 193 |
+
|
| 194 |
+
## π Troubleshooting
|
| 195 |
+
|
| 196 |
+
**Answers come back with no source citations.**
|
| 197 |
+
Check `/health`. If `chunks_in_db` is `0`, the vector database is empty and the agent is falling back to general knowledge. Run `python ingest.py`.
|
| 198 |
+
|
| 199 |
+
**Frontend says "Backend is unreachable".**
|
| 200 |
+
Confirm FastAPI is on port 8000. If it bound elsewhere, update `VITE_API_URL` in your frontend `.env`.
|
| 201 |
+
|
| 202 |
+
**Deleted PDFs still show up in answers.**
|
| 203 |
+
Vector stores don't auto-remove deleted documents. Delete the whole `chroma_db/` folder and re-run `python ingest.py` for a hard reset.
|
| 204 |
+
|
| 205 |
+
**Audio isn't playing.**
|
| 206 |
+
Edge-TTS needs a live connection to Microsoft's servers. Check network access and that `.env` loaded correctly.
|
| 207 |
+
|
| 208 |
+
---
|
| 209 |
+
|
| 210 |
+
## π License
|
| 211 |
+
|
| 212 |
+
MIT β see [LICENSE](LICENSE).
|
backend/.gitignore
ADDED
|
Binary file (66 Bytes). View file
|
|
|
backend/agent.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import re
|
| 3 |
+
import sys
|
| 4 |
+
import subprocess
|
| 5 |
+
|
| 6 |
+
from backend import (
|
| 7 |
+
get_vectorstore,
|
| 8 |
+
retrieve_context_with_sources,
|
| 9 |
+
generate_llm_response,
|
| 10 |
+
)
|
| 11 |
+
from scraper import scrape_latest_sppu_notice
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# Questions that genuinely need a live scrape of the SPPU circulars page.
|
| 15 |
+
# Everything else goes straight to vector retrieval.
|
| 16 |
+
NOTICE_PATTERNS = re.compile(
|
| 17 |
+
r"\b(notice|circular|announcement|exam\s*date|time\s*table|timetable|"
|
| 18 |
+
r"result\s*date|latest|recent|new\s+update|deadline)\b",
|
| 19 |
+
re.IGNORECASE,
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def check_latest_sppu_notices() -> str:
|
| 24 |
+
"""Scrape the official SPPU circulars page and index anything new."""
|
| 25 |
+
success, message = scrape_latest_sppu_notice()
|
| 26 |
+
if not success:
|
| 27 |
+
return f"Could not check for new notices: {message}"
|
| 28 |
+
|
| 29 |
+
backend_dir = os.path.dirname(os.path.abspath(__file__))
|
| 30 |
+
result = subprocess.run(
|
| 31 |
+
[sys.executable, "ingest.py"],
|
| 32 |
+
cwd=backend_dir,
|
| 33 |
+
capture_output=True,
|
| 34 |
+
text=True,
|
| 35 |
+
encoding="utf-8",
|
| 36 |
+
)
|
| 37 |
+
if result.returncode != 0:
|
| 38 |
+
return f"Found notices but failed to index them: {(result.stderr or '')[-500:]}"
|
| 39 |
+
|
| 40 |
+
get_vectorstore.cache_clear()
|
| 41 |
+
return message
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def run_agent(question: str, history: str = ""):
|
| 45 |
+
"""
|
| 46 |
+
Deterministic RAG pipeline.
|
| 47 |
+
|
| 48 |
+
The previous implementation used a LangGraph ReAct agent. That cost three
|
| 49 |
+
LLM round-trips per question (decide -> tool -> answer) and re-sent the full
|
| 50 |
+
retrieved context on every hop, which blew past Groq's free-tier 8000 TPM
|
| 51 |
+
limit. Retrieval is mandatory for every syllabus question here, so there is
|
| 52 |
+
nothing for the model to decide: retrieve once, answer once.
|
| 53 |
+
"""
|
| 54 |
+
notice_prefix = ""
|
| 55 |
+
|
| 56 |
+
if NOTICE_PATTERNS.search(question):
|
| 57 |
+
print("Time-sensitive question detected β checking SPPU circulars...")
|
| 58 |
+
notice_prefix = check_latest_sppu_notices()
|
| 59 |
+
|
| 60 |
+
context, sources = retrieve_context_with_sources(question, get_vectorstore())
|
| 61 |
+
|
| 62 |
+
if notice_prefix:
|
| 63 |
+
context = f"--- LATEST NOTICE CHECK ---\n{notice_prefix}\n\n{context}"
|
| 64 |
+
|
| 65 |
+
answer = generate_llm_response(
|
| 66 |
+
query=question,
|
| 67 |
+
context_text=context,
|
| 68 |
+
chat_history=history,
|
| 69 |
+
image_path=None,
|
| 70 |
+
use_rag=bool(context),
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
print(f"Sources returned: {sources or 'none'}")
|
| 74 |
+
return answer, sources
|
backend/api.py
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import urllib.parse
|
| 3 |
+
import shutil
|
| 4 |
+
import glob
|
| 5 |
+
import uuid
|
| 6 |
+
import base64
|
| 7 |
+
import sys
|
| 8 |
+
from datetime import date
|
| 9 |
+
from functools import lru_cache
|
| 10 |
+
from scraper import scrape_latest_sppu_notice
|
| 11 |
+
import subprocess
|
| 12 |
+
from fastapi import FastAPI, UploadFile, File, Form, HTTPException
|
| 13 |
+
from fastapi.responses import FileResponse, JSONResponse, Response
|
| 14 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 15 |
+
from urllib.parse import unquote
|
| 16 |
+
from pydantic import BaseModel
|
| 17 |
+
from huggingface_hub import HfApi, hf_hub_download
|
| 18 |
+
from backend import DB_PERSIST_DIRECTORY, retrieve_context_with_sources, generate_llm_response, get_vectorstore
|
| 19 |
+
from voice_agent import generate_tutor_audio
|
| 20 |
+
from agent import run_agent
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# --- SETUP ---
|
| 24 |
+
app = FastAPI()
|
| 25 |
+
|
| 26 |
+
app.add_middleware(
|
| 27 |
+
CORSMiddleware,
|
| 28 |
+
allow_origins=["*"],
|
| 29 |
+
allow_methods=["*"],
|
| 30 |
+
allow_headers=["*"],
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
# ---- DAILY REQUEST LIMITER ----
|
| 34 |
+
request_count = {"date": date.today(), "count": 0}
|
| 35 |
+
MAX_DAILY_REQUESTS = 200
|
| 36 |
+
|
| 37 |
+
@app.middleware("http")
|
| 38 |
+
async def limit_requests(request, call_next):
|
| 39 |
+
if request.url.path in ["/chat", "/speak"]:
|
| 40 |
+
if request_count["date"] != date.today():
|
| 41 |
+
request_count["date"] = date.today()
|
| 42 |
+
request_count["count"] = 0
|
| 43 |
+
if request_count["count"] >= MAX_DAILY_REQUESTS:
|
| 44 |
+
return JSONResponse(
|
| 45 |
+
status_code=429,
|
| 46 |
+
content={"detail": "Daily limit reached. Try again tomorrow."}
|
| 47 |
+
)
|
| 48 |
+
request_count["count"] += 1
|
| 49 |
+
return await call_next(request)
|
| 50 |
+
# ---- END LIMITER ----
|
| 51 |
+
|
| 52 |
+
# --- VECTOR DB SETUP ---
|
| 53 |
+
print("--- LOADING VECTOR DATABASE ---")
|
| 54 |
+
vectorstore = get_vectorstore()
|
| 55 |
+
print("--- DATABASE LOADED ---")
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
# --- PDF SOURCE RESOLUTION ---
|
| 59 |
+
# The 218 source PDFs live in an HF dataset, not in the container. We resolve
|
| 60 |
+
# local data/ first (so Live Sync scraped notices still work), then fall back
|
| 61 |
+
# to downloading the single requested PDF from the dataset on demand.
|
| 62 |
+
PDF_DATASET = "Yashkute/sppu-pdf-docs"
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
@lru_cache(maxsize=1)
|
| 66 |
+
def _pdf_index():
|
| 67 |
+
"""Map basename -> path inside the dataset repo. Built once per container."""
|
| 68 |
+
files = HfApi().list_repo_files(PDF_DATASET, repo_type="dataset")
|
| 69 |
+
return {os.path.basename(f): f for f in files if f.lower().endswith(".pdf")}
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def resolve_pdf(decoded_filename: str):
|
| 73 |
+
"""Return a local filesystem path for the PDF, or None if it doesn't exist."""
|
| 74 |
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 75 |
+
hits = glob.glob(
|
| 76 |
+
os.path.join(BASE_DIR, "data", "**", decoded_filename), recursive=True
|
| 77 |
+
)
|
| 78 |
+
if hits:
|
| 79 |
+
path = os.path.abspath(hits[0])
|
| 80 |
+
print(f"File found locally at: {path}")
|
| 81 |
+
return path
|
| 82 |
+
|
| 83 |
+
repo_path = _pdf_index().get(os.path.basename(decoded_filename))
|
| 84 |
+
if not repo_path:
|
| 85 |
+
return None
|
| 86 |
+
|
| 87 |
+
print(f"Fetching from HF dataset: {repo_path}")
|
| 88 |
+
return hf_hub_download(PDF_DATASET, repo_path, repo_type="dataset")
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
@app.get("/health")
|
| 92 |
+
def health():
|
| 93 |
+
try:
|
| 94 |
+
count = vectorstore._collection.count()
|
| 95 |
+
except Exception as e:
|
| 96 |
+
return {"chunks_in_db": -1, "error": str(e)}
|
| 97 |
+
return {"chunks_in_db": count, "db_path": DB_PERSIST_DIRECTORY}
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
# --- CHAT ENDPOINT ---
|
| 101 |
+
@app.post("/chat")
|
| 102 |
+
async def chat_endpoint(
|
| 103 |
+
question: str = Form(...),
|
| 104 |
+
history: str = Form(""),
|
| 105 |
+
use_rag: str = Form("true"),
|
| 106 |
+
file: UploadFile = File(None)
|
| 107 |
+
):
|
| 108 |
+
temp_image_path = None
|
| 109 |
+
try:
|
| 110 |
+
print(f"Received Question: {question}")
|
| 111 |
+
is_rag = use_rag.lower() == "true"
|
| 112 |
+
|
| 113 |
+
if file:
|
| 114 |
+
os.makedirs("temp", exist_ok=True)
|
| 115 |
+
temp_image_path = f"temp/{uuid.uuid4()}_{file.filename}"
|
| 116 |
+
with open(temp_image_path, "wb") as buffer:
|
| 117 |
+
shutil.copyfileobj(file.file, buffer)
|
| 118 |
+
print(f"Image saved temporarily at {temp_image_path}")
|
| 119 |
+
|
| 120 |
+
if is_rag and not temp_image_path:
|
| 121 |
+
print("Running agent...")
|
| 122 |
+
answer, sources = run_agent(question, history)
|
| 123 |
+
mode = "agent"
|
| 124 |
+
else:
|
| 125 |
+
answer = generate_llm_response(question, "", history, temp_image_path, use_rag=is_rag)
|
| 126 |
+
sources = []
|
| 127 |
+
mode = "vision" if temp_image_path else "general"
|
| 128 |
+
|
| 129 |
+
return JSONResponse(content={
|
| 130 |
+
"answer": answer,
|
| 131 |
+
"sources": sources,
|
| 132 |
+
"mode": mode,
|
| 133 |
+
"audio_base64": None
|
| 134 |
+
})
|
| 135 |
+
|
| 136 |
+
except Exception as e:
|
| 137 |
+
print(f"API Error: {e}")
|
| 138 |
+
return JSONResponse(content={"answer": "Sorry, a server error occurred.", "sources": [], "mode": "error", "audio_base64": None})
|
| 139 |
+
|
| 140 |
+
finally:
|
| 141 |
+
if temp_image_path and os.path.exists(temp_image_path):
|
| 142 |
+
os.remove(temp_image_path)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
# --- VOICE ON-DEMAND ENDPOINT ---
|
| 146 |
+
class SpeakRequest(BaseModel):
|
| 147 |
+
text: str
|
| 148 |
+
|
| 149 |
+
@app.post("/speak")
|
| 150 |
+
async def speak_endpoint(req: SpeakRequest):
|
| 151 |
+
print("Synthesizing Voice Tutor Audio on demand...")
|
| 152 |
+
try:
|
| 153 |
+
clean_text = req.text.replace("**", "").replace("*", "").replace("#", "")
|
| 154 |
+
|
| 155 |
+
if len(clean_text) > 3500:
|
| 156 |
+
clean_text = clean_text[:3500] + "... The rest of the answer has been truncated for audio playback."
|
| 157 |
+
|
| 158 |
+
audio_bytes = await generate_tutor_audio(clean_text)
|
| 159 |
+
|
| 160 |
+
if audio_bytes:
|
| 161 |
+
return Response(content=audio_bytes, media_type="audio/mpeg")
|
| 162 |
+
|
| 163 |
+
raise HTTPException(status_code=500, detail="Audio generation failed")
|
| 164 |
+
except Exception as e:
|
| 165 |
+
print(f"Speak Error: {e}")
|
| 166 |
+
raise HTTPException(status_code=500, detail=str(e))
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
# --- LIVE SYNC ENDPOINT (kept as manual override) ---
|
| 170 |
+
@app.post("/sync-notices")
|
| 171 |
+
async def sync_sppu_notices():
|
| 172 |
+
try:
|
| 173 |
+
success, message = scrape_latest_sppu_notice()
|
| 174 |
+
|
| 175 |
+
if success:
|
| 176 |
+
print("New file detected! Triggering Vector Database Update...")
|
| 177 |
+
backend_dir = os.path.dirname(os.path.abspath(__file__))
|
| 178 |
+
|
| 179 |
+
result = subprocess.run(
|
| 180 |
+
[sys.executable, "ingest.py"],
|
| 181 |
+
cwd=backend_dir,
|
| 182 |
+
check=False,
|
| 183 |
+
capture_output=True,
|
| 184 |
+
text=True,
|
| 185 |
+
encoding="utf-8",
|
| 186 |
+
env={**os.environ, "PYTHONIOENCODING": "utf-8"},
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
if result.returncode != 0:
|
| 190 |
+
err_tail = (result.stderr or "").strip()[-2000:]
|
| 191 |
+
out_tail = (result.stdout or "").strip()[-2000:]
|
| 192 |
+
raise RuntimeError(
|
| 193 |
+
f"ingest.py failed (exit code {result.returncode}).\nSTDERR tail:\n{err_tail}\nSTDOUT tail:\n{out_tail}"
|
| 194 |
+
)
|
| 195 |
+
|
| 196 |
+
global vectorstore
|
| 197 |
+
get_vectorstore.cache_clear()
|
| 198 |
+
vectorstore = get_vectorstore()
|
| 199 |
+
|
| 200 |
+
ingest_tail = ""
|
| 201 |
+
combined = ((result.stdout or "") + "\n" + (result.stderr or "")).strip()
|
| 202 |
+
if combined:
|
| 203 |
+
ingest_tail = combined[-900:]
|
| 204 |
+
if ingest_tail:
|
| 205 |
+
message += f" and injected into AI Memory (ingest completed). Ingest log tail: {ingest_tail}"
|
| 206 |
+
else:
|
| 207 |
+
message += " and injected into AI Memory (ingest completed)."
|
| 208 |
+
|
| 209 |
+
return {"status": "success" if success else "warning", "message": message}
|
| 210 |
+
|
| 211 |
+
except Exception as e:
|
| 212 |
+
print(f"Sync API Error: {e}")
|
| 213 |
+
raise HTTPException(status_code=500, detail=str(e))
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
# --- PDF VIEW ENDPOINT ---
|
| 217 |
+
@app.get("/view/{filename:path}")
|
| 218 |
+
async def view_pdf(filename: str):
|
| 219 |
+
decoded_filename = unquote(filename)
|
| 220 |
+
path = resolve_pdf(decoded_filename)
|
| 221 |
+
|
| 222 |
+
if not path:
|
| 223 |
+
print(f"File NOT found: {decoded_filename}")
|
| 224 |
+
raise HTTPException(status_code=404, detail="File not found")
|
| 225 |
+
|
| 226 |
+
return FileResponse(path, media_type="application/pdf")
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
# --- PDF DOWNLOAD ENDPOINT ---
|
| 230 |
+
@app.get("/download/{filename:path}")
|
| 231 |
+
async def download_file(filename: str):
|
| 232 |
+
decoded_filename = urllib.parse.unquote(filename)
|
| 233 |
+
print(f"Download request: {decoded_filename}")
|
| 234 |
+
|
| 235 |
+
path = resolve_pdf(decoded_filename)
|
| 236 |
+
|
| 237 |
+
if not path:
|
| 238 |
+
raise HTTPException(status_code=404, detail="File not found")
|
| 239 |
+
|
| 240 |
+
return FileResponse(
|
| 241 |
+
path=path,
|
| 242 |
+
filename=decoded_filename,
|
| 243 |
+
media_type="application/pdf",
|
| 244 |
+
headers={"Content-Disposition": f'attachment; filename="{decoded_filename}"'}
|
| 245 |
+
)
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
# --- SERVER STARTUP ---
|
| 249 |
+
if __name__ == "__main__":
|
| 250 |
+
import uvicorn
|
| 251 |
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|
backend/backend.py
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import base64
|
| 3 |
+
from functools import lru_cache
|
| 4 |
+
from PIL import Image
|
| 5 |
+
import io
|
| 6 |
+
from dotenv import load_dotenv
|
| 7 |
+
from sentence_transformers import CrossEncoder
|
| 8 |
+
import numpy as np
|
| 9 |
+
from langchain_groq import ChatGroq
|
| 10 |
+
from langchain_core.messages import HumanMessage, SystemMessage
|
| 11 |
+
from langchain_community.vectorstores import Chroma
|
| 12 |
+
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 13 |
+
|
| 14 |
+
# 1. SETUP
|
| 15 |
+
load_dotenv()
|
| 16 |
+
DB_PERSIST_DIRECTORY = "./chroma_db"
|
| 17 |
+
|
| 18 |
+
print("π§ Loading Embedding + Reranker engines...")
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
@lru_cache(maxsize=1)
|
| 22 |
+
def get_embeddings():
|
| 23 |
+
return HuggingFaceEmbeddings(
|
| 24 |
+
model_name="BAAI/bge-base-en-v1.5",
|
| 25 |
+
model_kwargs={"device": "cpu"},
|
| 26 |
+
encode_kwargs={
|
| 27 |
+
"normalize_embeddings": True,
|
| 28 |
+
"batch_size": 32,
|
| 29 |
+
},
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
@lru_cache(maxsize=1)
|
| 34 |
+
def get_reranker():
|
| 35 |
+
return CrossEncoder('BAAI/bge-reranker-base')
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
@lru_cache(maxsize=1)
|
| 39 |
+
def get_vectorstore():
|
| 40 |
+
return Chroma(persist_directory=DB_PERSIST_DIRECTORY, embedding_function=get_embeddings())
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
# --- π GROQ MODEL DEFINITIONS ---
|
| 44 |
+
# Migrated 19 Aug 2026 β Groq decommissioned the previous models:
|
| 45 |
+
# llama-3.3-70b-versatile -> shut down 16 Aug 2026
|
| 46 |
+
# meta-llama/llama-4-scout-17b-16e-instruct -> shut down 17 Jul 2026
|
| 47 |
+
TEXT_MODEL_NAME = "openai/gpt-oss-120b" # MoE reasoning text model (text-only)
|
| 48 |
+
VISION_MODEL_NAME = "qwen/qwen3.6-27b" # multimodal model (NOTE: Groq serves this as PREVIEW)
|
| 49 |
+
|
| 50 |
+
# Reasoning models spend tokens thinking before answering, so the ceiling has to
|
| 51 |
+
# be high enough for reasoning + the actual answer, or replies come back truncated.
|
| 52 |
+
# Groq reserves max_tokens against the per-minute budget, so this is also half of
|
| 53 |
+
# the 429 equation β do not raise it without checking the TPM headroom.
|
| 54 |
+
TEXT_MAX_TOKENS = 1600
|
| 55 |
+
VISION_MAX_TOKENS = 1024
|
| 56 |
+
|
| 57 |
+
print("\n--- π΅οΈββοΈ INITIALIZING GROQ AI ENGINE ---")
|
| 58 |
+
|
| 59 |
+
if not os.getenv("GROQ_API_KEY"):
|
| 60 |
+
print("β ERROR: GROQ_API_KEY not found in .env")
|
| 61 |
+
else:
|
| 62 |
+
print(f"β
Text Engine: {TEXT_MODEL_NAME}")
|
| 63 |
+
print(f"β
Vision Engine: {VISION_MODEL_NAME}")
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
@lru_cache(maxsize=4)
|
| 67 |
+
def get_groq_llm(model_name):
|
| 68 |
+
"""Creates and reuses a Groq LLM instance for lower startup overhead."""
|
| 69 |
+
is_reasoning_model = model_name.startswith("openai/gpt-oss")
|
| 70 |
+
|
| 71 |
+
kwargs = {
|
| 72 |
+
"model": model_name,
|
| 73 |
+
"temperature": 0.2,
|
| 74 |
+
"max_tokens": TEXT_MAX_TOKENS if is_reasoning_model else VISION_MAX_TOKENS,
|
| 75 |
+
# Groq's free tier is 8000 TPM. A burst of questions will legitimately
|
| 76 |
+
# hit 429; langchain retries those with exponential backoff, so the user
|
| 77 |
+
# sees a slower answer instead of an error.
|
| 78 |
+
"max_retries": 5,
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
# Only gpt-oss models accept these β sending them to the vision model errors out.
|
| 82 |
+
if is_reasoning_model:
|
| 83 |
+
kwargs["reasoning_effort"] = "medium" # tool routing + summarising: deep reasoning not needed
|
| 84 |
+
kwargs["reasoning_format"] = "hidden" # keeps chain-of-thought out of response.content
|
| 85 |
+
|
| 86 |
+
try:
|
| 87 |
+
return ChatGroq(**kwargs)
|
| 88 |
+
except TypeError:
|
| 89 |
+
# Older langchain-groq versions don't expose the reasoning params directly.
|
| 90 |
+
reasoning_kwargs = {
|
| 91 |
+
k: kwargs.pop(k) for k in ("reasoning_effort", "reasoning_format") if k in kwargs
|
| 92 |
+
}
|
| 93 |
+
if reasoning_kwargs:
|
| 94 |
+
kwargs["model_kwargs"] = reasoning_kwargs
|
| 95 |
+
return ChatGroq(**kwargs)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
# --- π οΈ UTILS ---
|
| 99 |
+
def encode_image(image_path):
|
| 100 |
+
"""Encodes image to base64 with optimization for local-to-cloud transfer."""
|
| 101 |
+
if not image_path or not os.path.exists(image_path):
|
| 102 |
+
return None
|
| 103 |
+
try:
|
| 104 |
+
with Image.open(image_path) as img:
|
| 105 |
+
if img.mode != 'RGB':
|
| 106 |
+
img = img.convert('RGB')
|
| 107 |
+
|
| 108 |
+
max_size = (1600, 1600)
|
| 109 |
+
img.thumbnail(max_size, Image.Resampling.LANCZOS)
|
| 110 |
+
|
| 111 |
+
buffer = io.BytesIO()
|
| 112 |
+
img.save(buffer, format="JPEG", quality=80, optimize=True)
|
| 113 |
+
|
| 114 |
+
size_mb = buffer.tell() / (1024 * 1024)
|
| 115 |
+
print(f"π Image optimized: {size_mb:.2f} MB")
|
| 116 |
+
|
| 117 |
+
return base64.b64encode(buffer.getvalue()).decode('utf-8')
|
| 118 |
+
except Exception as e:
|
| 119 |
+
print(f"β Error encoding image: {e}")
|
| 120 |
+
return None
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
BGE_QUERY_PREFIX = "Represent this sentence for searching relevant passages: "
|
| 124 |
+
|
| 125 |
+
# bge-reranker-base returns a RAW LOGIT, not a probability. Relevant chunks
|
| 126 |
+
# routinely score negative on paraphrased queries, so keep the top hits always
|
| 127 |
+
# and only bail when even the best hit is clearly unrelated.
|
| 128 |
+
LOW_CONFIDENCE_FLOOR = -4.0
|
| 129 |
+
TOP_K = 3
|
| 130 |
+
|
| 131 |
+
# --- TOKEN BUDGET ---
|
| 132 |
+
# Groq free tier = 8000 tokens/minute, and max_tokens is reserved against it.
|
| 133 |
+
# Roughly 4 chars per token, so these two caps keep a request near ~3.5k total
|
| 134 |
+
# and leave room for a second question inside the same minute.
|
| 135 |
+
MAX_CHARS_PER_CHUNK = 1100
|
| 136 |
+
MAX_HISTORY_CHARS = 1500
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def retrieve_context_with_sources(query, vectorstore):
|
| 140 |
+
"""Stage 1: Fast candidate retrieval. Stage 2: Cross-encoder reranking for precision."""
|
| 141 |
+
try:
|
| 142 |
+
search_query = BGE_QUERY_PREFIX + query
|
| 143 |
+
|
| 144 |
+
retriever = vectorstore.as_retriever(search_kwargs={"k": 20})
|
| 145 |
+
initial_docs = retriever.invoke(search_query)
|
| 146 |
+
if not initial_docs:
|
| 147 |
+
return "", []
|
| 148 |
+
|
| 149 |
+
reranker = get_reranker()
|
| 150 |
+
sentence_pairs = [[query, doc.page_content] for doc in initial_docs]
|
| 151 |
+
scores = np.asarray(reranker.predict(sentence_pairs), dtype=np.float32)
|
| 152 |
+
|
| 153 |
+
sorted_indices = np.argsort(scores)[::-1]
|
| 154 |
+
|
| 155 |
+
top_indices = [int(i) for i in sorted_indices[:TOP_K]]
|
| 156 |
+
|
| 157 |
+
if not top_indices or scores[top_indices[0]] < LOW_CONFIDENCE_FLOOR:
|
| 158 |
+
print("β οΈ No chunk passed the confidence threshold β falling back to general knowledge.")
|
| 159 |
+
return "", []
|
| 160 |
+
|
| 161 |
+
top_k_docs = [initial_docs[i] for i in top_indices]
|
| 162 |
+
|
| 163 |
+
print("π Retrieved chunks (reranked):")
|
| 164 |
+
for i in top_indices:
|
| 165 |
+
src = os.path.basename(initial_docs[i].metadata.get('source', 'Unknown'))
|
| 166 |
+
print(f" score={scores[i]:.3f} src={src}")
|
| 167 |
+
|
| 168 |
+
formatted_text = ""
|
| 169 |
+
sources_with_pages = []
|
| 170 |
+
for d in top_k_docs:
|
| 171 |
+
name = os.path.basename(d.metadata.get('source', 'Unknown'))
|
| 172 |
+
page = d.metadata.get('page', 0) + 1
|
| 173 |
+
body = d.page_content[:MAX_CHARS_PER_CHUNK]
|
| 174 |
+
formatted_text += f"--- FROM: {name} (Page {page}) ---\n{body}\n\n"
|
| 175 |
+
sources_with_pages.append(f"{name} [Pg. {page}]")
|
| 176 |
+
|
| 177 |
+
unique_sources = list(dict.fromkeys(sources_with_pages))
|
| 178 |
+
|
| 179 |
+
approx_tokens = len(formatted_text) // 4
|
| 180 |
+
print(f"π¦ Context size: {len(formatted_text)} chars (~{approx_tokens} tokens)")
|
| 181 |
+
|
| 182 |
+
return formatted_text, unique_sources
|
| 183 |
+
|
| 184 |
+
except Exception as e:
|
| 185 |
+
print(f"β Reranking Error: {e}")
|
| 186 |
+
return "", []
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
# --- π§ MAIN CHAT FUNCTION ---
|
| 190 |
+
def generate_llm_response(query, context_text, chat_history, image_path, use_rag=True):
|
| 191 |
+
# 1. Choose Engine
|
| 192 |
+
if image_path:
|
| 193 |
+
print("πΈ Vision Mode...")
|
| 194 |
+
current_llm = get_groq_llm(VISION_MODEL_NAME)
|
| 195 |
+
else:
|
| 196 |
+
print("π Text Mode...")
|
| 197 |
+
current_llm = get_groq_llm(TEXT_MODEL_NAME)
|
| 198 |
+
|
| 199 |
+
# 2. Skip RAG formatting for small greetings
|
| 200 |
+
query_lower = query.strip().lower()
|
| 201 |
+
common_greetings = ["hi", "hello", "hey", "yo", "thanks", "good morning"]
|
| 202 |
+
if any(query_lower.startswith(g) for g in common_greetings) and len(query.split()) < 4:
|
| 203 |
+
use_rag = False
|
| 204 |
+
|
| 205 |
+
# Keep only the tail of the conversation β older turns are the cheapest
|
| 206 |
+
# thing to drop when staying inside the per-minute token budget.
|
| 207 |
+
if chat_history and len(chat_history) > MAX_HISTORY_CHARS:
|
| 208 |
+
chat_history = "...(earlier turns trimmed)...\n" + chat_history[-MAX_HISTORY_CHARS:]
|
| 209 |
+
|
| 210 |
+
# 3. Apply the Specialized SPPU System Prompt
|
| 211 |
+
if use_rag and context_text:
|
| 212 |
+
system_text = (
|
| 213 |
+
"You are an elite Academic AI Assistant for SPPU engineering students. "
|
| 214 |
+
"Your job is rigorous exam prep: simplify complex concepts and explain logic step-by-step.\n\n"
|
| 215 |
+
"### π― CORE DIRECTIVES:\n"
|
| 216 |
+
"1. **Context is the source of truth.** Answer using ONLY the provided CONTEXT below whenever it "
|
| 217 |
+
"contains the answer. Do NOT add outside facts when the context already covers the topic. "
|
| 218 |
+
"Cite the exact source document name at the end of the relevant points.\n"
|
| 219 |
+
"2. **Partial-context handling:** If the CONTEXT only partially answers the question, answer the "
|
| 220 |
+
"covered part from context (and cite it), then clearly mark any added explanation as general knowledge.\n"
|
| 221 |
+
"3. **True fallback only:** If the CONTEXT does not address the question at all, you MUST begin your "
|
| 222 |
+
"response with this exact warning: 'β οΈ *I could not find this specific topic in your provided study "
|
| 223 |
+
"materials, but based on general knowledge:*' and then answer.\n"
|
| 224 |
+
"4. **Study formatting:** STRICTLY follow the user's requested format. "
|
| 225 |
+
"If the user asks for 7-8 points, give exactly 7-8 points. "
|
| 226 |
+
"If the user asks for a brief answer, be concise. "
|
| 227 |
+
"If the user asks for a table, use a table. "
|
| 228 |
+
"If no format is specified, default to clear numbered points with bold key terms.\n"
|
| 229 |
+
"5. **Technical precision:** Break down algorithms, data structures, and engineering logic systematically.\n"
|
| 230 |
+
"6. **Visual analysis:** If an image (diagram/paper) is provided, analyze it and connect it to the question.\n"
|
| 231 |
+
"7. **Output only the final answer.** Do not show your internal reasoning or planning steps.\n\n"
|
| 232 |
+
f"--- HISTORY ---\n{chat_history}\n\n"
|
| 233 |
+
f"--- CONTEXT ---\n{context_text}"
|
| 234 |
+
)
|
| 235 |
+
else:
|
| 236 |
+
system_text = (
|
| 237 |
+
"You are a helpful SPPU AI Assistant. No specific study material was found for this question, "
|
| 238 |
+
"so answer using general engineering knowledge. Begin your answer with this exact warning: "
|
| 239 |
+
"'β οΈ *I could not find this specific topic in your provided study materials, but based on general knowledge:*'\n"
|
| 240 |
+
"Output only the final answer β do not show your internal reasoning or planning steps.\n"
|
| 241 |
+
f"--- HISTORY ---\n{chat_history}"
|
| 242 |
+
)
|
| 243 |
+
|
| 244 |
+
# 4. Payload Construction
|
| 245 |
+
content_payload = []
|
| 246 |
+
if image_path:
|
| 247 |
+
b64 = encode_image(image_path)
|
| 248 |
+
if b64:
|
| 249 |
+
content_payload.append({
|
| 250 |
+
"type": "image_url",
|
| 251 |
+
"image_url": {"url": f"data:image/jpeg;base64,{b64}"}
|
| 252 |
+
})
|
| 253 |
+
|
| 254 |
+
content_payload.append({"type": "text", "text": query})
|
| 255 |
+
|
| 256 |
+
messages = [
|
| 257 |
+
SystemMessage(content=system_text),
|
| 258 |
+
HumanMessage(content=content_payload)
|
| 259 |
+
]
|
| 260 |
+
|
| 261 |
+
try:
|
| 262 |
+
response = current_llm.invoke(messages)
|
| 263 |
+
return response.content
|
| 264 |
+
except Exception as e:
|
| 265 |
+
print(f"β Groq Error: {e}")
|
| 266 |
+
if "rate_limit" in str(e).lower() or "429" in str(e):
|
| 267 |
+
return (
|
| 268 |
+
"β³ The free-tier request limit was hit. Please wait about a minute "
|
| 269 |
+
"and ask again."
|
| 270 |
+
)
|
| 271 |
+
return "I encountered an error while processing that request. Please try again."
|
backend/ingest.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
import shutil
|
| 4 |
+
import urllib.parse
|
| 5 |
+
from dotenv import load_dotenv
|
| 6 |
+
|
| 7 |
+
# --- LIBRARIES ---
|
| 8 |
+
import torch
|
| 9 |
+
from langchain_community.document_loaders import PyPDFLoader
|
| 10 |
+
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
| 11 |
+
from langchain_community.vectorstores import Chroma
|
| 12 |
+
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 13 |
+
|
| 14 |
+
sys.stdout.reconfigure(encoding="utf-8")
|
| 15 |
+
|
| 16 |
+
# 1. Setup
|
| 17 |
+
load_dotenv()
|
| 18 |
+
DATA_PATH = "./data"
|
| 19 |
+
DB_PATH = "./chroma_db"
|
| 20 |
+
|
| 21 |
+
# Auto-detect hardware: CUDA on your local GTX 1650, CPU on the HF Space.
|
| 22 |
+
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
| 23 |
+
|
| 24 |
+
# Public base URL of the PDFs so citations can link straight to the source file
|
| 25 |
+
# without shipping 599MB of PDFs into the container.
|
| 26 |
+
HF_PDF_BASE = "https://huggingface.co/datasets/Yashkute/sppu-pdf-docs/resolve/main/"
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def main():
|
| 30 |
+
print(f"Initializing Embedding Engine on device: {DEVICE}")
|
| 31 |
+
|
| 32 |
+
embeddings = HuggingFaceEmbeddings(
|
| 33 |
+
model_name="BAAI/bge-base-en-v1.5",
|
| 34 |
+
model_kwargs={"device": DEVICE},
|
| 35 |
+
encode_kwargs={
|
| 36 |
+
"normalize_embeddings": True,
|
| 37 |
+
"batch_size": 32,
|
| 38 |
+
},
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
# --- 1. LOAD EXISTING DB & CHECK PROCESSED FILES ---
|
| 42 |
+
processed_files = set()
|
| 43 |
+
db = None
|
| 44 |
+
|
| 45 |
+
if os.path.exists(DB_PATH):
|
| 46 |
+
print(f"Loading existing database from '{DB_PATH}'...")
|
| 47 |
+
db = Chroma(persist_directory=DB_PATH, embedding_function=embeddings)
|
| 48 |
+
existing_data = db.get(include=["metadatas"])
|
| 49 |
+
processed_files = set(
|
| 50 |
+
meta.get("source") for meta in existing_data["metadatas"] if meta and "source" in meta
|
| 51 |
+
)
|
| 52 |
+
print(f" Found {len(processed_files)} previously processed files in the DB.")
|
| 53 |
+
else:
|
| 54 |
+
print("No existing database found. Creating a new one from scratch.")
|
| 55 |
+
|
| 56 |
+
# --- 2. SCAN FOR NEW PDFs ---
|
| 57 |
+
print(f"\nScanning '{DATA_PATH}' for NEW PDFs...")
|
| 58 |
+
documents = []
|
| 59 |
+
new_files_count = 0
|
| 60 |
+
|
| 61 |
+
for root, dirs, files in os.walk(DATA_PATH):
|
| 62 |
+
for file in files:
|
| 63 |
+
if not file.lower().endswith(".pdf"):
|
| 64 |
+
continue
|
| 65 |
+
if file in processed_files:
|
| 66 |
+
continue
|
| 67 |
+
|
| 68 |
+
file_path = os.path.join(root, file)
|
| 69 |
+
print(f" NEW FILE DETECTED: {file}")
|
| 70 |
+
|
| 71 |
+
rel = os.path.relpath(file_path, DATA_PATH).replace(os.sep, "/")
|
| 72 |
+
source_url = HF_PDF_BASE + urllib.parse.quote(rel)
|
| 73 |
+
|
| 74 |
+
try:
|
| 75 |
+
loader = PyPDFLoader(file_path)
|
| 76 |
+
docs = loader.load()
|
| 77 |
+
for doc in docs:
|
| 78 |
+
doc.metadata["source"] = file
|
| 79 |
+
doc.metadata["source_url"] = source_url
|
| 80 |
+
if getattr(doc, "page_content", "") and doc.page_content.strip():
|
| 81 |
+
documents.append(doc)
|
| 82 |
+
new_files_count += 1
|
| 83 |
+
except Exception as e:
|
| 84 |
+
print(f" Failed to load {file}: {e}")
|
| 85 |
+
|
| 86 |
+
# --- 3. EARLY EXIT IF NOTHING NEW ---
|
| 87 |
+
if not documents:
|
| 88 |
+
print("\nNo new PDFs found. Database is already up to date.")
|
| 89 |
+
return
|
| 90 |
+
|
| 91 |
+
print(f"\nLoaded {new_files_count} new files ({len(documents)} non-empty pages total).")
|
| 92 |
+
|
| 93 |
+
# --- 4. SPLIT TEXT & INJECT METADATA ---
|
| 94 |
+
print("Splitting text into chunks...")
|
| 95 |
+
text_splitter = RecursiveCharacterTextSplitter(
|
| 96 |
+
chunk_size=600,
|
| 97 |
+
chunk_overlap=120,
|
| 98 |
+
separators=["\n\n", "\n", ". ", " ", ""],
|
| 99 |
+
)
|
| 100 |
+
chunks = text_splitter.split_documents(documents)
|
| 101 |
+
|
| 102 |
+
if not chunks:
|
| 103 |
+
print("\nNo text chunks could be created. Skipping vector DB update.")
|
| 104 |
+
return
|
| 105 |
+
|
| 106 |
+
print("Injecting filenames into the text content...")
|
| 107 |
+
for chunk in chunks:
|
| 108 |
+
filename = chunk.metadata.get("source", "Unknown Document")
|
| 109 |
+
chunk.page_content = f"Document Title: {filename}\n\n{chunk.page_content}"
|
| 110 |
+
|
| 111 |
+
print(f" Created and enriched {len(chunks)} text chunks.")
|
| 112 |
+
|
| 113 |
+
# --- 5. UPDATE VECTOR DATABASE ---
|
| 114 |
+
print("Embedding new chunks into the database...")
|
| 115 |
+
BATCH_SIZE = 500
|
| 116 |
+
if db is None:
|
| 117 |
+
db = Chroma.from_documents(
|
| 118 |
+
documents=chunks[:BATCH_SIZE],
|
| 119 |
+
embedding=embeddings,
|
| 120 |
+
persist_directory=DB_PATH,
|
| 121 |
+
)
|
| 122 |
+
remaining = chunks[BATCH_SIZE:]
|
| 123 |
+
else:
|
| 124 |
+
remaining = chunks
|
| 125 |
+
|
| 126 |
+
total_batches = max(1, (len(remaining) - 1) // BATCH_SIZE + 1) if remaining else 0
|
| 127 |
+
for i in range(0, len(remaining), BATCH_SIZE):
|
| 128 |
+
batch = remaining[i:i + BATCH_SIZE]
|
| 129 |
+
db.add_documents(documents=batch)
|
| 130 |
+
print(f" Batch {i // BATCH_SIZE + 1}/{total_batches} embedded")
|
| 131 |
+
|
| 132 |
+
print(f"Success. Database updated at '{DB_PATH}'")
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
if __name__ == "__main__":
|
| 136 |
+
main()
|
backend/pdf_mapping.json
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"LATEST_NOTICE_15062026235719_16062026.pdf": "LATEST_NOTICE_15062026235719_16062026.pdf",
|
| 3 |
+
"LATEST_NOTICE_AT-871-Professor-Law_14062026.pdf": "LATEST_NOTICE_AT-871-Professor-Law_14062026.pdf",
|
| 4 |
+
"LATEST_NOTICE_AT-872-Professor-Statistics_14062026.pdf": "LATEST_NOTICE_AT-872-Professor-Statistics_14062026.pdf",
|
| 5 |
+
"LATEST_NOTICE_AT-873-Professor-Sanskrit_and_Prakrit_Languages)_14062026.pdf": "LATEST_NOTICE_AT-873-Professor-Sanskrit_and_Prakrit_Languages)_14062026.pdf",
|
| 6 |
+
"LATEST_NOTICE_AT-928-Professor-History_19062026.PDF": "LATEST_NOTICE_AT-928-Professor-History_19062026.PDF",
|
| 7 |
+
"LATEST_NOTICE_AT-929-Associate_Professor-History_19062026.PDF": "LATEST_NOTICE_AT-929-Associate_Professor-History_19062026.PDF",
|
| 8 |
+
"LATEST_NOTICE_AT-931-Associate_Professor-Statistics_18062026.PDF": "LATEST_NOTICE_AT-931-Associate_Professor-Statistics_18062026.PDF",
|
| 9 |
+
"LATEST_NOTICE_Circular_no-_106_17062026.pdf": "LATEST_NOTICE_Circular_no-_106_17062026.pdf",
|
| 10 |
+
"LATEST_NOTICE_Circular_No._89-2026_15052026.pdf": "LATEST_NOTICE_Circular_No._89-2026_15052026.pdf",
|
| 11 |
+
"LATEST_NOTICE_FCTM_Admission_Notification_2026_12062026.pdf": "LATEST_NOTICE_FCTM_Admission_Notification_2026_12062026.pdf",
|
| 12 |
+
"LATEST_NOTICE_OEE_Date_Extension_Letter_PGS-2363_15052026.pdf": "LATEST_NOTICE_OEE_Date_Extension_Letter_PGS-2363_15052026.pdf",
|
| 13 |
+
"LATEST_NOTICE_OEE_Extention_Letter_20052026.pdf": "LATEST_NOTICE_OEE_Extention_Letter_20052026.pdf",
|
| 14 |
+
"LATEST_NOTICE_PGS-2063_dt_23042026.pdf": "LATEST_NOTICE_PGS-2063_dt_23042026.pdf",
|
| 15 |
+
"LATEST_NOTICE_ProvisionalScrutiny_Associate_Professor_Statistics_16062026.pdf": "LATEST_NOTICE_ProvisionalScrutiny_Associate_Professor_Statistics_16062026.pdf",
|
| 16 |
+
"be_artificial-intelligence-and-data-science_semester-7_2023_november_data-modeling-&-visualization-dm-&-v-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/DATA MODELING & VISUALIZATION (DM & V) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2023_november_data-modeling-&-visualization-dm-&-v-2019-pattern.pdf",
|
| 17 |
+
"be_artificial-intelligence-and-data-science_semester-7_2023_october_data-modeling-&-visualization-dm-&-v-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/DATA MODELING & VISUALIZATION (DM & V) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2023_october_data-modeling-&-visualization-dm-&-v-2019-pattern.pdf",
|
| 18 |
+
"be_artificial-intelligence-and-data-science_semester-7_2024_october_data-modeling-visualization-dm-v-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/DATA MODELING & VISUALIZATION (DM & V) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2024_october_data-modeling-visualization-dm-v-2019-pattern.pdf",
|
| 19 |
+
"be_artificial-intelligence-and-data-science_semester-7_2025_august_data-modeling-visualization-dm-v-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/DATA MODELING & VISUALIZATION (DM & V) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2025_august_data-modeling-visualization-dm-v-2019-pattern.pdf",
|
| 20 |
+
"be_artificial-intelligence-and-data-science_semester-7_2015_may_industrial-internet-of-things-iiot-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/INDUSTRIAL INTERNET OF THINGS (IIOT) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2015_may_industrial-internet-of-things-iiot-2019-pattern.pdf",
|
| 21 |
+
"be_artificial-intelligence-and-data-science_semester-7_2023_november_industrial-internet-of-things-iiot-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/INDUSTRIAL INTERNET OF THINGS (IIOT) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2023_november_industrial-internet-of-things-iiot-2019-pattern.pdf",
|
| 22 |
+
"be_artificial-intelligence-and-data-science_semester-7_2023_october_industrial-internet-of-things-iiot-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/INDUSTRIAL INTERNET OF THINGS (IIOT) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2023_october_industrial-internet-of-things-iiot-2019-pattern.pdf",
|
| 23 |
+
"be_artificial-intelligence-and-data-science_semester-7_2024_october_industrial-internet-of-things-iiot-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/INDUSTRIAL INTERNET OF THINGS (IIOT) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2024_october_industrial-internet-of-things-iiot-2019-pattern.pdf",
|
| 24 |
+
"be_artificial-intelligence-and-data-science_semester-7_2025_august_industrial-internet-of-things-iiot-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/INDUSTRIAL INTERNET OF THINGS (IIOT) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2025_august_industrial-internet-of-things-iiot-2019-pattern.pdf",
|
| 25 |
+
"be_artificial-intelligence-and-data-science_semester-7_2023_november_information-retrieval-ir-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/INFORMATION RETRIEVAL (IR) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2023_november_information-retrieval-ir-2019-pattern.pdf",
|
| 26 |
+
"be_artificial-intelligence-and-data-science_semester-7_2023_october_information-retrieval-ir-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/INFORMATION RETRIEVAL (IR) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2023_october_information-retrieval-ir-2019-pattern.pdf",
|
| 27 |
+
"be_artificial-intelligence-and-data-science_semester-7_2024_may_information-retrieval-ir-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/INFORMATION RETRIEVAL (IR) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2024_may_information-retrieval-ir-2019-pattern.pdf",
|
| 28 |
+
"be_artificial-intelligence-and-data-science_semester-7_2024_october_information-retrieval-ir-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/INFORMATION RETRIEVAL (IR) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2024_october_information-retrieval-ir-2019-pattern.pdf",
|
| 29 |
+
"be_artificial-intelligence-and-data-science_semester-7_2025_august_information-retrieval-ir-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/INFORMATION RETRIEVAL (IR) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2025_august_information-retrieval-ir-2019-pattern.pdf",
|
| 30 |
+
"be_artificial-intelligence-and-data-science_semester-7_2023_november_machine-learning-ml-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2023_november_machine-learning-ml-2019-pattern.pdf",
|
| 31 |
+
"be_artificial-intelligence-and-data-science_semester-7_2023_october_machine-learning-ml-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2023_october_machine-learning-ml-2019-pattern.pdf",
|
| 32 |
+
"be_artificial-intelligence-and-data-science_semester-7_2024_october_machine-learning-ml-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2024_october_machine-learning-ml-2019-pattern.pdf",
|
| 33 |
+
"be_artificial-intelligence-and-data-science_semester-7_2025_august_machine-learning-ml-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2025_august_machine-learning-ml-2019-pattern.pdf",
|
| 34 |
+
"be_artificial-intelligence-and-data-science_semester-7_2023_november_quantum-artificial-intelligence-qai-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/QUANTUM ARTIFICIAL INTELLIGENCE (QAI) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2023_november_quantum-artificial-intelligence-qai-2019-pattern.pdf",
|
| 35 |
+
"be_artificial-intelligence-and-data-science_semester-7_2023_october_quantum-artificial-intelligence-qai-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/QUANTUM ARTIFICIAL INTELLIGENCE (QAI) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2023_october_quantum-artificial-intelligence-qai-2019-pattern.pdf",
|
| 36 |
+
"be_artificial-intelligence-and-data-science_semester-7_2024_october_quantum-artificial-intelligence-qai-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/QUANTUM ARTIFICIAL INTELLIGENCE (QAI) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2024_october_quantum-artificial-intelligence-qai-2019-pattern.pdf",
|
| 37 |
+
"be_artificial-intelligence-and-data-science_semester-7_2025_august_quantum-artificial-intelligence-qai-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 7/QUANTUM ARTIFICIAL INTELLIGENCE (QAI) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-7_2025_august_quantum-artificial-intelligence-qai-2019-pattern.pdf",
|
| 38 |
+
"be_artificial-intelligence-and-data-science_semester-8_2024_march_big-data-analytics-bda-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/BIG DATA ANALYTICS (BDA) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2024_march_big-data-analytics-bda-2019-pattern.pdf",
|
| 39 |
+
"be_artificial-intelligence-and-data-science_semester-8_2024_may_big-data-analytics-bda-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/BIG DATA ANALYTICS (BDA) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2024_may_big-data-analytics-bda-2019-pattern.pdf",
|
| 40 |
+
"be_artificial-intelligence-and-data-science_semester-8_2024_march_business-intelligence-bi-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/BUSINESS INTELLIGENCE (BI) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2024_march_business-intelligence-bi-2019-pattern.pdf",
|
| 41 |
+
"be_artificial-intelligence-and-data-science_semester-8_2024_may_business-intelligence-bi-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/BUSINESS INTELLIGENCE (BI) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2024_may_business-intelligence-bi-2019-pattern.pdf",
|
| 42 |
+
"be_artificial-intelligence-and-data-science_semester-8_2024_march_computational-intelligence-ci-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/COMPUTATIONAL INTELLIGENCE (CI) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2024_march_computational-intelligence-ci-2019-pattern.pdf",
|
| 43 |
+
"be_artificial-intelligence-and-data-science_semester-8_2024_may_computational-intelligence-ci-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/COMPUTATIONAL INTELLIGENCE (CI) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2024_may_computational-intelligence-ci-2019-pattern.pdf",
|
| 44 |
+
"be_artificial-intelligence-and-data-science_semester-8_2025_may_computational-intelligence-ci-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/COMPUTATIONAL INTELLIGENCE (CI) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2025_may_computational-intelligence-ci-2019-pattern.pdf",
|
| 45 |
+
"be_artificial-intelligence-and-data-science_semester-8_2024_march_deep-learning-dl-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/DEEP LEARNING (DL) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2024_march_deep-learning-dl-2019-pattern.pdf",
|
| 46 |
+
"be_artificial-intelligence-and-data-science_semester-8_2024_may_deep-learning-dl-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/DEEP LEARNING (DL) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2024_may_deep-learning-dl-2019-pattern.pdf",
|
| 47 |
+
"be_artificial-intelligence-and-data-science_semester-8_2025_may_deep-learning-dl-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/DEEP LEARNING (DL) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2025_may_deep-learning-dl-2019-pattern.pdf",
|
| 48 |
+
"be_artificial-intelligence-and-data-science_semester-8_2024_march_distributed-computing-dc-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/DISTRIBUTED COMPUTING (DC) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2024_march_distributed-computing-dc-2019-pattern.pdf",
|
| 49 |
+
"be_artificial-intelligence-and-data-science_semester-8_2024_may_distributed-computing-dc-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/DISTRIBUTED COMPUTING (DC) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2024_may_distributed-computing-dc-2019-pattern.pdf",
|
| 50 |
+
"be_artificial-intelligence-and-data-science_semester-8_2025_may_distributed-computing-dc-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/DISTRIBUTED COMPUTING (DC) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2025_may_distributed-computing-dc-2019-pattern.pdf",
|
| 51 |
+
"be_artificial-intelligence-and-data-science_semester-8_2024_march_reinforcement-learning-rl-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/REINFORCEMENT LEARNING (RL) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2024_march_reinforcement-learning-rl-2019-pattern.pdf",
|
| 52 |
+
"be_artificial-intelligence-and-data-science_semester-8_2024_may_reinforcement-learning-rl-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/REINFORCEMENT LEARNING (RL) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2024_may_reinforcement-learning-rl-2019-pattern.pdf",
|
| 53 |
+
"be_artificial-intelligence-and-data-science_semester-8_2025_may_reinforcement-learning-rl-2019-pattern.pdf": "AIDS(PATTERN-2019)/SEM 8/REINFORCEMENT LEARNING (RL) (2019 PATTERN)/be_artificial-intelligence-and-data-science_semester-8_2025_may_reinforcement-learning-rl-2019-pattern.pdf",
|
| 54 |
+
"BE - AIDS - 2020 Syllabus_03082023.pdf": "B.E 2024 Pattern/BE - AIDS - 2020 Syllabus_03082023.pdf",
|
| 55 |
+
"be_civil-engineering_final-year-be-semester-7-8-2019-pattern.pdf": "B.E 2024 Pattern/be_civil-engineering_final-year-be-semester-7-8-2019-pattern.pdf",
|
| 56 |
+
"be_computer-engineering_final-year-be-semester-7-8-2019-pattern.pdf": "B.E 2024 Pattern/be_computer-engineering_final-year-be-semester-7-8-2019-pattern.pdf",
|
| 57 |
+
"be_electrical-engineering_final-year-be-semester-7-8-2019-pattern.pdf": "B.E 2024 Pattern/be_electrical-engineering_final-year-be-semester-7-8-2019-pattern.pdf",
|
| 58 |
+
"be_electronics-and-telecommunication-engineering_final-year-be-semester-7-8-2019-pattern.pdf": "B.E 2024 Pattern/be_electronics-and-telecommunication-engineering_final-year-be-semester-7-8-2019-pattern.pdf",
|
| 59 |
+
"be_electronics-engineering_final-year-be-semester-7-8-2019-pattern.pdf": "B.E 2024 Pattern/be_electronics-engineering_final-year-be-semester-7-8-2019-pattern.pdf",
|
| 60 |
+
"be_information-technology-engineering_final-year-be-semester-7-8-2019-pattern.pdf": "B.E 2024 Pattern/be_information-technology-engineering_final-year-be-semester-7-8-2019-pattern.pdf",
|
| 61 |
+
"be_mechanical-engineering_final-year-be-semester-7-8-2019-pattern.pdf": "B.E 2024 Pattern/be_mechanical-engineering_final-year-be-semester-7-8-2019-pattern.pdf",
|
| 62 |
+
"be_mechanical-sandwich-engineering_final-year-be-semester-7-8-2019-pattern.pdf": "B.E 2024 Pattern/be_mechanical-sandwich-engineering_final-year-be-semester-7-8-2019-pattern.pdf",
|
| 63 |
+
"BE AIML April 2024.pdf": "B.E AIML(PATTERN-2019)/SEM 7/BE AIML April 2024.pdf",
|
| 64 |
+
"BE AIML April 2025.pdf": "B.E AIML(PATTERN-2019)/SEM 7/BE AIML April 2025.pdf",
|
| 65 |
+
"BE AIML nov 2024.pdf": "B.E AIML(PATTERN-2019)/SEM 7/BE AIML nov 2024.pdf",
|
| 66 |
+
"BE AIML OCT 2023.pdf": "B.E AIML(PATTERN-2019)/SEM 7/BE AIML OCT 2023.pdf",
|
| 67 |
+
"B.E ( 2019 PATTERN )1.pdf": "B.E(PATTERN-2019)/B.E ( 2019 PATTERN )1.pdf",
|
| 68 |
+
"B.E ( 2019 PATTERN )2.pdf": "B.E(PATTERN-2019)/B.E ( 2019 PATTERN )2.pdf",
|
| 69 |
+
"B.E ( 2019 PATTERN )3.pdf": "B.E(PATTERN-2019)/B.E ( 2019 PATTERN )3.pdf",
|
| 70 |
+
"be_computer-engineering_semester-7_2022_november_blockchain-technology-bt-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/BLOCKCHAIN TECHNOLOGY (BT) (PATTERN-2019)/be_computer-engineering_semester-7_2022_november_blockchain-technology-bt-pattern-2019.pdf",
|
| 71 |
+
"be_computer-engineering_semester-7_2022_october_blockchain-technology-bt-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/BLOCKCHAIN TECHNOLOGY (BT) (PATTERN-2019)/be_computer-engineering_semester-7_2022_october_blockchain-technology-bt-pattern-2019.pdf",
|
| 72 |
+
"be_computer-engineering_semester-7_2023_november_blockchain-technology-bt-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/BLOCKCHAIN TECHNOLOGY (BT) (PATTERN-2019)/be_computer-engineering_semester-7_2023_november_blockchain-technology-bt-pattern-2019.pdf",
|
| 73 |
+
"be_computer-engineering_semester-7_2023_october_blockchain-technology-bt-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/BLOCKCHAIN TECHNOLOGY (BT) (PATTERN-2019)/be_computer-engineering_semester-7_2023_october_blockchain-technology-bt-pattern-2019.pdf",
|
| 74 |
+
"be_computer-engineering_semester-7_2024_may_blockchain-technology-bt-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/BLOCKCHAIN TECHNOLOGY (BT) (PATTERN-2019)/be_computer-engineering_semester-7_2024_may_blockchain-technology-bt-pattern-2019.pdf",
|
| 75 |
+
"be_computer-engineering_semester-7_2024_october_blockchain-technology-bt-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/BLOCKCHAIN TECHNOLOGY (BT) (PATTERN-2019)/be_computer-engineering_semester-7_2024_october_blockchain-technology-bt-pattern-2019.pdf",
|
| 76 |
+
"be_computer-engineering_semester-7_2025_august_blockchain-technology-bt-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/BLOCKCHAIN TECHNOLOGY (BT) (PATTERN-2019)/be_computer-engineering_semester-7_2025_august_blockchain-technology-bt-pattern-2019.pdf",
|
| 77 |
+
"be_computer-engineering_semester-7_2025_may_blockchain-technology-bt-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/BLOCKCHAIN TECHNOLOGY (BT) (PATTERN-2019)/be_computer-engineering_semester-7_2025_may_blockchain-technology-bt-pattern-2019.pdf",
|
| 78 |
+
"be_computer-engineering_semester-7_2022_may_cyber-security-and-digital-forensics-cs-&-df-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/CYBER SECURITY AND DIGITAL FORENSICS (CS & DF) (PATTERN-2019)/be_computer-engineering_semester-7_2022_may_cyber-security-and-digital-forensics-cs-&-df-pattern-2019.pdf",
|
| 79 |
+
"be_computer-engineering_semester-7_2022_november_cyber-security-and-digital-forensics-cs-&-df-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/CYBER SECURITY AND DIGITAL FORENSICS (CS & DF) (PATTERN-2019)/be_computer-engineering_semester-7_2022_november_cyber-security-and-digital-forensics-cs-&-df-pattern-2019.pdf",
|
| 80 |
+
"be_computer-engineering_semester-7_2022_october_cyber-security-and-digital-forensics-cs-&-df-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/CYBER SECURITY AND DIGITAL FORENSICS (CS & DF) (PATTERN-2019)/be_computer-engineering_semester-7_2022_october_cyber-security-and-digital-forensics-cs-&-df-pattern-2019.pdf",
|
| 81 |
+
"be_computer-engineering_semester-7_2023_may_cyber-security-and-digital-forensics-cs-&-df-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/CYBER SECURITY AND DIGITAL FORENSICS (CS & DF) (PATTERN-2019)/be_computer-engineering_semester-7_2023_may_cyber-security-and-digital-forensics-cs-&-df-pattern-2019.pdf",
|
| 82 |
+
"be_computer-engineering_semester-7_2023_november_cyber-security-and-digital-forensics-cs-df-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/CYBER SECURITY AND DIGITAL FORENSICS (CS & DF) (PATTERN-2019)/be_computer-engineering_semester-7_2023_november_cyber-security-and-digital-forensics-cs-df-pattern-2019.pdf",
|
| 83 |
+
"be_computer-engineering_semester-7_2023_october_cyber-security-and-digital-forensics-cs-df-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/CYBER SECURITY AND DIGITAL FORENSICS (CS & DF) (PATTERN-2019)/be_computer-engineering_semester-7_2023_october_cyber-security-and-digital-forensics-cs-df-pattern-2019.pdf",
|
| 84 |
+
"be_computer-engineering_semester-7_2024_may_cyber-security-and-digital-forensics-cs-df-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/CYBER SECURITY AND DIGITAL FORENSICS (CS & DF) (PATTERN-2019)/be_computer-engineering_semester-7_2024_may_cyber-security-and-digital-forensics-cs-df-pattern-2019.pdf",
|
| 85 |
+
"be_computer-engineering_semester-7_2024_october_cyber-security-and-digital-forensics-cs-df-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/CYBER SECURITY AND DIGITAL FORENSICS (CS & DF) (PATTERN-2019)/be_computer-engineering_semester-7_2024_october_cyber-security-and-digital-forensics-cs-df-pattern-2019.pdf",
|
| 86 |
+
"be_computer-engineering_semester-7_2025_august_cyber-security-and-digital-forensics-cs-df-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/CYBER SECURITY AND DIGITAL FORENSICS (CS & DF) (PATTERN-2019)/be_computer-engineering_semester-7_2025_august_cyber-security-and-digital-forensics-cs-df-pattern-2019.pdf",
|
| 87 |
+
"be_computer-engineering_semester-7_2025_may_cyber-security-and-digital-forensics-cs-df-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/CYBER SECURITY AND DIGITAL FORENSICS (CS & DF) (PATTERN-2019)/be_computer-engineering_semester-7_2025_may_cyber-security-and-digital-forensics-cs-df-pattern-2019.pdf",
|
| 88 |
+
"be_computer-engineering_semester-7_2022_november_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/DESIGN AND ANALYSIS OF ALGORITHMS (D & AOA) (PATTERN-2019)/be_computer-engineering_semester-7_2022_november_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf",
|
| 89 |
+
"be_computer-engineering_semester-7_2022_october_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/DESIGN AND ANALYSIS OF ALGORITHMS (D & AOA) (PATTERN-2019)/be_computer-engineering_semester-7_2022_october_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf",
|
| 90 |
+
"be_computer-engineering_semester-7_2023_november_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/DESIGN AND ANALYSIS OF ALGORITHMS (D & AOA) (PATTERN-2019)/be_computer-engineering_semester-7_2023_november_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf",
|
| 91 |
+
"be_computer-engineering_semester-7_2023_october_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/DESIGN AND ANALYSIS OF ALGORITHMS (D & AOA) (PATTERN-2019)/be_computer-engineering_semester-7_2023_october_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf",
|
| 92 |
+
"be_computer-engineering_semester-7_2024_may_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/DESIGN AND ANALYSIS OF ALGORITHMS (D & AOA) (PATTERN-2019)/be_computer-engineering_semester-7_2024_may_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf",
|
| 93 |
+
"be_computer-engineering_semester-7_2024_october_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/DESIGN AND ANALYSIS OF ALGORITHMS (D & AOA) (PATTERN-2019)/be_computer-engineering_semester-7_2024_october_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf",
|
| 94 |
+
"be_computer-engineering_semester-7_2025_august_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/DESIGN AND ANALYSIS OF ALGORITHMS (D & AOA) (PATTERN-2019)/be_computer-engineering_semester-7_2025_august_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf",
|
| 95 |
+
"be_computer-engineering_semester-7_2025_may_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/DESIGN AND ANALYSIS OF ALGORITHMS (D & AOA) (PATTERN-2019)/be_computer-engineering_semester-7_2025_may_design-and-analysis-of-algorithms-d-aoa-pattern-2019.pdf",
|
| 96 |
+
"be_computer-engineering_semester-7_2022_november_machine-learning-ml-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (PATTERN-2019)/be_computer-engineering_semester-7_2022_november_machine-learning-ml-pattern-2019.pdf",
|
| 97 |
+
"be_computer-engineering_semester-7_2022_october_machine-learning-ml-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (PATTERN-2019)/be_computer-engineering_semester-7_2022_october_machine-learning-ml-pattern-2019.pdf",
|
| 98 |
+
"be_computer-engineering_semester-7_2023_may_machine-learning-ml-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (PATTERN-2019)/be_computer-engineering_semester-7_2023_may_machine-learning-ml-pattern-2019.pdf",
|
| 99 |
+
"be_computer-engineering_semester-7_2023_november_machine-learning-ml-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (PATTERN-2019)/be_computer-engineering_semester-7_2023_november_machine-learning-ml-pattern-2019.pdf",
|
| 100 |
+
"be_computer-engineering_semester-7_2023_october_machine-learning-ml-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (PATTERN-2019)/be_computer-engineering_semester-7_2023_october_machine-learning-ml-pattern-2019.pdf",
|
| 101 |
+
"be_computer-engineering_semester-7_2024_may_machine-learning-ml-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (PATTERN-2019)/be_computer-engineering_semester-7_2024_may_machine-learning-ml-pattern-2019.pdf",
|
| 102 |
+
"be_computer-engineering_semester-7_2024_october_machine-learning-ml-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (PATTERN-2019)/be_computer-engineering_semester-7_2024_october_machine-learning-ml-pattern-2019.pdf",
|
| 103 |
+
"be_computer-engineering_semester-7_2025_august_machine-learning-ml-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (PATTERN-2019)/be_computer-engineering_semester-7_2025_august_machine-learning-ml-pattern-2019.pdf",
|
| 104 |
+
"be_computer-engineering_semester-7_2025_may_machine-learning-ml-pattern-2019.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 7/MACHINE LEARNING (ML) (PATTERN-2019)/be_computer-engineering_semester-7_2025_may_machine-learning-ml-pattern-2019.pdf",
|
| 105 |
+
"be_computer-engineering_semester-8_2023_february_deep-learning-2019-pattern (1).pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/DEEP LEARNING (2019 PATTERN)/be_computer-engineering_semester-8_2023_february_deep-learning-2019-pattern (1).pdf",
|
| 106 |
+
"be_computer-engineering_semester-8_2023_february_deep-learning-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/DEEP LEARNING (2019 PATTERN)/be_computer-engineering_semester-8_2023_february_deep-learning-2019-pattern.pdf",
|
| 107 |
+
"be_computer-engineering_semester-8_2023_may_deep-learning-2019-pattern (1).pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/DEEP LEARNING (2019 PATTERN)/be_computer-engineering_semester-8_2023_may_deep-learning-2019-pattern (1).pdf",
|
| 108 |
+
"be_computer-engineering_semester-8_2023_may_deep-learning-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/DEEP LEARNING (2019 PATTERN)/be_computer-engineering_semester-8_2023_may_deep-learning-2019-pattern.pdf",
|
| 109 |
+
"be_computer-engineering_semester-8_2023_november_deep-learning-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/DEEP LEARNING (2019 PATTERN)/be_computer-engineering_semester-8_2023_november_deep-learning-2019-pattern.pdf",
|
| 110 |
+
"be_computer-engineering_semester-8_2024_march_deep-learning-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/DEEP LEARNING (2019 PATTERN)/be_computer-engineering_semester-8_2024_march_deep-learning-2019-pattern.pdf",
|
| 111 |
+
"be_computer-engineering_semester-8_2024_may_deep-learning-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/DEEP LEARNING (2019 PATTERN)/be_computer-engineering_semester-8_2024_may_deep-learning-2019-pattern.pdf",
|
| 112 |
+
"be_computer-engineering_semester-8_2025_may_deep-learning-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/DEEP LEARNING (2019 PATTERN)/be_computer-engineering_semester-8_2025_may_deep-learning-2019-pattern.pdf",
|
| 113 |
+
"be_computer-engineering_semester-8_2023_february_high-performance-computing-hpc-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/HIGH PERFORMANCE COMPUTING (HPC) (2019 PATTERN)/be_computer-engineering_semester-8_2023_february_high-performance-computing-hpc-2019-pattern.pdf",
|
| 114 |
+
"be_computer-engineering_semester-8_2023_may_high-performance-computing-hpc-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/HIGH PERFORMANCE COMPUTING (HPC) (2019 PATTERN)/be_computer-engineering_semester-8_2023_may_high-performance-computing-hpc-2019-pattern.pdf",
|
| 115 |
+
"be_computer-engineering_semester-8_2024_march_high-performance-computing-hpc-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/HIGH PERFORMANCE COMPUTING (HPC) (2019 PATTERN)/be_computer-engineering_semester-8_2024_march_high-performance-computing-hpc-2019-pattern.pdf",
|
| 116 |
+
"be_computer-engineering_semester-8_2024_may_high-performance-computing-hpc-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/HIGH PERFORMANCE COMPUTING (HPC) (2019 PATTERN)/be_computer-engineering_semester-8_2024_may_high-performance-computing-hpc-2019-pattern.pdf",
|
| 117 |
+
"be_computer-engineering_semester-8_2025_may_high-performance-computing-hpc-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/HIGH PERFORMANCE COMPUTING (HPC) (2019 PATTERN)/be_computer-engineering_semester-8_2025_may_high-performance-computing-hpc-2019-pattern.pdf",
|
| 118 |
+
"be_computer-engineering_semester-8_2023_february_natural-language-processing-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/NATURAL LANGUAGE PROCESSING (2019 PATTERN)/be_computer-engineering_semester-8_2023_february_natural-language-processing-2019-pattern.pdf",
|
| 119 |
+
"be_computer-engineering_semester-8_2023_may_natural-language-processing-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/NATURAL LANGUAGE PROCESSING (2019 PATTERN)/be_computer-engineering_semester-8_2023_may_natural-language-processing-2019-pattern.pdf",
|
| 120 |
+
"be_computer-engineering_semester-8_2023_november_natural-language-processing-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/NATURAL LANGUAGE PROCESSING (2019 PATTERN)/be_computer-engineering_semester-8_2023_november_natural-language-processing-2019-pattern.pdf",
|
| 121 |
+
"be_computer-engineering_semester-8_2024_march_natural-language-processing-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/NATURAL LANGUAGE PROCESSING (2019 PATTERN)/be_computer-engineering_semester-8_2024_march_natural-language-processing-2019-pattern.pdf",
|
| 122 |
+
"be_computer-engineering_semester-8_2024_may_natural-language-processing-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/NATURAL LANGUAGE PROCESSING (2019 PATTERN)/be_computer-engineering_semester-8_2024_may_natural-language-processing-2019-pattern.pdf",
|
| 123 |
+
"be_computer-engineering_semester-8_2025_may_natural-language-processing-2019-pattern.pdf": "COMPUTER ENGINEERING(PATTERN-2019)/SEM 8/NATURAL LANGUAGE PROCESSING (2019 PATTERN)/be_computer-engineering_semester-8_2025_may_natural-language-processing-2019-pattern.pdf",
|
| 124 |
+
"B.E ( 2008 PATTERN ).pdf": "Data/Data/B.E ( 2008 PATTERN ).pdf",
|
| 125 |
+
"B.E ( 2012 PATTERN ).pdf": "Data/Data/B.E ( 2012 PATTERN ).pdf",
|
| 126 |
+
"B.E ( 2015 PATTERN ).pdf": "Data/Data/B.E ( 2015 PATTERN ).pdf",
|
| 127 |
+
"F.E ( 2015 PATTERN ).pdf": "Data/Data/F.E ( 2015 PATTERN ).pdf",
|
| 128 |
+
"M.E ( 2017 PATTERN ).pdf": "Data/Data/M.E ( 2017 PATTERN ).pdf",
|
| 129 |
+
"M.E ( 2008-2012 PATTERN ).pdf": "Data/Data/M.E ( 2008-2012 PATTERN ).pdf",
|
| 130 |
+
"S.E ( 2015 PATTERN ).pdf": "Data/Data/S.E ( 2015 PATTERN ).pdf",
|
| 131 |
+
"T.E ( 2008-2012 PATTERN ).pdf": "Data/Data/T.E ( 2008-2012 PATTERN ).pdf",
|
| 132 |
+
"T.E ( 2015 PATTERN ).pdf": "Data/Data/T.E ( 2015 PATTERN ).pdf",
|
| 133 |
+
"F.E ( 2019 PATTERN )1.pdf": "F.E (PATTERN-2019)/F.E ( 2019 PATTERN )1.pdf",
|
| 134 |
+
"F.E ( 2019 PATTERN ) 4.pdf": "F.E (PATTERN-2019)/F.E ( 2019 PATTERN ) 4.pdf",
|
| 135 |
+
"F.E ( 2019 PATTERN )2 .pdf": "F.E (PATTERN-2019)/F.E ( 2019 PATTERN )2 .pdf",
|
| 136 |
+
"F.E ( 2019 PATTERN )3.pdf": "F.E (PATTERN-2019)/F.E ( 2019 PATTERN )3.pdf",
|
| 137 |
+
"SPPU FE 2024 [2024-2025] Pattern Syllabus.pdf": "FE 2024 Pattern/SPPU FE 2024 [2024-2025] Pattern Syllabus.pdf",
|
| 138 |
+
"F.E. 2024 PATTERN SEM 1 QP.pdf": "FE 2024 Pattern/Sem 1/F.E. 2024 PATTERN SEM 1 QP.pdf",
|
| 139 |
+
"BEE_Unit 1 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Basic Electrical Engineering Notes/BEE_Unit 1 Notes_2024 Pattern.pdf",
|
| 140 |
+
"BEE_Unit 3 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Basic Electrical Engineering Notes/BEE_Unit 3 Notes_2024 Pattern.pdf",
|
| 141 |
+
"BEE_Unit 4 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Basic Electrical Engineering Notes/BEE_Unit 4 Notes_2024 Pattern.pdf",
|
| 142 |
+
"BEE_Unit 5 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Basic Electrical Engineering Notes/BEE_Unit 5 Notes_2024 Pattern.pdf",
|
| 143 |
+
"Chem_Unit_1_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Engineering Chemistry Notes/Chem_Unit_1_Notes_2024 Pattern.pdf",
|
| 144 |
+
"Chem_Unit_2_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Engineering Chemistry Notes/Chem_Unit_2_Notes_2024 Pattern.pdf",
|
| 145 |
+
"Chem_Unit_3_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Engineering Chemistry Notes/Chem_Unit_3_Notes_2024 Pattern.pdf",
|
| 146 |
+
"Chem_Unit_4_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Engineering Chemistry Notes/Chem_Unit_4_Notes_2024 Pattern.pdf",
|
| 147 |
+
"Chem_Unit_5_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Engineering Chemistry Notes/Chem_Unit_5_Notes_2024 Pattern.pdf",
|
| 148 |
+
"M1_Unit 1 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Engineering Mathematics Notes/M1_Unit 1 Notes_2024 Pattern.pdf",
|
| 149 |
+
"M1_Unit 2 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Engineering Mathematics Notes/M1_Unit 2 Notes_2024 Pattern.pdf",
|
| 150 |
+
"M1_Unit 4 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Engineering Mathematics Notes/M1_Unit 4 Notes_2024 Pattern.pdf",
|
| 151 |
+
"M1_Unit 5 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/Engineering Mathematics Notes/M1_Unit 5 Notes_2024 Pattern.pdf",
|
| 152 |
+
"FPL Unit 1_StudyMedia.pdf": "FE 2024 Pattern/Sem 1/FPL Notes/FPL Unit 1_StudyMedia.pdf",
|
| 153 |
+
"FPL Unit 2_StudyMedia.pdf": "FE 2024 Pattern/Sem 1/FPL Notes/FPL Unit 2_StudyMedia.pdf",
|
| 154 |
+
"FPL Unit 3_StudyMedia.pdf": "FE 2024 Pattern/Sem 1/FPL Notes/FPL Unit 3_StudyMedia.pdf",
|
| 155 |
+
"FPL Unit 4_StudyMedia.pdf": "FE 2024 Pattern/Sem 1/FPL Notes/FPL Unit 4_StudyMedia.pdf",
|
| 156 |
+
"FPL Unit 5_StudyMedia.pdf": "FE 2024 Pattern/Sem 1/FPL Notes/FPL Unit 5_StudyMedia.pdf",
|
| 157 |
+
"PPS_Unit 1 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/PPS Notes/PPS_Unit 1 Notes_2024 Pattern.pdf",
|
| 158 |
+
"PPS_Unit_2_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/PPS Notes/PPS_Unit_2_Notes_2024 Pattern.pdf",
|
| 159 |
+
"PPS_Unit_3_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/PPS Notes/PPS_Unit_3_Notes_2024 Pattern.pdf",
|
| 160 |
+
"PPS_Unit_4_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/PPS Notes/PPS_Unit_4_Notes_2024 Pattern.pdf",
|
| 161 |
+
"PPS_Unit_5_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 1/PPS Notes/PPS_Unit_5_Notes_2024 Pattern.pdf",
|
| 162 |
+
"F.E. 2024 PATTERN SEM 2 QP April 2025.pdf": "FE 2024 Pattern/Sem 2/F.E. 2024 PATTERN SEM 2 QP April 2025.pdf",
|
| 163 |
+
"BXE_Unit 1 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Basic Electronics Engineering/BXE_Unit 1 Notes_2024 Pattern.pdf",
|
| 164 |
+
"BXE_Unit 2 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Basic Electronics Engineering/BXE_Unit 2 Notes_2024 Pattern.pdf",
|
| 165 |
+
"BXE_Unit 3 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Basic Electronics Engineering/BXE_Unit 3 Notes_2024 Pattern.pdf",
|
| 166 |
+
"BXE_Unit 4 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Basic Electronics Engineering/BXE_Unit 4 Notes_2024 Pattern.pdf",
|
| 167 |
+
"BXE_Unit 5 Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Basic Electronics Engineering/BXE_Unit 5 Notes_2024 Pattern.pdf",
|
| 168 |
+
"EG Unit 1_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Engineering Graphics/EG Unit 1_Notes_2024 Pattern.pdf",
|
| 169 |
+
"EG Unit 2_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Engineering Graphics/EG Unit 2_Notes_2024 Pattern.pdf",
|
| 170 |
+
"EG Unit 3_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Engineering Graphics/EG Unit 3_Notes_2024 Pattern.pdf",
|
| 171 |
+
"EG Unit 4_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Engineering Graphics/EG Unit 4_Notes_2024 Pattern.pdf",
|
| 172 |
+
"EG Unit 5_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Engineering Graphics/EG Unit 5_Notes_2024 Pattern.pdf",
|
| 173 |
+
"PPT_ M2 Unit 1.pdf": "FE 2024 Pattern/Sem 2/Engineering Mathematics-II/PPT_ M2 Unit 1.pdf",
|
| 174 |
+
"PPT_ M2 Unit 2.pdf": "FE 2024 Pattern/Sem 2/Engineering Mathematics-II/PPT_ M2 Unit 2.pdf",
|
| 175 |
+
"PPT_ M2 Unit 3.pdf": "FE 2024 Pattern/Sem 2/Engineering Mathematics-II/PPT_ M2 Unit 3.pdf",
|
| 176 |
+
"PPT_ M2 Unit 4.pdf": "FE 2024 Pattern/Sem 2/Engineering Mathematics-II/PPT_ M2 Unit 4.pdf",
|
| 177 |
+
"PPT_ M2 Unit 5.pdf": "FE 2024 Pattern/Sem 2/Engineering Mathematics-II/PPT_ M2 Unit 5.pdf",
|
| 178 |
+
"PPT_ M2 Unit 6.pdf": "FE 2024 Pattern/Sem 2/Engineering Mathematics-II/PPT_ M2 Unit 6.pdf",
|
| 179 |
+
"EM Unit 1.pdf": "FE 2024 Pattern/Sem 2/Engineering Mechanics/EM Unit 1.pdf",
|
| 180 |
+
"EM Unit 2.pdf": "FE 2024 Pattern/Sem 2/Engineering Mechanics/EM Unit 2.pdf",
|
| 181 |
+
"EM Unit 5.pdf": "FE 2024 Pattern/Sem 2/Engineering Mechanics/EM Unit 5.pdf",
|
| 182 |
+
"PHY_Unit 2 PPT_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Engineering Physics/PHY_Unit 2 PPT_2024 Pattern.pdf",
|
| 183 |
+
"PHY_Unit_1_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Engineering Physics/PHY_Unit_1_Notes_2024 Pattern.pdf",
|
| 184 |
+
"PHY_Unit_2_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Engineering Physics/PHY_Unit_2_Notes_2024 Pattern.pdf",
|
| 185 |
+
"PHY_Unit_5_Notes_2024 Pattern.pdf": "FE 2024 Pattern/Sem 2/Engineering Physics/PHY_Unit_5_Notes_2024 Pattern.pdf",
|
| 186 |
+
"be_first-year-fe-engineering_semester-1_2025_april_basic-electrical-engineering-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/BASIC ELECTRICAL ENGINEERING (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_april_basic-electrical-engineering-pattern-2024.pdf",
|
| 187 |
+
"be_first-year-fe-engineering_semester-1_2025_november_basic-electrical-engineering-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/BASIC ELECTRICAL ENGINEERING (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_november_basic-electrical-engineering-pattern-2024.pdf",
|
| 188 |
+
"be_first-year-fe-engineering_semester-1_2025_april_basic-electronics-engineering-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/BASIC ELECTRONICS ENGINEERING (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_april_basic-electronics-engineering-pattern-2024.pdf",
|
| 189 |
+
"be_first-year-fe-engineering_semester-1_2025_november_basic-electronics-engineering-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/BASIC ELECTRONICS ENGINEERING (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_november_basic-electronics-engineering-pattern-2024.pdf",
|
| 190 |
+
"be_first-year-fe-engineering_semester-1_2025_april_engineering-chemistry-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/ENGINEERING CHEMISTRY (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_april_engineering-chemistry-pattern-2024.pdf",
|
| 191 |
+
"be_first-year-fe-engineering_semester-1_2025_november_engineering-chemistry-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/ENGINEERING CHEMISTRY (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_november_engineering-chemistry-pattern-2024.pdf",
|
| 192 |
+
"be_first-year-fe-engineering_semester-1_2024_november_engineering-graphics-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/ENGINEERING GRAPHICS (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2024_november_engineering-graphics-pattern-2024.pdf",
|
| 193 |
+
"be_first-year-fe-engineering_semester-1_2025_april_engineering-graphics-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/ENGINEERING GRAPHICS (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_april_engineering-graphics-pattern-2024.pdf",
|
| 194 |
+
"be_first-year-fe-engineering_semester-1_2025_april_engineering-mathematics-i-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/ENGINEERING MATHEMATICS-I (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_april_engineering-mathematics-i-pattern-2024.pdf",
|
| 195 |
+
"be_first-year-fe-engineering_semester-1_2025_november_engineering-mathematics-i-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/ENGINEERING MATHEMATICS-I (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_november_engineering-mathematics-i-pattern-2024.pdf",
|
| 196 |
+
"be_first-year-fe-engineering_semester-1_2025_april_engineering-mechanics-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/ENGINEERING MECHANICS (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_april_engineering-mechanics-pattern-2024.pdf",
|
| 197 |
+
"be_first-year-fe-engineering_semester-1_2025_november_engineering-mechanics-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/ENGINEERING MECHANICS (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_november_engineering-mechanics-pattern-2024.pdf",
|
| 198 |
+
"be_first-year-fe-engineering_semester-1_2025_april_engineering-physics-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/ENGINEERING PHYSICS (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_april_engineering-physics-pattern-2024.pdf",
|
| 199 |
+
"be_first-year-fe-engineering_semester-1_2025_november_engineering-physics-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/ENGINEERING PHYSICS (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_november_engineering-physics-pattern-2024.pdf",
|
| 200 |
+
"be_first-year-fe-engineering_semester-1_2025_april_fundamentals-of-programming-languages-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/FUNDAMENTALS OF PROGRAMMING LANGUAGES (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_april_fundamentals-of-programming-languages-pattern-2024.pdf",
|
| 201 |
+
"be_first-year-fe-engineering_semester-1_2025_november_fundamentals-of-programming-languages-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 1/FUNDAMENTALS OF PROGRAMMING LANGUAGES (PATTERN 2024)/be_first-year-fe-engineering_semester-1_2025_november_fundamentals-of-programming-languages-pattern-2024.pdf",
|
| 202 |
+
"be_first-year-fe-engineering_semester-2_2024_april_engineering-mathematics-ii-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 2/ENGINEERING MATHEMATICS-II (PATTERN 2024)/be_first-year-fe-engineering_semester-2_2024_april_engineering-mathematics-ii-pattern-2024.pdf",
|
| 203 |
+
"be_first-year-fe-engineering_semester-2_2025_april_programming-and-problem-solving-pattern-2024.pdf": "FIRST YEAR ENGINEERING(PATTERN-2024)/SEM 2/PROGRAMMING AND PROBLEM SOLVING (PATTERN 2024)/be_first-year-fe-engineering_semester-2_2025_april_programming-and-problem-solving-pattern-2024.pdf",
|
| 204 |
+
"S.E ( 2019 PATTERN )1.pdf": "S.E(PATTERN-2019)/S.E ( 2019 PATTERN )1.pdf",
|
| 205 |
+
"S.E ( 2019 PATTERN )2.pdf": "S.E(PATTERN-2019)/S.E ( 2019 PATTERN )2.pdf",
|
| 206 |
+
"S.E ( 2019 PATTERN )3.pdf": "S.E(PATTERN-2019)/S.E ( 2019 PATTERN )3.pdf",
|
| 207 |
+
"S.E ( 2019 PATTERN )4.pdf": "S.E(PATTERN-2019)/S.E ( 2019 PATTERN )4.pdf",
|
| 208 |
+
"SE - AIandDS - 2024 Pattern_18072025.pdf": "SE 2024 Pattern/SE - AIandDS - 2024 Pattern_18072025.pdf",
|
| 209 |
+
"SE - Computer Engineering - 2024 Pattern_18072025.pdf": "SE 2024 Pattern/SE - Computer Engineering - 2024 Pattern_18072025.pdf",
|
| 210 |
+
"SE IT 2024 Pattern Syllabus_15072025.pdf": "SE 2024 Pattern/SE IT 2024 Pattern Syllabus_15072025.pdf",
|
| 211 |
+
"SE-Civil2024_pattern-_final_version_22072025.pdf": "SE 2024 Pattern/SE-Civil2024_pattern-_final_version_22072025.pdf",
|
| 212 |
+
"SE_EandC_Syllabus_2024 NEP Patt _R2_AY_25-26_21072025.pdf": "SE 2024 Pattern/SE_EandC_Syllabus_2024 NEP Patt _R2_AY_25-26_21072025.pdf",
|
| 213 |
+
"SE_EandTC_NEP 2024 Pat_R2_AY_ 25-26._21072025.pdf": "SE 2024 Pattern/SE_EandTC_NEP 2024 Pat_R2_AY_ 25-26._21072025.pdf",
|
| 214 |
+
"SE_Electrical_Syllabus_2024_pattern_14th_July_15072025.pdf": "SE 2024 Pattern/SE_Electrical_Syllabus_2024_pattern_14th_July_15072025.pdf",
|
| 215 |
+
"T.E ( 2019 PATTERN )1.pdf": "T.E(PATTERN-2019)/T.E ( 2019 PATTERN )1.pdf",
|
| 216 |
+
"T.E ( 2019 PATTERN )2.pdf": "T.E(PATTERN-2019)/T.E ( 2019 PATTERN )2.pdf",
|
| 217 |
+
"T.E ( 2019 PATTERN )3.pdf": "T.E(PATTERN-2019)/T.E ( 2019 PATTERN )3.pdf",
|
| 218 |
+
"T.E ( 2019 PATTERN )4.pdf": "T.E(PATTERN-2019)/T.E ( 2019 PATTERN )4.pdf"
|
| 219 |
+
}
|
backend/requirements.txt
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --- API & SERVER ---
|
| 2 |
+
fastapi==0.129.0
|
| 3 |
+
uvicorn==0.41.0
|
| 4 |
+
python-multipart==0.0.9
|
| 5 |
+
pydantic==2.12.5
|
| 6 |
+
|
| 7 |
+
# --- ENVIRONMENT & UTILS ---
|
| 8 |
+
python-dotenv==1.2.1
|
| 9 |
+
Pillow==12.1.1
|
| 10 |
+
numpy<2.0.0
|
| 11 |
+
requests
|
| 12 |
+
beautifulsoup4
|
| 13 |
+
|
| 14 |
+
# --- LANGCHAIN ECOSYSTEM ---
|
| 15 |
+
# Capped below 1.0 - LangChain 1.x moves the langchain_community imports used here.
|
| 16 |
+
langchain>=0.3,<1.0
|
| 17 |
+
langchain-core>=0.3,<1.0
|
| 18 |
+
langchain-community>=0.3,<1.0
|
| 19 |
+
langchain-huggingface>=0.1,<1.0
|
| 20 |
+
langchain-text-splitters>=0.3,<1.0
|
| 21 |
+
langchain-groq>=0.2,<1.0
|
| 22 |
+
langgraph>=0.2,<1.0
|
| 23 |
+
groq
|
| 24 |
+
|
| 25 |
+
# --- HF HUB (startup PDF download) ---
|
| 26 |
+
huggingface_hub>=0.23,<1.0
|
| 27 |
+
|
| 28 |
+
# --- VOICE / TTS ENGINE ---
|
| 29 |
+
edge-tts
|
| 30 |
+
|
| 31 |
+
# --- VECTOR DATABASE & INGESTION ---
|
| 32 |
+
torch
|
| 33 |
+
sentence-transformers==2.6.1
|
| 34 |
+
chromadb==0.4.24
|
| 35 |
+
pypdf==4.2.0
|
backend/scraper.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import re
|
| 3 |
+
from datetime import datetime
|
| 4 |
+
from urllib.parse import urlparse, quote
|
| 5 |
+
|
| 6 |
+
import requests
|
| 7 |
+
from bs4 import BeautifulSoup
|
| 8 |
+
|
| 9 |
+
DATA_FOLDER = "./data"
|
| 10 |
+
if not os.path.exists(DATA_FOLDER):
|
| 11 |
+
alt = os.path.join(os.path.dirname(__file__), "data")
|
| 12 |
+
if os.path.exists(alt):
|
| 13 |
+
DATA_FOLDER = alt
|
| 14 |
+
|
| 15 |
+
TARGET_URLS = [
|
| 16 |
+
"http://sppudocs.unipune.ac.in/sites/circulars/Admission%20Circulars/Forms/AllItems.aspx",
|
| 17 |
+
"http://sppudocs.unipune.ac.in/sites/circulars/Administrative%20Circulars%20%20Teaching/Forms/AllItems.aspx",
|
| 18 |
+
]
|
| 19 |
+
|
| 20 |
+
BASE_URL = "http://sppudocs.unipune.ac.in"
|
| 21 |
+
HEADERS = {"User-Agent": "Mozilla/5.0 (compatible; StudentAI-SPPUbot/1.0)"}
|
| 22 |
+
PDF_EXT_RE = re.compile(r"\.pdf($|\s*$)", re.IGNORECASE)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def _fix_url(href: str) -> str:
|
| 26 |
+
"""
|
| 27 |
+
SharePoint hrefs contain raw spaces β encode them properly.
|
| 28 |
+
e.g. '/sites/circulars/Admission Circulars/file name.pdf'
|
| 29 |
+
-> 'http://sppudocs.unipune.ac.in/sites/circulars/Admission%20Circulars/file%20name.pdf'
|
| 30 |
+
"""
|
| 31 |
+
href = href.strip()
|
| 32 |
+
if href.startswith("http"):
|
| 33 |
+
parsed = urlparse(href)
|
| 34 |
+
return parsed._replace(path=quote(parsed.path, safe="/%")).geturl()
|
| 35 |
+
else:
|
| 36 |
+
return BASE_URL + quote(href, safe="/%")
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def _pick_top_pdf_links(html: str, limit: int = 5) -> list[str]:
|
| 40 |
+
soup = BeautifulSoup(html, "html.parser")
|
| 41 |
+
pdf_links = []
|
| 42 |
+
|
| 43 |
+
for a in soup.find_all("a", href=True):
|
| 44 |
+
href = str(a.get("href", "")).strip()
|
| 45 |
+
if not href:
|
| 46 |
+
continue
|
| 47 |
+
if not PDF_EXT_RE.search(href.split("?")[0]):
|
| 48 |
+
continue
|
| 49 |
+
|
| 50 |
+
full_url = _fix_url(href)
|
| 51 |
+
|
| 52 |
+
if full_url not in pdf_links:
|
| 53 |
+
pdf_links.append(full_url)
|
| 54 |
+
|
| 55 |
+
if len(pdf_links) >= limit:
|
| 56 |
+
break
|
| 57 |
+
|
| 58 |
+
return pdf_links
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def _safe_local_filename(pdf_url: str) -> str:
|
| 62 |
+
path = urlparse(pdf_url).path
|
| 63 |
+
raw_name = os.path.basename(path)
|
| 64 |
+
|
| 65 |
+
if not raw_name or len(raw_name) < 2:
|
| 66 |
+
raw_name = f"sppu_notice_{int(datetime.utcnow().timestamp())}.pdf"
|
| 67 |
+
|
| 68 |
+
if not raw_name.startswith("LATEST_NOTICE_"):
|
| 69 |
+
filename = f"LATEST_NOTICE_{raw_name}"
|
| 70 |
+
else:
|
| 71 |
+
filename = raw_name
|
| 72 |
+
|
| 73 |
+
return filename.replace("%20", "_").replace(" ", "_")
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def scrape_latest_sppu_notice():
|
| 77 |
+
print("π Initiating SPPU Multi-Target Scraper...")
|
| 78 |
+
try:
|
| 79 |
+
downloaded_files: list[str] = []
|
| 80 |
+
|
| 81 |
+
for url in TARGET_URLS:
|
| 82 |
+
section = url.split('/sites/')[1].split('/Forms')[0].replace('%20', ' ')
|
| 83 |
+
print(f" π Scanning: {section}")
|
| 84 |
+
|
| 85 |
+
resp = requests.get(url, headers=HEADERS, timeout=20)
|
| 86 |
+
resp.raise_for_status()
|
| 87 |
+
|
| 88 |
+
pdf_urls = _pick_top_pdf_links(resp.text, limit=5)
|
| 89 |
+
|
| 90 |
+
if not pdf_urls:
|
| 91 |
+
print(f" β οΈ No PDF links found on this page.")
|
| 92 |
+
continue
|
| 93 |
+
|
| 94 |
+
print(f" Found {len(pdf_urls)} PDF links.")
|
| 95 |
+
|
| 96 |
+
for pdf_url in pdf_urls:
|
| 97 |
+
filename = _safe_local_filename(pdf_url)
|
| 98 |
+
local_path = os.path.join(DATA_FOLDER, filename)
|
| 99 |
+
|
| 100 |
+
if os.path.exists(local_path) and os.path.getsize(local_path) > 0:
|
| 101 |
+
print(f" β© Already exists: '{filename}'. Stopping for this section.")
|
| 102 |
+
break
|
| 103 |
+
|
| 104 |
+
print(f" π₯ Downloading: {filename}...")
|
| 105 |
+
os.makedirs(DATA_FOLDER, exist_ok=True)
|
| 106 |
+
|
| 107 |
+
resp_pdf = requests.get(pdf_url, headers=HEADERS, timeout=30, stream=True)
|
| 108 |
+
resp_pdf.raise_for_status()
|
| 109 |
+
|
| 110 |
+
with open(local_path, "wb") as f:
|
| 111 |
+
for chunk in resp_pdf.iter_content(chunk_size=1024 * 256):
|
| 112 |
+
if chunk:
|
| 113 |
+
f.write(chunk)
|
| 114 |
+
|
| 115 |
+
downloaded_files.append(filename)
|
| 116 |
+
print(f" β
Saved: {filename}")
|
| 117 |
+
|
| 118 |
+
if downloaded_files:
|
| 119 |
+
msg = f"Successfully synced {len(downloaded_files)} new notice(s): {', '.join(downloaded_files)}"
|
| 120 |
+
print(f"π {msg}")
|
| 121 |
+
return True, msg
|
| 122 |
+
|
| 123 |
+
print("β
All boards already up to date.")
|
| 124 |
+
return True, "All targeted boards are already up to date."
|
| 125 |
+
|
| 126 |
+
except Exception as e:
|
| 127 |
+
print(f"β Scraper Error: {e}")
|
| 128 |
+
return False, f"Failed to sync: {str(e)}"
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
if __name__ == "__main__":
|
| 132 |
+
scrape_latest_sppu_notice()
|
backend/startup.sh
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -e
|
| 3 |
+
cd /app/backend
|
| 4 |
+
|
| 5 |
+
if [ -d "chroma_db" ] && [ -n "$(ls -A chroma_db 2>/dev/null)" ]; then
|
| 6 |
+
echo "=== CHROMA_DB PRESENT - SKIPPING DOWNLOAD ==="
|
| 7 |
+
else
|
| 8 |
+
echo "=== DOWNLOADING PREBUILT CHROMA DB FROM HF DATASET ==="
|
| 9 |
+
python - <<'PY'
|
| 10 |
+
from huggingface_hub import snapshot_download
|
| 11 |
+
snapshot_download(
|
| 12 |
+
repo_id="Yashkute/sppu-chroma-db",
|
| 13 |
+
repo_type="dataset",
|
| 14 |
+
local_dir="chroma_db",
|
| 15 |
+
)
|
| 16 |
+
print("Chroma DB downloaded.")
|
| 17 |
+
PY
|
| 18 |
+
fi
|
| 19 |
+
|
| 20 |
+
echo "=== STARTING FASTAPI SERVER ==="
|
| 21 |
+
uvicorn api:app --host 0.0.0.0 --port 7860
|
backend/voice_agent.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import edge_tts
|
| 2 |
+
|
| 3 |
+
async def generate_tutor_audio(text: str):
|
| 4 |
+
"""
|
| 5 |
+
Takes LLM text and generates an audio byte stream using free Microsoft Azure Neural voices.
|
| 6 |
+
"""
|
| 7 |
+
voice_id = "en-US-AriaNeural"
|
| 8 |
+
print(f"π‘ Requesting free Azure audio (Voice: {voice_id})...")
|
| 9 |
+
|
| 10 |
+
try:
|
| 11 |
+
communicate = edge_tts.Communicate(text, voice_id)
|
| 12 |
+
|
| 13 |
+
audio_bytes = b""
|
| 14 |
+
async for chunk in communicate.stream():
|
| 15 |
+
if chunk["type"] == "audio":
|
| 16 |
+
audio_bytes += chunk["data"]
|
| 17 |
+
|
| 18 |
+
return audio_bytes
|
| 19 |
+
|
| 20 |
+
except Exception as e:
|
| 21 |
+
print(f"β Edge-TTS Error: {e}")
|
| 22 |
+
return None
|
frontend/.gitignore
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Logs
|
| 2 |
+
logs
|
| 3 |
+
*.log
|
| 4 |
+
npm-debug.log*
|
| 5 |
+
yarn-debug.log*
|
| 6 |
+
yarn-error.log*
|
| 7 |
+
pnpm-debug.log*
|
| 8 |
+
lerna-debug.log*
|
| 9 |
+
|
| 10 |
+
node_modules
|
| 11 |
+
dist
|
| 12 |
+
dist-ssr
|
| 13 |
+
*.local
|
| 14 |
+
|
| 15 |
+
# Editor directories and files
|
| 16 |
+
.vscode/*
|
| 17 |
+
!.vscode/extensions.json
|
| 18 |
+
.idea
|
| 19 |
+
.DS_Store
|
| 20 |
+
*.suo
|
| 21 |
+
*.ntvs*
|
| 22 |
+
*.njsproj
|
| 23 |
+
*.sln
|
| 24 |
+
*.sw?
|
frontend/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# React + Vite
|
| 2 |
+
|
| 3 |
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
| 4 |
+
|
| 5 |
+
Currently, two official plugins are available:
|
| 6 |
+
|
| 7 |
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
| 8 |
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
| 9 |
+
|
| 10 |
+
## React Compiler
|
| 11 |
+
|
| 12 |
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
| 13 |
+
|
| 14 |
+
## Expanding the ESLint configuration
|
| 15 |
+
|
| 16 |
+
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
|
frontend/eslint.config.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import js from '@eslint/js'
|
| 2 |
+
import globals from 'globals'
|
| 3 |
+
import reactHooks from 'eslint-plugin-react-hooks'
|
| 4 |
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
| 5 |
+
import { defineConfig, globalIgnores } from 'eslint/config'
|
| 6 |
+
|
| 7 |
+
export default defineConfig([
|
| 8 |
+
globalIgnores(['dist']),
|
| 9 |
+
{
|
| 10 |
+
files: ['**/*.{js,jsx}'],
|
| 11 |
+
extends: [
|
| 12 |
+
js.configs.recommended,
|
| 13 |
+
reactHooks.configs.flat.recommended,
|
| 14 |
+
reactRefresh.configs.vite,
|
| 15 |
+
],
|
| 16 |
+
languageOptions: {
|
| 17 |
+
ecmaVersion: 2020,
|
| 18 |
+
globals: globals.browser,
|
| 19 |
+
parserOptions: {
|
| 20 |
+
ecmaVersion: 'latest',
|
| 21 |
+
ecmaFeatures: { jsx: true },
|
| 22 |
+
sourceType: 'module',
|
| 23 |
+
},
|
| 24 |
+
},
|
| 25 |
+
rules: {
|
| 26 |
+
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
|
| 27 |
+
},
|
| 28 |
+
},
|
| 29 |
+
])
|
frontend/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
+
<title>frontend</title>
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
<div id="root"></div>
|
| 11 |
+
<script type="module" src="/src/main.jsx"></script>
|
| 12 |
+
</body>
|
| 13 |
+
</html>
|
frontend/package-lock.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "frontend",
|
| 3 |
+
"private": true,
|
| 4 |
+
"version": "0.0.0",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"scripts": {
|
| 7 |
+
"dev": "vite",
|
| 8 |
+
"build": "vite build",
|
| 9 |
+
"lint": "eslint .",
|
| 10 |
+
"preview": "vite preview"
|
| 11 |
+
},
|
| 12 |
+
"dependencies": {
|
| 13 |
+
"@tailwindcss/vite": "^4.1.18",
|
| 14 |
+
"axios": "^1.13.5",
|
| 15 |
+
"clsx": "^2.1.1",
|
| 16 |
+
"framer-motion": "^12.34.0",
|
| 17 |
+
"lucide-react": "^0.563.0",
|
| 18 |
+
"react": "^19.2.0",
|
| 19 |
+
"react-dom": "^19.2.0",
|
| 20 |
+
"tailwind-merge": "^3.4.0"
|
| 21 |
+
},
|
| 22 |
+
"devDependencies": {
|
| 23 |
+
"@eslint/js": "^9.39.1",
|
| 24 |
+
"@types/react": "^19.2.7",
|
| 25 |
+
"@types/react-dom": "^19.2.3",
|
| 26 |
+
"@vitejs/plugin-react": "^5.1.1",
|
| 27 |
+
"autoprefixer": "^10.4.24",
|
| 28 |
+
"eslint": "^9.39.1",
|
| 29 |
+
"eslint-plugin-react-hooks": "^7.0.1",
|
| 30 |
+
"eslint-plugin-react-refresh": "^0.4.24",
|
| 31 |
+
"globals": "^16.5.0",
|
| 32 |
+
"postcss": "^8.5.6",
|
| 33 |
+
"tailwindcss": "^4.1.18",
|
| 34 |
+
"vite": "^7.3.1"
|
| 35 |
+
}
|
| 36 |
+
}
|
frontend/public/vite.svg
ADDED
|
|
frontend/src/App.css
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#root {
|
| 2 |
+
max-width: 1280px;
|
| 3 |
+
margin: 0 auto;
|
| 4 |
+
padding: 2rem;
|
| 5 |
+
text-align: center;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
.logo {
|
| 9 |
+
height: 6em;
|
| 10 |
+
padding: 1.5em;
|
| 11 |
+
will-change: filter;
|
| 12 |
+
transition: filter 300ms;
|
| 13 |
+
}
|
| 14 |
+
.logo:hover {
|
| 15 |
+
filter: drop-shadow(0 0 2em #646cffaa);
|
| 16 |
+
}
|
| 17 |
+
.logo.react:hover {
|
| 18 |
+
filter: drop-shadow(0 0 2em #61dafbaa);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
@keyframes logo-spin {
|
| 22 |
+
from {
|
| 23 |
+
transform: rotate(0deg);
|
| 24 |
+
}
|
| 25 |
+
to {
|
| 26 |
+
transform: rotate(360deg);
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
@media (prefers-reduced-motion: no-preference) {
|
| 31 |
+
a:nth-of-type(2) .logo {
|
| 32 |
+
animation: logo-spin infinite 20s linear;
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.card {
|
| 37 |
+
padding: 2em;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
.read-the-docs {
|
| 41 |
+
color: #888;
|
| 42 |
+
}
|
frontend/src/App.jsx
ADDED
|
@@ -0,0 +1,649 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useState, useEffect, useRef } from 'react';
|
| 2 |
+
import axios from 'axios';
|
| 3 |
+
import { motion, AnimatePresence } from 'framer-motion';
|
| 4 |
+
import { Send, Paperclip, Bot, User, X, Loader2, Plus, MessageSquare, Trash2, Menu, ChevronLeft, Database, Zap, Download, Volume2, Play, Pause, RefreshCw } from 'lucide-react';
|
| 5 |
+
|
| 6 |
+
const API_URL = import.meta.env.VITE_API_URL || "http://localhost:8000";
|
| 7 |
+
|
| 8 |
+
function App() {
|
| 9 |
+
const [isSyncing, setIsSyncing] = useState(false);
|
| 10 |
+
const [sessions, setSessions] = useState([]);
|
| 11 |
+
const [currentSessionId, setCurrentSessionId] = useState(null);
|
| 12 |
+
const [messages, setMessages] = useState([]);
|
| 13 |
+
const [input, setInput] = useState("");
|
| 14 |
+
const [isLoading, setIsLoading] = useState(false);
|
| 15 |
+
const [selectedImage, setSelectedImage] = useState(null);
|
| 16 |
+
const [previewUrl, setPreviewUrl] = useState(null);
|
| 17 |
+
const [isSidebarOpen, setSidebarOpen] = useState(false); // default closed on mobile
|
| 18 |
+
const [isRagEnabled, setIsRagEnabled] = useState(true);
|
| 19 |
+
const [showMobileMenu, setShowMobileMenu] = useState(false); // mobile mode toggle sheet
|
| 20 |
+
|
| 21 |
+
const [playingId, setPlayingId] = useState(null);
|
| 22 |
+
const [isAudioPaused, setIsAudioPaused] = useState(false);
|
| 23 |
+
|
| 24 |
+
const messagesEndRef = useRef(null);
|
| 25 |
+
const fileInputRef = useRef(null);
|
| 26 |
+
const currentAudioRef = useRef(null);
|
| 27 |
+
|
| 28 |
+
// Detect if we're on mobile
|
| 29 |
+
const isMobile = () => window.innerWidth < 768;
|
| 30 |
+
|
| 31 |
+
useEffect(() => {
|
| 32 |
+
// On desktop, open sidebar by default
|
| 33 |
+
if (!isMobile()) setSidebarOpen(true);
|
| 34 |
+
|
| 35 |
+
const savedSessions = localStorage.getItem('sppu_chat_sessions');
|
| 36 |
+
if (savedSessions) {
|
| 37 |
+
const parsed = JSON.parse(savedSessions);
|
| 38 |
+
setSessions(parsed);
|
| 39 |
+
if (parsed.length > 0) {
|
| 40 |
+
loadSession(parsed[0].id, parsed);
|
| 41 |
+
} else {
|
| 42 |
+
createNewSession();
|
| 43 |
+
}
|
| 44 |
+
} else {
|
| 45 |
+
createNewSession();
|
| 46 |
+
}
|
| 47 |
+
}, []);
|
| 48 |
+
|
| 49 |
+
useEffect(() => {
|
| 50 |
+
if (sessions.length > 0) {
|
| 51 |
+
localStorage.setItem('sppu_chat_sessions', JSON.stringify(sessions));
|
| 52 |
+
}
|
| 53 |
+
}, [sessions]);
|
| 54 |
+
|
| 55 |
+
useEffect(() => {
|
| 56 |
+
scrollToBottom();
|
| 57 |
+
}, [messages, isLoading]);
|
| 58 |
+
|
| 59 |
+
const scrollToBottom = () => {
|
| 60 |
+
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
const createNewSession = () => {
|
| 64 |
+
const newSession = {
|
| 65 |
+
id: Date.now(),
|
| 66 |
+
title: "New Chat",
|
| 67 |
+
timestamp: new Date().toISOString(),
|
| 68 |
+
messages: [{
|
| 69 |
+
id: 'init',
|
| 70 |
+
text: "Hello! I'm your SPPU Student Assistant. Ready to study? Ask me anything!",
|
| 71 |
+
sender: 'ai',
|
| 72 |
+
sources: [],
|
| 73 |
+
mode: 'general'
|
| 74 |
+
}]
|
| 75 |
+
};
|
| 76 |
+
setSessions(prev => [newSession, ...prev]);
|
| 77 |
+
setCurrentSessionId(newSession.id);
|
| 78 |
+
setMessages(newSession.messages);
|
| 79 |
+
setInput("");
|
| 80 |
+
setSidebarOpen(false); // always close sidebar after action on mobile
|
| 81 |
+
};
|
| 82 |
+
|
| 83 |
+
const loadSession = (id, sessionList = sessions) => {
|
| 84 |
+
const session = sessionList.find(s => s.id === id);
|
| 85 |
+
if (session) {
|
| 86 |
+
setCurrentSessionId(id);
|
| 87 |
+
setMessages(session.messages);
|
| 88 |
+
setSidebarOpen(false);
|
| 89 |
+
|
| 90 |
+
if (currentAudioRef.current) {
|
| 91 |
+
currentAudioRef.current.pause();
|
| 92 |
+
setPlayingId(null);
|
| 93 |
+
setIsAudioPaused(false);
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
const deleteSession = (e, id) => {
|
| 99 |
+
e.stopPropagation();
|
| 100 |
+
const updatedSessions = sessions.filter(s => s.id !== id);
|
| 101 |
+
setSessions(updatedSessions);
|
| 102 |
+
localStorage.setItem('sppu_chat_sessions', JSON.stringify(updatedSessions));
|
| 103 |
+
if (updatedSessions.length === 0) {
|
| 104 |
+
createNewSession();
|
| 105 |
+
} else if (id === currentSessionId) {
|
| 106 |
+
loadSession(updatedSessions[0].id, updatedSessions);
|
| 107 |
+
}
|
| 108 |
+
};
|
| 109 |
+
|
| 110 |
+
const updateCurrentSessionMessages = (newMessages) => {
|
| 111 |
+
setMessages(newMessages);
|
| 112 |
+
setSessions(prev => prev.map(session => {
|
| 113 |
+
if (session.id === currentSessionId) {
|
| 114 |
+
let newTitle = session.title;
|
| 115 |
+
if (session.title === "New Chat" && newMessages.length > 1) {
|
| 116 |
+
const firstUserMsg = newMessages.find(m => m.sender === 'user');
|
| 117 |
+
if (firstUserMsg) {
|
| 118 |
+
newTitle = firstUserMsg.text.slice(0, 30) + (firstUserMsg.text.length > 30 ? "..." : "");
|
| 119 |
+
}
|
| 120 |
+
}
|
| 121 |
+
return { ...session, messages: newMessages, title: newTitle };
|
| 122 |
+
}
|
| 123 |
+
return session;
|
| 124 |
+
}));
|
| 125 |
+
};
|
| 126 |
+
|
| 127 |
+
const handleImageSelect = (e) => {
|
| 128 |
+
const file = e.target.files[0];
|
| 129 |
+
if (file) {
|
| 130 |
+
setSelectedImage(file);
|
| 131 |
+
setPreviewUrl(URL.createObjectURL(file));
|
| 132 |
+
}
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
const clearImage = () => {
|
| 136 |
+
setSelectedImage(null);
|
| 137 |
+
setPreviewUrl(null);
|
| 138 |
+
if (fileInputRef.current) fileInputRef.current.value = "";
|
| 139 |
+
};
|
| 140 |
+
|
| 141 |
+
const handleSend = async () => {
|
| 142 |
+
if ((!input.trim() && !selectedImage) || isLoading) return;
|
| 143 |
+
|
| 144 |
+
const userMessage = {
|
| 145 |
+
id: Date.now(),
|
| 146 |
+
text: input,
|
| 147 |
+
sender: 'user',
|
| 148 |
+
image: previewUrl
|
| 149 |
+
};
|
| 150 |
+
|
| 151 |
+
const updatedMessages = [...messages, userMessage];
|
| 152 |
+
updateCurrentSessionMessages(updatedMessages);
|
| 153 |
+
setInput("");
|
| 154 |
+
setIsLoading(true);
|
| 155 |
+
|
| 156 |
+
try {
|
| 157 |
+
const recentHistory = updatedMessages.slice(-4).map(msg =>
|
| 158 |
+
`${msg.sender === 'user' ? 'Student' : 'Assistant'}: ${msg.text}`
|
| 159 |
+
).join('\n');
|
| 160 |
+
|
| 161 |
+
const formData = new FormData();
|
| 162 |
+
formData.append('question', userMessage.text || "Analyze this image");
|
| 163 |
+
formData.append('history', recentHistory);
|
| 164 |
+
formData.append('use_rag', isRagEnabled);
|
| 165 |
+
|
| 166 |
+
if (selectedImage) {
|
| 167 |
+
formData.append('file', selectedImage);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
clearImage();
|
| 171 |
+
|
| 172 |
+
const response = await axios.post(`${API_URL}/chat`, formData, {
|
| 173 |
+
headers: { 'Content-Type': 'multipart/form-data' }
|
| 174 |
+
});
|
| 175 |
+
|
| 176 |
+
const aiMessageId = Date.now() + 1;
|
| 177 |
+
const aiMessage = {
|
| 178 |
+
id: aiMessageId,
|
| 179 |
+
text: response.data.answer,
|
| 180 |
+
sender: 'ai',
|
| 181 |
+
sources: response.data.sources || [],
|
| 182 |
+
mode: response.data.mode,
|
| 183 |
+
audio_url: null,
|
| 184 |
+
isAudioLoading: false
|
| 185 |
+
};
|
| 186 |
+
|
| 187 |
+
updateCurrentSessionMessages([...updatedMessages, aiMessage]);
|
| 188 |
+
} catch (error) {
|
| 189 |
+
console.error(error);
|
| 190 |
+
const errorMessage = {
|
| 191 |
+
id: Date.now() + 1,
|
| 192 |
+
text: "β οΈ Error: Could not connect to the Assistant. Is your backend running?",
|
| 193 |
+
sender: 'ai',
|
| 194 |
+
isError: true
|
| 195 |
+
};
|
| 196 |
+
updateCurrentSessionMessages([...updatedMessages, errorMessage]);
|
| 197 |
+
} finally {
|
| 198 |
+
setIsLoading(false);
|
| 199 |
+
}
|
| 200 |
+
};
|
| 201 |
+
|
| 202 |
+
const updateSpecificMessage = (msgId, updates) => {
|
| 203 |
+
setMessages(prev => prev.map(m => m.id === msgId ? { ...m, ...updates } : m));
|
| 204 |
+
setSessions(prev => prev.map(session => {
|
| 205 |
+
if (session.id === currentSessionId) {
|
| 206 |
+
return { ...session, messages: session.messages.map(m => m.id === msgId ? { ...m, ...updates } : m) };
|
| 207 |
+
}
|
| 208 |
+
return session;
|
| 209 |
+
}));
|
| 210 |
+
};
|
| 211 |
+
|
| 212 |
+
const playAudio = (id, audioUrl) => {
|
| 213 |
+
const audio = new Audio(audioUrl);
|
| 214 |
+
currentAudioRef.current = audio;
|
| 215 |
+
setPlayingId(id);
|
| 216 |
+
setIsAudioPaused(false);
|
| 217 |
+
audio.play();
|
| 218 |
+
audio.onended = () => {
|
| 219 |
+
setPlayingId(null);
|
| 220 |
+
setIsAudioPaused(false);
|
| 221 |
+
};
|
| 222 |
+
};
|
| 223 |
+
|
| 224 |
+
const handleListen = async (msg) => {
|
| 225 |
+
if (playingId === msg.id) {
|
| 226 |
+
if (currentAudioRef.current.paused) {
|
| 227 |
+
currentAudioRef.current.play();
|
| 228 |
+
setIsAudioPaused(false);
|
| 229 |
+
} else {
|
| 230 |
+
currentAudioRef.current.pause();
|
| 231 |
+
setIsAudioPaused(true);
|
| 232 |
+
}
|
| 233 |
+
return;
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
if (currentAudioRef.current) {
|
| 237 |
+
currentAudioRef.current.pause();
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
if (msg.audio_url) {
|
| 241 |
+
playAudio(msg.id, msg.audio_url);
|
| 242 |
+
return;
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
updateSpecificMessage(msg.id, { isAudioLoading: true });
|
| 246 |
+
|
| 247 |
+
try {
|
| 248 |
+
const res = await axios.post(`${API_URL}/speak`, { text: msg.text }, {
|
| 249 |
+
responseType: 'blob'
|
| 250 |
+
});
|
| 251 |
+
const audioUrl = URL.createObjectURL(res.data);
|
| 252 |
+
updateSpecificMessage(msg.id, { audio_url: audioUrl, isAudioLoading: false });
|
| 253 |
+
playAudio(msg.id, audioUrl);
|
| 254 |
+
} catch (err) {
|
| 255 |
+
console.error("Audio fetch failed", err);
|
| 256 |
+
updateSpecificMessage(msg.id, { isAudioLoading: false });
|
| 257 |
+
alert("Failed to generate audio.");
|
| 258 |
+
}
|
| 259 |
+
};
|
| 260 |
+
|
| 261 |
+
const exportChat = () => {
|
| 262 |
+
if (messages.length <= 1) {
|
| 263 |
+
alert("No conversation to export yet!");
|
| 264 |
+
return;
|
| 265 |
+
}
|
| 266 |
+
const currentSession = sessions.find(s => s.id === currentSessionId);
|
| 267 |
+
const title = currentSession ? currentSession.title.replace(/[^a-z0-9]/gi, '_').toLowerCase() : 'sppu_study_session';
|
| 268 |
+
|
| 269 |
+
let chatContent = `# SPPU AI Assistant - Study Session\nDate: ${new Date().toLocaleString()}\nTopic: ${title}\n\n---\n\n`;
|
| 270 |
+
|
| 271 |
+
messages.forEach(msg => {
|
| 272 |
+
if (msg.id === 'init') return;
|
| 273 |
+
const senderName = msg.sender === 'user' ? 'π§βπ Student' : 'π€ SPPU Assistant';
|
| 274 |
+
chatContent += `### ${senderName}\n${msg.text}\n\n`;
|
| 275 |
+
if (msg.sources && msg.sources.length > 0) {
|
| 276 |
+
chatContent += `*Sources used: ${msg.sources.join(', ')}*\n\n`;
|
| 277 |
+
}
|
| 278 |
+
chatContent += `---\n\n`;
|
| 279 |
+
});
|
| 280 |
+
|
| 281 |
+
const blob = new Blob([chatContent], { type: 'text/markdown;charset=utf-8' });
|
| 282 |
+
const url = URL.createObjectURL(blob);
|
| 283 |
+
const link = document.createElement('a');
|
| 284 |
+
link.href = url;
|
| 285 |
+
link.download = `${title}_notes.md`;
|
| 286 |
+
document.body.appendChild(link);
|
| 287 |
+
link.click();
|
| 288 |
+
document.body.removeChild(link);
|
| 289 |
+
URL.revokeObjectURL(url);
|
| 290 |
+
};
|
| 291 |
+
|
| 292 |
+
const handleKeyPress = (e) => {
|
| 293 |
+
if (e.key === 'Enter' && !e.shiftKey) {
|
| 294 |
+
e.preventDefault();
|
| 295 |
+
handleSend();
|
| 296 |
+
}
|
| 297 |
+
};
|
| 298 |
+
|
| 299 |
+
const getMessageStyle = (msg) => {
|
| 300 |
+
if (msg.sender === 'user') return 'bg-blue-600 text-white rounded-tr-none';
|
| 301 |
+
if (msg.isError) return 'bg-red-500/10 border border-red-500/20 text-red-200';
|
| 302 |
+
return msg.mode === 'rag'
|
| 303 |
+
? 'bg-slate-800/80 border border-cyan-500/30 text-cyan-50 shadow-[0_0_15px_rgba(6,182,212,0.1)] rounded-tl-none'
|
| 304 |
+
: 'bg-slate-800/80 border border-orange-500/30 text-orange-50 shadow-[0_0_15px_rgba(249,115,22,0.1)] rounded-tl-none';
|
| 305 |
+
};
|
| 306 |
+
|
| 307 |
+
const handleSyncNotices = async () => {
|
| 308 |
+
setIsSyncing(true);
|
| 309 |
+
try {
|
| 310 |
+
const res = await axios.post(`${API_URL}/sync-notices`);
|
| 311 |
+
alert(res.data.message);
|
| 312 |
+
} catch (err) {
|
| 313 |
+
console.error(err);
|
| 314 |
+
alert("Failed to sync with SPPU servers.");
|
| 315 |
+
} finally {
|
| 316 |
+
setIsSyncing(false);
|
| 317 |
+
}
|
| 318 |
+
};
|
| 319 |
+
|
| 320 |
+
return (
|
| 321 |
+
<div className="flex h-screen w-screen bg-slate-900 text-white overflow-hidden font-sans relative">
|
| 322 |
+
|
| 323 |
+
{/* ββ SIDEBAR OVERLAY (mobile only) ββ */}
|
| 324 |
+
<AnimatePresence>
|
| 325 |
+
{isSidebarOpen && (
|
| 326 |
+
<motion.div
|
| 327 |
+
initial={{ opacity: 0 }}
|
| 328 |
+
animate={{ opacity: 1 }}
|
| 329 |
+
exit={{ opacity: 0 }}
|
| 330 |
+
className="fixed inset-0 bg-black/60 z-30 md:hidden"
|
| 331 |
+
onClick={() => setSidebarOpen(false)}
|
| 332 |
+
/>
|
| 333 |
+
)}
|
| 334 |
+
</AnimatePresence>
|
| 335 |
+
|
| 336 |
+
{/* ββ SIDEBAR ββ */}
|
| 337 |
+
{/* On mobile: fixed overlay. On desktop: static flex column. */}
|
| 338 |
+
<motion.aside
|
| 339 |
+
initial={false}
|
| 340 |
+
animate={{ x: isSidebarOpen ? 0 : '-100%' }}
|
| 341 |
+
transition={{ type: 'tween', duration: 0.22 }}
|
| 342 |
+
className="fixed md:static top-0 left-0 h-full z-40 md:z-auto
|
| 343 |
+
w-64 md:w-64
|
| 344 |
+
bg-slate-900 border-r border-white/10
|
| 345 |
+
flex flex-col shrink-0
|
| 346 |
+
md:translate-x-0"
|
| 347 |
+
style={{ transform: undefined }} // let motion handle it on mobile; on md+ we use CSS
|
| 348 |
+
>
|
| 349 |
+
{/* Close button inside sidebar (mobile only) */}
|
| 350 |
+
<button
|
| 351 |
+
onClick={() => setSidebarOpen(false)}
|
| 352 |
+
className="md:hidden absolute top-3 right-3 p-1.5 rounded-lg hover:bg-white/10 text-slate-400"
|
| 353 |
+
>
|
| 354 |
+
<X size={18} />
|
| 355 |
+
</button>
|
| 356 |
+
|
| 357 |
+
<div className="p-4 flex flex-col gap-4 h-full pt-12 md:pt-4">
|
| 358 |
+
<button
|
| 359 |
+
onClick={createNewSession}
|
| 360 |
+
className="flex items-center gap-3 bg-blue-600 hover:bg-blue-500 text-white px-4 py-3 rounded-lg transition-all shadow-lg hover:shadow-blue-500/20 font-medium w-full"
|
| 361 |
+
>
|
| 362 |
+
<Plus size={20} />
|
| 363 |
+
<span>New Chat</span>
|
| 364 |
+
</button>
|
| 365 |
+
|
| 366 |
+
<div className="flex-1 overflow-y-auto space-y-2 pr-1">
|
| 367 |
+
<h3 className="text-xs font-semibold text-slate-500 uppercase tracking-wider mb-2 mt-2 pl-2">Recent Chats</h3>
|
| 368 |
+
{sessions.map((session) => (
|
| 369 |
+
<div
|
| 370 |
+
key={session.id}
|
| 371 |
+
onClick={() => loadSession(session.id)}
|
| 372 |
+
className={`group flex items-center justify-between p-3 rounded-lg cursor-pointer transition-all ${
|
| 373 |
+
currentSessionId === session.id
|
| 374 |
+
? 'bg-slate-800 text-white border border-white/10'
|
| 375 |
+
: 'text-slate-400 hover:bg-slate-800/50 hover:text-slate-200'
|
| 376 |
+
}`}
|
| 377 |
+
>
|
| 378 |
+
<div className="flex items-center gap-3 overflow-hidden">
|
| 379 |
+
<MessageSquare size={16} className={currentSessionId === session.id ? 'text-cyan-400' : 'text-slate-500'} />
|
| 380 |
+
<span className="truncate text-sm">{session.title}</span>
|
| 381 |
+
</div>
|
| 382 |
+
<button
|
| 383 |
+
onClick={(e) => deleteSession(e, session.id)}
|
| 384 |
+
className="opacity-0 group-hover:opacity-100 p-1 hover:text-red-400 transition-opacity shrink-0"
|
| 385 |
+
>
|
| 386 |
+
<Trash2 size={14} />
|
| 387 |
+
</button>
|
| 388 |
+
</div>
|
| 389 |
+
))}
|
| 390 |
+
</div>
|
| 391 |
+
|
| 392 |
+
<div className="pt-4 border-t border-white/10 flex items-center gap-3">
|
| 393 |
+
<div className="w-8 h-8 rounded-full bg-gradient-to-tr from-cyan-500 to-blue-500 flex items-center justify-center shrink-0">
|
| 394 |
+
<User size={16} className="text-white" />
|
| 395 |
+
</div>
|
| 396 |
+
<div className="flex-1 overflow-hidden">
|
| 397 |
+
<p className="text-sm font-medium truncate">Yash Kute</p>
|
| 398 |
+
<p className="text-xs text-emerald-400">Final Year - SPPU</p>
|
| 399 |
+
</div>
|
| 400 |
+
</div>
|
| 401 |
+
</div>
|
| 402 |
+
</motion.aside>
|
| 403 |
+
|
| 404 |
+
{/* ββ MAIN CHAT ββ */}
|
| 405 |
+
<main className="flex-1 flex flex-col h-full relative bg-slate-900/50 min-w-0">
|
| 406 |
+
|
| 407 |
+
{/* ββ HEADER ββ */}
|
| 408 |
+
<header className="h-14 md:h-16 border-b border-white/10 bg-slate-900/80 backdrop-blur-md flex items-center justify-between px-3 md:px-4 z-10 shrink-0 gap-2">
|
| 409 |
+
|
| 410 |
+
{/* Left: hamburger + title */}
|
| 411 |
+
<div className="flex items-center gap-2 min-w-0">
|
| 412 |
+
<button
|
| 413 |
+
onClick={() => setSidebarOpen(!isSidebarOpen)}
|
| 414 |
+
className="p-2 hover:bg-white/5 rounded-lg text-slate-400 transition-colors shrink-0"
|
| 415 |
+
>
|
| 416 |
+
<Menu size={20} />
|
| 417 |
+
</button>
|
| 418 |
+
<h1 className="font-bold text-sm tracking-wide flex items-center gap-2 truncate">
|
| 419 |
+
<span className="hidden xs:inline">SPPU Assistant</span>
|
| 420 |
+
<span className="xs:hidden">SPPU</span>
|
| 421 |
+
<span className="bg-slate-800 text-[10px] px-1.5 py-0.5 rounded text-slate-300 border border-white/5 shrink-0">v2.2</span>
|
| 422 |
+
</h1>
|
| 423 |
+
</div>
|
| 424 |
+
|
| 425 |
+
{/* Right: action buttons */}
|
| 426 |
+
<div className="flex items-center gap-1.5 md:gap-3 shrink-0">
|
| 427 |
+
|
| 428 |
+
{/* Sync β icon only on mobile */}
|
| 429 |
+
<button
|
| 430 |
+
onClick={handleSyncNotices}
|
| 431 |
+
disabled={isSyncing}
|
| 432 |
+
className="flex items-center gap-1.5 px-2 md:px-3 py-1.5 rounded-md text-xs font-medium text-emerald-400 hover:text-emerald-300 hover:bg-emerald-900/30 border border-emerald-500/30 transition-all disabled:opacity-50"
|
| 433 |
+
>
|
| 434 |
+
<RefreshCw size={14} className={isSyncing ? "animate-spin" : ""} />
|
| 435 |
+
<span className="hidden md:inline">{isSyncing ? "Syncing..." : "Live Sync"}</span>
|
| 436 |
+
</button>
|
| 437 |
+
|
| 438 |
+
{/* Export β icon only on mobile */}
|
| 439 |
+
<button
|
| 440 |
+
onClick={exportChat}
|
| 441 |
+
className="flex items-center gap-1.5 px-2 md:px-3 py-1.5 rounded-md text-xs font-medium text-slate-400 hover:text-white hover:bg-slate-800 border border-transparent hover:border-white/10 transition-all"
|
| 442 |
+
>
|
| 443 |
+
<Download size={16} />
|
| 444 |
+
<span className="hidden md:inline">Export</span>
|
| 445 |
+
</button>
|
| 446 |
+
|
| 447 |
+
{/* Mode toggle β compact on mobile */}
|
| 448 |
+
<div className="flex items-center bg-slate-800 p-0.5 rounded-lg border border-white/5">
|
| 449 |
+
<button
|
| 450 |
+
onClick={() => setIsRagEnabled(true)}
|
| 451 |
+
className={`flex items-center gap-1 px-2 md:px-3 py-1.5 rounded-md text-xs font-medium transition-all ${isRagEnabled ? 'bg-cyan-600 text-white shadow' : 'text-slate-400 hover:text-white'}`}
|
| 452 |
+
title="RAG Mode"
|
| 453 |
+
>
|
| 454 |
+
<Database size={13} />
|
| 455 |
+
<span className="hidden sm:inline">RAG</span>
|
| 456 |
+
</button>
|
| 457 |
+
<button
|
| 458 |
+
onClick={() => setIsRagEnabled(false)}
|
| 459 |
+
className={`flex items-center gap-1 px-2 md:px-3 py-1.5 rounded-md text-xs font-medium transition-all ${!isRagEnabled ? 'bg-orange-600 text-white shadow' : 'text-slate-400 hover:text-white'}`}
|
| 460 |
+
title="General Mode"
|
| 461 |
+
>
|
| 462 |
+
<Zap size={13} />
|
| 463 |
+
<span className="hidden sm:inline">Gen</span>
|
| 464 |
+
</button>
|
| 465 |
+
</div>
|
| 466 |
+
</div>
|
| 467 |
+
</header>
|
| 468 |
+
|
| 469 |
+
{/* ββ MESSAGES ββ */}
|
| 470 |
+
<div className="flex-1 overflow-y-auto p-3 md:p-6 lg:p-8 space-y-4 md:space-y-6 scroll-smooth">
|
| 471 |
+
<AnimatePresence>
|
| 472 |
+
{messages.map((msg) => (
|
| 473 |
+
<motion.div
|
| 474 |
+
key={msg.id}
|
| 475 |
+
initial={{ opacity: 0, y: 10 }}
|
| 476 |
+
animate={{ opacity: 1, y: 0 }}
|
| 477 |
+
className={`flex gap-2 md:gap-4 ${msg.sender === 'user' ? 'justify-end' : 'justify-start md:max-w-3xl md:mx-auto w-full'}`}
|
| 478 |
+
>
|
| 479 |
+
{msg.sender === 'ai' && (
|
| 480 |
+
<div className="flex flex-col items-center gap-2 mt-1 shrink-0">
|
| 481 |
+
<div className={`w-7 h-7 md:w-8 md:h-8 rounded-full flex items-center justify-center border border-white/10 ${msg.mode === 'rag' ? 'bg-cyan-900/50 text-cyan-400' : 'bg-orange-900/50 text-orange-400'}`}>
|
| 482 |
+
{msg.mode === 'rag' ? <Database size={14} /> : <Zap size={14} />}
|
| 483 |
+
</div>
|
| 484 |
+
|
| 485 |
+
{msg.id !== 'init' && (
|
| 486 |
+
<button
|
| 487 |
+
onClick={() => handleListen(msg)}
|
| 488 |
+
disabled={msg.isAudioLoading}
|
| 489 |
+
className={`w-6 h-6 md:w-7 md:h-7 rounded-full flex items-center justify-center transition-all border ${
|
| 490 |
+
playingId === msg.id
|
| 491 |
+
? 'bg-cyan-500/20 border-cyan-500/50 text-cyan-400'
|
| 492 |
+
: 'bg-slate-800 border-white/5 text-slate-400 hover:text-white hover:bg-slate-700'
|
| 493 |
+
}`}
|
| 494 |
+
title="Listen"
|
| 495 |
+
>
|
| 496 |
+
{msg.isAudioLoading ? (
|
| 497 |
+
<Loader2 size={10} className="animate-spin text-cyan-400" />
|
| 498 |
+
) : playingId === msg.id && !isAudioPaused ? (
|
| 499 |
+
<Pause size={10} fill="currentColor" />
|
| 500 |
+
) : (
|
| 501 |
+
<Play size={10} className="ml-0.5" fill="currentColor" />
|
| 502 |
+
)}
|
| 503 |
+
</button>
|
| 504 |
+
)}
|
| 505 |
+
</div>
|
| 506 |
+
)}
|
| 507 |
+
|
| 508 |
+
<div className={`space-y-2 min-w-0 ${msg.sender === 'user' ? 'max-w-[85%] md:max-w-[75%]' : 'flex-1'}`}>
|
| 509 |
+
|
| 510 |
+
{playingId === msg.id && !isAudioPaused && (
|
| 511 |
+
<motion.div
|
| 512 |
+
initial={{ opacity: 0, scale: 0.8 }}
|
| 513 |
+
animate={{ opacity: 1, scale: 1 }}
|
| 514 |
+
className="inline-flex items-center gap-1.5 bg-cyan-500/10 border border-cyan-500/30 text-cyan-300 text-[10px] font-bold px-2 py-0.5 rounded-full mb-1 animate-pulse"
|
| 515 |
+
>
|
| 516 |
+
<Volume2 size={10} /> Speaking...
|
| 517 |
+
</motion.div>
|
| 518 |
+
)}
|
| 519 |
+
|
| 520 |
+
<div className={`p-3 md:p-4 rounded-2xl text-sm leading-relaxed shadow-sm ${getMessageStyle(msg)}`}>
|
| 521 |
+
{msg.image && (
|
| 522 |
+
<img src={msg.image} alt="Uploaded" className="max-w-full w-full h-auto rounded-lg mb-3 border border-white/10" />
|
| 523 |
+
)}
|
| 524 |
+
<div className="whitespace-pre-wrap break-words">
|
| 525 |
+
{msg.text.split('**').map((part, i) =>
|
| 526 |
+
i % 2 === 1
|
| 527 |
+
? <strong key={i} className={msg.mode === 'rag' ? "text-cyan-300 font-bold" : "text-orange-300 font-bold"}>{part}</strong>
|
| 528 |
+
: part
|
| 529 |
+
)}
|
| 530 |
+
</div>
|
| 531 |
+
</div>
|
| 532 |
+
|
| 533 |
+
{/* Sources */}
|
| 534 |
+
{msg.sources && msg.sources.length > 0 && (
|
| 535 |
+
<div className="flex flex-wrap gap-1.5 pl-1 mt-1">
|
| 536 |
+
{msg.sources.map((src, idx) => {
|
| 537 |
+
const isPageCited = src.includes('[Pg.');
|
| 538 |
+
const fileNameOnly = src.split(' [Pg.')[0];
|
| 539 |
+
const pageMatch = src.match(/\[Pg\. (\d+)\]/);
|
| 540 |
+
const pageNumber = pageMatch ? pageMatch[1] : null;
|
| 541 |
+
const viewUrl = `${API_URL}/view/${encodeURIComponent(fileNameOnly)}${pageNumber ? `#page=${pageNumber}` : ''}`;
|
| 542 |
+
|
| 543 |
+
return (
|
| 544 |
+
<a
|
| 545 |
+
key={idx}
|
| 546 |
+
href={viewUrl}
|
| 547 |
+
target="_blank"
|
| 548 |
+
rel="noopener noreferrer"
|
| 549 |
+
className="text-[10px] bg-slate-800/50 hover:bg-slate-700 text-slate-400 hover:text-cyan-300 px-2 py-1 rounded border border-white/5 hover:border-cyan-500/30 truncate max-w-[200px] md:max-w-[280px] cursor-pointer transition-all flex items-center gap-1"
|
| 550 |
+
title={`View ${fileNameOnly} at Page ${pageNumber || 1}`}
|
| 551 |
+
>
|
| 552 |
+
{isPageCited ? 'π' : 'π'} <span className="truncate">{src}</span>
|
| 553 |
+
</a>
|
| 554 |
+
);
|
| 555 |
+
})}
|
| 556 |
+
</div>
|
| 557 |
+
)}
|
| 558 |
+
|
| 559 |
+
{msg.sender === 'ai' && !msg.sources?.length && msg.mode === 'general' && (
|
| 560 |
+
<div className="text-[10px] text-slate-500 pl-1 italic">Generated using General Knowledge</div>
|
| 561 |
+
)}
|
| 562 |
+
</div>
|
| 563 |
+
</motion.div>
|
| 564 |
+
))}
|
| 565 |
+
</AnimatePresence>
|
| 566 |
+
|
| 567 |
+
{isLoading && (
|
| 568 |
+
<div className="md:max-w-3xl md:mx-auto w-full flex gap-3">
|
| 569 |
+
<div className="w-7 h-7 rounded-full bg-slate-800 flex items-center justify-center shrink-0 border border-white/10">
|
| 570 |
+
<Bot size={14} className="text-slate-400 animate-pulse" />
|
| 571 |
+
</div>
|
| 572 |
+
<div className="flex items-center gap-2 text-slate-400 text-sm pt-1">
|
| 573 |
+
<Loader2 size={15} className="animate-spin text-cyan-400" />
|
| 574 |
+
Generating Intelligence...
|
| 575 |
+
</div>
|
| 576 |
+
</div>
|
| 577 |
+
)}
|
| 578 |
+
<div ref={messagesEndRef} />
|
| 579 |
+
</div>
|
| 580 |
+
|
| 581 |
+
{/* ββ INPUT ββ */}
|
| 582 |
+
<div className="p-3 md:p-4 bg-slate-900 border-t border-white/10 z-20 safe-area-bottom">
|
| 583 |
+
<div className="md:max-w-3xl md:mx-auto w-full">
|
| 584 |
+
<AnimatePresence>
|
| 585 |
+
{previewUrl && (
|
| 586 |
+
<motion.div
|
| 587 |
+
initial={{ opacity: 0, height: 0 }}
|
| 588 |
+
animate={{ opacity: 1, height: 'auto' }}
|
| 589 |
+
exit={{ opacity: 0, height: 0 }}
|
| 590 |
+
className="flex items-center gap-3 mb-2 bg-slate-800 p-2 rounded-lg w-fit border border-white/10"
|
| 591 |
+
>
|
| 592 |
+
<img src={previewUrl} alt="Preview" className="w-9 h-9 rounded object-cover" />
|
| 593 |
+
<span className="text-xs text-slate-300 max-w-[160px] truncate">{selectedImage?.name}</span>
|
| 594 |
+
<button onClick={clearImage} className="p-1 hover:bg-white/10 rounded-full text-slate-400 hover:text-white">
|
| 595 |
+
<X size={14} />
|
| 596 |
+
</button>
|
| 597 |
+
</motion.div>
|
| 598 |
+
)}
|
| 599 |
+
</AnimatePresence>
|
| 600 |
+
|
| 601 |
+
<div className={`flex items-center gap-2 bg-slate-800 px-2 py-2 rounded-xl border transition-all shadow-lg ${isRagEnabled ? 'focus-within:border-cyan-500/50 border-white/10' : 'focus-within:border-orange-500/50 border-white/10'}`}>
|
| 602 |
+
<input
|
| 603 |
+
type="file"
|
| 604 |
+
ref={fileInputRef}
|
| 605 |
+
onChange={handleImageSelect}
|
| 606 |
+
accept="image/*"
|
| 607 |
+
className="hidden"
|
| 608 |
+
/>
|
| 609 |
+
<button
|
| 610 |
+
onClick={() => fileInputRef.current?.click()}
|
| 611 |
+
className={`p-1.5 rounded-lg transition-all shrink-0 ${selectedImage ? 'text-cyan-400 bg-cyan-400/10' : 'text-slate-400 hover:text-white hover:bg-slate-700'}`}
|
| 612 |
+
>
|
| 613 |
+
<Paperclip size={18} />
|
| 614 |
+
</button>
|
| 615 |
+
|
| 616 |
+
<input
|
| 617 |
+
type="text"
|
| 618 |
+
value={input}
|
| 619 |
+
onChange={(e) => setInput(e.target.value)}
|
| 620 |
+
onKeyDown={handleKeyPress}
|
| 621 |
+
placeholder={isRagEnabled ? "Ask about your syllabus..." : "Ask anything..."}
|
| 622 |
+
className="flex-1 bg-transparent text-sm text-white placeholder-slate-500 outline-none min-w-0 py-1"
|
| 623 |
+
disabled={isLoading}
|
| 624 |
+
/>
|
| 625 |
+
|
| 626 |
+
<button
|
| 627 |
+
onClick={handleSend}
|
| 628 |
+
disabled={isLoading || (!input.trim() && !selectedImage)}
|
| 629 |
+
className={`p-2 rounded-lg text-white shadow-lg transition-all shrink-0 ${isRagEnabled ? 'bg-cyan-600 hover:bg-cyan-500' : 'bg-orange-600 hover:bg-orange-500'} disabled:opacity-50 disabled:cursor-not-allowed`}
|
| 630 |
+
>
|
| 631 |
+
<Send size={16} />
|
| 632 |
+
</button>
|
| 633 |
+
</div>
|
| 634 |
+
|
| 635 |
+
<div className="text-center mt-1.5">
|
| 636 |
+
<p className="text-[10px] text-slate-600">
|
| 637 |
+
Mode: <span className={isRagEnabled ? "text-cyan-400 font-bold" : "text-orange-500 font-bold"}>
|
| 638 |
+
{isRagEnabled ? "RAG (Files)" : "General (Internet)"}
|
| 639 |
+
</span>
|
| 640 |
+
</p>
|
| 641 |
+
</div>
|
| 642 |
+
</div>
|
| 643 |
+
</div>
|
| 644 |
+
</main>
|
| 645 |
+
</div>
|
| 646 |
+
);
|
| 647 |
+
}
|
| 648 |
+
|
| 649 |
+
export default App;
|
frontend/src/assets/react.svg
ADDED
|
|
frontend/src/index.css
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@import "tailwindcss";
|
| 2 |
+
|
| 3 |
+
@theme {
|
| 4 |
+
--animate-blob: blob 7s infinite;
|
| 5 |
+
|
| 6 |
+
@keyframes blob {
|
| 7 |
+
0% { transform: translate(0px, 0px) scale(1); }
|
| 8 |
+
33% { transform: translate(30px, -50px) scale(1.1); }
|
| 9 |
+
66% { transform: translate(-20px, 20px) scale(0.9); }
|
| 10 |
+
100% { transform: translate(0px, 0px) scale(1); }
|
| 11 |
+
}
|
| 12 |
+
}
|
frontend/src/main.jsx
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { StrictMode } from 'react'
|
| 2 |
+
import { createRoot } from 'react-dom/client'
|
| 3 |
+
import './index.css'
|
| 4 |
+
import App from './App.jsx'
|
| 5 |
+
|
| 6 |
+
createRoot(document.getElementById('root')).render(
|
| 7 |
+
<StrictMode>
|
| 8 |
+
<App />
|
| 9 |
+
</StrictMode>,
|
| 10 |
+
)
|
frontend/vite.config.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { defineConfig } from 'vite'
|
| 2 |
+
import react from '@vitejs/plugin-react'
|
| 3 |
+
import tailwindcss from '@tailwindcss/vite'
|
| 4 |
+
|
| 5 |
+
// https://vitejs.dev/config/
|
| 6 |
+
export default defineConfig({
|
| 7 |
+
plugins: [
|
| 8 |
+
react(),
|
| 9 |
+
tailwindcss(),
|
| 10 |
+
],
|
| 11 |
+
})
|