jansahayak / README.md
Anmol4521's picture
Upload 95 files
388aa42 verified
metadata
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

Hugging Face Spaces Flask LangChain


๐ŸŒŸ 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)

# 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

    • 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!)

    git clone https://huggingface.co/spaces/YOUR_USERNAME/jansahayak
    cd jansahayak
    
  3. Copy your project files

    # 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

    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

# 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 โœ… Yes LLM Inference
Tavily tavily.com 1000 searches/mo Web Search
HuggingFace 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?

# Set in .env
SKIP_VECTORSTORES=true

Uses web search only (no embeddings needed)

Vectorstore errors?

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, Groq, Tavily, and โค๏ธ


Made for the people of India ๐Ÿ‡ฎ๐Ÿ‡ณ