Skip to content

prabhatKumar65/PMJAY-Chatbot-POC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ PMJAY AI-MITRA(ChatBot) POC

Status AI Cost Python MongoDB

πŸ“± Live Preview

PMJAY AI-Mitra Chatbot Interface

PMJAY AI-Mitra - Clean User Interface


βœ… What's Special:

  • English-only (clean, professional responses)
  • FREE (uses Ollama Mistral β€” no API costs)
  • No Hindi gibberish (perfect English)
  • MongoDB storage (all conversations saved)
  • Real AI (human-like responses)
  • Production-ready (reliable & fast)

πŸš€ QUICK SETUP (5 Minutes)

Step 1: Seed Database

cd pmjay-english
pip install pymongo
python seed_data.py

Output:

βœ… Inserted 6 beneficiaries
βœ… Inserted 5 ration cards
βœ… Inserted 7 hospitals
πŸŽ‰ DATABASE SEEDED SUCCESSFULLY!

Step 2: Install Requirements

pip install -r requirements.txt

Step 3: Start Ollama (Mistral)

Terminal 1:

ollama serve

Check if mistral is available:

ollama list

If mistral not in list, pull it:

ollama pull mistral

Step 4: Start Backend

Terminal 2:

uvicorn main:app --reload

Step 5: Open Browser

http://localhost:8000

πŸ’¬ TESTING β€” Try These

Test 1: Basic Greeting

You: hello
Bot: Hello! I'm PMJAY AI-Mitra. I can help you with PM-JAY eligibility checks, finding hospitals, and understanding scheme benefits. What would you like to know?

Test 2: Eligibility Check

You: am i eligible?
Bot: I can help you check PM-JAY eligibility! 😊
     Please choose one:
     β€’ Type 'Aadhaar' to check with Aadhaar number
     β€’ Type 'Ration' to check with Ration Card number

You: aadhaar
Bot: Please enter your 12-digit Aadhaar number.
     πŸ“ For demo, try: 123456789012

You: 123456789012
Bot: βœ… Great news! Ramesh Kumar is eligible for PM-JAY.
     πŸ“‹ Details:
     β€’ Card Number: PMJAY-UP-12345
     β€’ State: Uttar Pradesh
     β€’ Family Members: 3

Test 3: Hospital Search

You: find hospital
Bot: I'll help you find empanelled hospitals! πŸ₯
     Please tell me your state name.

You: Bihar
Bot: Got it! Searching for hospitals in Bihar.
     Please provide your 6-digit pincode.

You: 800001
Bot: πŸ₯ Found 2 empanelled hospital(s):
     β€’ AIIMS Patna
       πŸ“ Patna, Bihar
       πŸ“ž 0612-2451070
     β€’ IGIMS Patna
       πŸ“ Patna, Bihar
       πŸ“ž 0612-2297321

Test 4: Scheme Info

You: what is PMJAY?
Bot: πŸ“‹ About Pradhan Mantri Jan Arogya Yojana (PM-JAY):
     β€’ World's largest health insurance scheme
     β€’ β‚Ή5 lakh coverage per family per year
     β€’ Covers 1,949 medical procedures
     β€’ Cashless treatment at 27,000+ empanelled hospitals

Test 5: Natural Chat

You: how does it work?
Bot: [AI explains in natural English]

You: is it free?
Bot: [AI explains free eligibility and benefits]

πŸ“Š DEMO DATA

Aadhaar Numbers:

123456789012 β†’ Ramesh Kumar (Eligible βœ…)
111122223333 β†’ Sita Devi (Eligible βœ…)
999988887777 β†’ Amit Sharma (Not Eligible ❌)
444455556666 β†’ Priya Singh (Eligible βœ…)
777788889999 β†’ Mohammad Alam (Eligible βœ…)
555566667777 β†’ Lakshmi Bai (Eligible βœ…)

Ration Cards:

RC1001 β†’ Eligible βœ…
RC2002 β†’ Not Eligible ❌
RC3003 β†’ Eligible βœ…
RC4004 β†’ Eligible βœ…
RC5005 β†’ Eligible βœ…

Hospitals (by Pincode):

800001 β†’ Bihar (AIIMS Patna, IGIMS Patna)
110001 β†’ Delhi (AIIMS Delhi)
201301 β†’ Uttar Pradesh (Max Hospital Noida)
600006 β†’ Tamil Nadu (Apollo Hospital Chennai)
700107 β†’ West Bengal (Fortis Hospital Kolkata)
462001 β†’ Madhya Pradesh (Hamidia Hospital Bhopal)

πŸ” MONITORING ENDPOINTS

Check Stats

http://localhost:8000/stats

Response:

{
  "beneficiaries": 6,
  "ration_cards": 5,
  "hospitals": 7,
  "conversations": 12,
  "active_sessions": 1
}

Test AI

http://localhost:8000/test-ai

Response:

{
  "status": "βœ… Working",
  "model": "mistral",
  "ai_response": "Hello! How can I help you today..."
}

🎯 WHY THIS VERSION IS BEST:

βœ… No Cost

  • Ollama is FREE forever
  • No API charges
  • Runs on your laptop

βœ… English Only

  • Clean, professional responses
  • No Hindi gibberish
  • Perfect grammar

βœ… Fast & Reliable

  • Mistral model (optimized for English)
  • Fallback to structured responses
  • No timeouts

βœ… Production Ready

  • MongoDB storage
  • Session management
  • Conversation history
  • Error handling

❌ TROUBLESHOOTING

Problem: "Connection refused"

Check MongoDB:

mongosh
# Should connect successfully

If not running:

net start MongoDB  # Windows
brew services start mongodb-community  # Mac
sudo systemctl start mongod  # Linux

Problem: "Mistral not found"

ollama pull mistral
# Wait for download (it's ~4GB)
ollama list
# Should show mistral now

Problem: "AI giving gibberish"

Solution: We're using Mistral (better than phi3) and system prompts are optimized for English. Should not happen!

If it does:

  1. Restart Ollama: ollama serve
  2. Check terminal logs for errors
  3. Fallback responses will work anyway

Problem: "Slow responses"

This is normal β€” Mistral takes 3-5 seconds locally. But responses are high quality!

To speed up:

  • Use lighter model: Change model="phi3" in main.py (faster but lower quality)
  • Or use GPU if available

πŸ“ˆ NEXT STEPS (Future)

  1. Add more data (100+ beneficiaries, 50+ hospitals)
  2. Voice input (speech-to-text)
  3. File upload (Aadhaar card image β†’ OCR)
  4. WhatsApp integration
  5. Analytics dashboard

βœ… FINAL CHECKLIST

Before deployment, verify:

  • MongoDB running
  • Database seeded (6 beneficiaries, 5 cards, 7 hospitals)
  • Ollama running with mistral
  • Backend running (port 8000)
  • Browser opens chatbot
  • Quick action buttons work
  • Eligibility check works
  • Hospital search works
  • AI responses are clean English
  • No Hindi gibberish
  • Conversations saving to MongoDB

All βœ…? PERFECT! Demo ready. πŸŽ‰


πŸ’‘ IMPORTANT NOTES

Why Mistral over phi3?

  • Better English understanding
  • More natural responses
  • Less likely to give gibberish
  • Slightly slower but worth it

Why English-only?

  • Ollama models struggle with Hindi
  • Would need Gemini API for good Hindi (costs money)
  • English is professional & reliable
  • Most government portals use English anyway

Is it really FREE?

  • YES! 100% free forever
  • Ollama is open-source
  • MongoDB community edition is free
  • No hidden costs

🀝 Contributing

Found a bug or want to contribute? Feel free to:

  • πŸ› Report Issues
  • πŸ’‘ Suggest features
  • πŸ”§ Submit pull requests

πŸ‘¨β€πŸ’» Developer

Prabhat Kumar

LinkedIn Email GitHub

AI Agent Developer | Generative AI & LLM Engineer | AI/ML Enthusiast | Open Source Contributor


⭐ Show Your Support

If you found this project helpful, please consider giving it a ⭐ on GitHub!


πŸ™ Acknowledgments

  • PM-JAY Team - For the world's largest health insurance scheme
  • Ollama - For providing free, open-source AI models
  • MongoDB - For robust database solutions
  • FastAPI - For the powerful and fast backend framework

Made with ❀️ for Digital Health Inclusion

Β© 2024 PMJAY AI-Mitra. All Rights Reserved.

Empowering healthcare accessibility through AI

About

πŸ₯ PMJAY AI-Mitra: Intelligent chatbot for Ayushman Bharat scheme assistance. Features: Real-time eligibility verification, hospital search, AI-powered responses using Ollama Mistral. Stack: Python, FastAPI, MongoDB | Free & Open Source

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors