Skip to content

mudrabhedi/my-medibot-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🩺 MediBot – AI-Powered Medical Chatbot (Mobile + Flask Backend)

MediBot is an intelligent, generative AI-based medical chatbot that provides accurate, context-aware responses to health-related queries. It integrates state-of-the-art large language models (LLMs) using Retrieval-Augmented Generation (RAG) and delivers real-time answers via an Android app built with WebView.

⚠️ Disclaimer: MediBot is an informational tool and not a substitute for professional medical advice, diagnosis, or treatment.


πŸ“Œ Features

  • 🧠 Powered by transformer-based LLMs (e.g., LLaMA-3.1-8B-Instruct)
  • πŸ” Context-aware responses using FAISS + LangChain RetrievalQA
  • πŸ“± Android frontend with React Native + WebView
  • πŸ”— Seamless Flask-based backend integration
  • πŸ“‚ Dynamic PDF ingestion and semantic embedding creation
  • 🌐 Deployed via Hugging Face Inference API

πŸ“ Architecture Overview

flowchart TD
    A[User Query via Android App] --> B[POST to Flask API]
    B --> C[Retrieve Env Vars & Model Config]
    C --> D[LangChain RetrievalQA Pipeline]
    D --> E[Fetch Chunks from FAISS]
    E --> F[Form Prompt + Context]
    F --> G[Call HuggingFace InferenceClient]
    G --> H[Generate & Return Answer]
    H --> I[Display Response in Mobile UI]
    subgraph Setup
    J[Upload PDFs] --> K[Chunk Text] --> L[Embed with SentenceTransformer] --> M[FAISS Index]
    end
    M --> E
Loading

πŸ› οΈ Tech Stack

Layer Technology
Frontend React Native, WebView, Expo Go
Backend Flask, Python, LangChain, dotenv
Embedding sentence-transformers, FAISS
LLM Hugging Face InferenceClient (LLaMA)
Retrieval LangChain RetrievalQA Chain
Storage Local FAISS Vectorstore

πŸ“‚ Folder Structure

β”œβ”€β”€ medibot-app/                           # Core logic for embedding + memory management
β”‚   β”œβ”€β”€ connect_memory_with_llm.py         # Retrieval pipeline with LLM
β”‚   β”œβ”€β”€ create_memory_for_llm.py           # Embedding medical PDFs into FAISS
β”‚   β”œβ”€β”€ file.gitignore
β”‚   β”œβ”€β”€ medibot.py                         # Main interface file
β”‚   β”œβ”€β”€ test.py
β”‚   β”œβ”€β”€ README.md
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ data/                              # PDF files for ingestion
β”‚   └── vectorstore/                       # FAISS index storage
β”‚
β”œβ”€β”€ medibot-flask/                         # Flask backend for serving the LLM pipeline
β”‚   β”œβ”€β”€ app.py                             # Flask API entrypoint
β”‚   β”œβ”€β”€ requirements.txt                   # Python dependencies
β”‚   β”œβ”€β”€ .gitignore
β”‚   └── vectorstore/                       # Shared FAISS index
β”‚
β”œβ”€β”€ medibot-react-app/
β”‚   └── medibot-app/                       # React Native frontend
β”‚       β”œβ”€β”€ App.js                         # Root of the mobile app
β”‚       β”œβ”€β”€ app/                           # Navigation and screen components
β”‚       β”œβ”€β”€ assets/                        # Images, icons
β”‚       β”œβ”€β”€ components/                    # UI components
β”‚       β”œβ”€β”€ constants/                     # Static configs
β”‚       β”œβ”€β”€ hooks/                         # React hooks
β”‚       β”œβ”€β”€ scripts/                       # Any automation/util scripts
β”‚       β”œβ”€β”€ node_modules/
β”‚       β”œβ”€β”€ eas.json                       # Expo app config
β”‚       β”œβ”€β”€ app.json                       # Project manifest
β”‚       β”œβ”€β”€ package.json                   # JS dependencies
β”‚       β”œβ”€β”€ tsconfig.json                  # TypeScript config
β”‚       └── README.md


πŸš€ Getting Started

1. Clone the Repository

git clone https://github.com/<your-username>/medibot.git
cd medibot

2. Setup the Backend

cd medibot-flask
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows
pip install -r requirements.txt

Create a .env file:

HF_TOKEN=your_huggingface_api_token
HUGGINGFACE_REPO_ID=meta-llama/Llama-3.1-8B-Instruct
DB_FAISS_PATH=vectorstore/db_faiss

Then run:

python app.py

3. Generate the Embedding Memory

python create_memory_for_llm.py

4. Launch the React Native App

cd ../medical-chatbot
npm install
npx expo start

Scan the QR code on Expo Go app to preview it on your phone.


πŸ“Έ Screenshots

Insert screenshots of:

  • The Android app UI
  • WhatsApp Image 2025-05-15 at 00 53 58_8e670e3e
  • Web App UI
  • Screenshot 2025-05-15 093316

πŸ§ͺ Testing

  • Use sample PDFs in the /data/ folder to simulate ingestion.
  • Try queries like:
    • β€œWhat are the symptoms of dengue?”
    • β€œHow to treat a mild fever?”
  • Evaluate response speed, context relevance, and coherence.

πŸ”„ Future Enhancements

  • πŸ” Multi-turn chat memory
  • 🌍 Multilingual input/output support
  • 🎀 Speech-to-text and text-to-speech capabilities
  • πŸ’Ύ On-device inference using quantized models
  • πŸ“Š Feedback loop + model fine-tuning dashboard

πŸ™‹β€β™€οΈ Contributing

  1. Fork this repo
  2. Create a new branch (git checkout -b feature/xyz)
  3. Commit your changes (git commit -m 'Add feature')
  4. Push to the branch (git push origin feature/xyz)
  5. Create a pull request!

πŸ“œ License

This project is licensed under the MIT License.


πŸ™ Acknowledgements

Demo Video of the App

About

MediBot is an AI-powered medical chatbot delivering context-aware health answers via an Android app with a Flask backend. It uses advanced LLMs, FAISS vector search, and LangChain to provide accurate, real-time responses based on medical documents.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors