Spaces:
Running
Running
File size: 6,171 Bytes
388aa42 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | ---
title: JanSahayak
emoji: ๐
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
---
# ๐ JanSahayak - AI-Powered Government Schemes & Exams Assistant
> Your personal AI assistant for discovering government schemes and competitive exam opportunities in India
[](https://huggingface.co/spaces)
[](https://flask.palletsprojects.com/)
[](https://www.langchain.com/)
---
## ๐ Features
### ๐ค Multi-Agent AI System
- **Profiling Agent**: Extracts structured user information
- **Scheme Agent**: Recommends relevant government schemes
- **Exam Agent**: Suggests competitive exams based on qualifications
- **RAG Agent**: Retrieves information from curated document database
### ๐ก Intelligent Capabilities
- โ
Natural language understanding of user profiles
- โ
Smart recommendations based on eligibility criteria
- โ
RAG (Retrieval-Augmented Generation) with FAISS vectorstore
- โ
Real-time web search via Tavily API
- โ
PDF generation for saving recommendations
- โ
Beautiful web interface with modern UI
---
## ๐ Deploy to Hugging Face Spaces (Recommended)
### Why Hugging Face Spaces?
- โ
**16GB RAM for FREE** (perfect for RAG apps!)
- โ
Built for ML/AI applications
- โ
Git-based deployment
- โ
Public URL instantly
- โ
Persistent storage
### Quick Deploy Steps:
**Method 1: Using HF CLI (Easiest)**
```bash
# Install HF CLI
pip install huggingface_hub[cli]
# Login
huggingface-cli login
# Create Space and push
huggingface-cli repo create jansahayak --type space --space_sdk gradio
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/jansahayak
git push hf main
```
**Method 2: Manual Setup**
1. **Create Space** on [huggingface.co/spaces](https://huggingface.co/spaces)
- Click "Create new Space"
- Name: `jansahayak`
- SDK: Select "Gradio" (works with Flask)
- Hardware: CPU basic (Free - 16GB RAM!)
- License: MIT
2. **Clone YOUR Space repo** (not GitHub!)
```bash
git clone https://huggingface.co/spaces/YOUR_USERNAME/jansahayak
cd jansahayak
```
3. **Copy your project files**
```bash
# Copy all files from your JanSahayak folder to the cloned space folder
cp -r /path/to/JanSahayak/* .
```
4. **Add Environment Variables** (Space Settings โ Variables and secrets)
```
GROQ_API_KEY=your_groq_key
TAVILY_API_KEY=your_tavily_key
HF_TOKEN=your_hf_token (optional)
SKIP_VECTORSTORES=false
```
5. **Push to Space**
```bash
git add .
git commit -m "Initial commit"
git push
```
Your app will be live at: `https://huggingface.co/spaces/YOUR_USERNAME/jansahayak`
### Important Notes:
- HF Spaces uses its own Git repo (not GitHub directly)
- App runs on port 7860 by default (Flask uses 5000, update if needed)
- First deployment may take 5-10 minutes to install dependencies
- Check Space logs if deployment fails
---
## ๐ ๏ธ Local Development
```bash
# Clone and setup
git clone https://github.com/YOUR_USERNAME/JanSahayak.git
cd JanSahayak
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/Mac
.venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Configure API keys
cp .env.example .env
# Edit .env with your keys
# Build vectorstores (optional - if you have PDFs)
python init_embeddings.py
# Run app
python app.py
# or use launcher scripts: start_web.bat (Windows) / ./start_web.sh (Linux/Mac)
```
Visit `http://localhost:5000`
---
## ๐ Get API Keys
| Service | URL | Free Tier | Used For |
|---------|-----|-----------|----------|
| **Groq** | [console.groq.com](https://console.groq.com) | โ
Yes | LLM Inference |
| **Tavily** | [tavily.com](https://tavily.com) | 1000 searches/mo | Web Search |
| **HuggingFace** | [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) | โ
Yes | Model Downloads |
---
## ๐พ Adding Custom Documents
### Government Schemes PDFs
1. Place PDFs in `data/schemes_pdfs/`
2. Run `python init_embeddings.py`
3. Restart app
### Exam Information PDFs
1. Place PDFs in `data/exams_pdfs/`
2. Run `python init_embeddings.py`
3. Restart app
Automatically indexed and searchable via RAG!
---
## ๐งช Technology Stack
- **Backend**: Flask
- **AI**: LangChain + LangGraph
- **LLM**: Groq (Llama 3.3 70B)
- **Embeddings**: sentence-transformers/all-MiniLM-L6-v2
- **Vector DB**: FAISS (local)
- **Search**: Tavily API
- **Frontend**: HTML5 + CSS3 + JavaScript
---
## ๐ Project Structure
```
JanSahayak/
โโโ app.py # Flask web app
โโโ main.py # CLI interface
โโโ agents/ # AI agents
โ โโโ profiling_agent.py
โ โโโ scheme_agent.py
โ โโโ exam_agent.py
โ โโโ rag_agent.py
โโโ rag/ # RAG components
โ โโโ embeddings.py
โ โโโ scheme_vectorstore.py
โ โโโ exam_vectorstore.py
โโโ data/ # Documents
โ โโโ schemes_pdfs/
โ โโโ exams_pdfs/
โโโ templates/ # HTML templates
โโโ static/ # CSS/JS
```
---
## ๐ Troubleshooting
**Memory issues on local machine?**
```env
# Set in .env
SKIP_VECTORSTORES=true
```
Uses web search only (no embeddings needed)
**Vectorstore errors?**
```bash
rm -rf rag/scheme_index rag/exam_index
python init_embeddings.py
```
---
## ๐ค Contributing
Contributions welcome! Fork โ Create branch โ Submit PR
---
## ๐ License
MIT License
---
## ๐ Acknowledgments
Built with [LangChain](https://www.langchain.com/), [Groq](https://groq.com/), [Tavily](https://tavily.com/), and โค๏ธ
---
Made for the people of India ๐ฎ๐ณ
|