Skip to content

Sahil0015/MedGuide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🩺 MedGuide β€” AI Health Companion

MedGuide is an intelligent AI-powered application that interprets blood and lab test reports, generates structured summaries, and enables contextual chat about health results.
It combines multi-agent reasoning, vector-based retrieval (LanceDB), and LLMs (OpenAI GPT + Cohere Reranker) to deliver factual, explainable, and user-friendly insights.


πŸš€ Features

  • 🧠 AI-driven report analysis: Automatically extracts and analyzes lab report values.
  • πŸ“„ Page-wise interpretation: Asynchronous agents process each page independently.
  • πŸ“Š Structured final report: Merges multi-page insights into one comprehensive summary.
  • πŸ’¬ Conversational interface: Chat with your analyzed reports using hybrid RAG retrieval.
  • ⚑ Hybrid search: Combines vector + keyword search (LanceDB + Cohere reranker).
  • 🧩 Local knowledge base: Builds an offline LanceDB store for efficient querying.
  • πŸ§‘β€βš•οΈ Safe AI design: Focused on factual, educational insights β€” not medical advice.

πŸ—οΈ Project Architecture

MedGuide/
β”‚
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ streamlit_app.py        # Main Streamlit UI
β”‚   β”œβ”€β”€ app.py                  # FastAPI REST backend
β”‚   β”œβ”€β”€ main.py                 # CLI pipeline for local testing
β”‚   β”œβ”€β”€ data/                   # Stores processed text, LanceDB, and uploads
β”‚
β”œβ”€β”€ agents/
β”‚   β”œβ”€β”€ analyzer_agent.py       # Interprets lab values page-wise
β”‚   β”œβ”€β”€ chat_agent.py           # Conversational RAG agent
β”‚   β”œβ”€β”€ document_extraction_agent.py  # Extracts test names, values, ranges
β”‚   β”œβ”€β”€ final_report_agent.py   # Combines all pages into a summary report
β”‚
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ pdf_extractor.py        # Extracts text from PDFs using PyMuPDF
β”‚   β”œβ”€β”€ pdf_to_txt.py           # Converts PDFs into text for preprocessing
β”‚
β”œβ”€β”€ vectordb/
β”‚   β”œβ”€β”€ create_vector_db.py     # Builds LanceDB-based knowledge base
β”‚
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ knowledge_base/         # (Ignored in Git) Private extracted data
β”‚   β”œβ”€β”€ sample_reports/         # Example lab reports
β”‚   β”œβ”€β”€ lancedb/                # Vector DB storage
β”‚
β”œβ”€β”€ requirements.txt            # Dependencies
β”œβ”€β”€ .gitignore                  # Ignore rules
└── README.md                   # Documentation

🧠 How It Works

πŸ”Ή Step 1 β€” Upload

Upload any PDF-based lab report via the Streamlit interface.

πŸ”Ή Step 2 β€” Extraction

document_extraction_agent parses test names, values, and reference ranges.

πŸ”Ή Step 3 β€” Analysis

analyzer_agent interprets results and gives concise, factual explanations.

πŸ”Ή Step 4 β€” Report Generation

final_report_agent merges all insights into a single structured health report.

πŸ”Ή Step 5 β€” Knowledge Base Creation

create_vector_db.py generates a LanceDB vector store for RAG retrieval.

πŸ”Ή Step 6 β€” Chat Interaction

chat_agent enables conversations with your report using OpenAI GPT + Cohere.


πŸ› οΈ Installation & Setup

1️⃣ Clone the repository

git clone https://github.com/Sahil0015/MedGuide.git
cd MedGuide

2️⃣ Create and activate a virtual environment

python -m venv venv
venv\Scripts\activate      # On Windows
# source venv/bin/activate # On Mac/Linux

3️⃣ Install dependencies

pip install -r requirements.txt

4️⃣ Set up environment variables

Create a .env file in the project root:

OPENAI_API_KEY=your_openai_api_key
COHERE_API_KEY=your_cohere_api_key

5️⃣ Run the Streamlit app

streamlit run app/streamlit_app.py

🧬 Technologies Used

Category Technologies
Frontend Streamlit
LLMs & Agents OpenAI GPT, Agno, LangChain
Retrieval & DB LanceDB, RedisVL, Cohere Reranker
PDF Processing PyMuPDF, Tantivy
Utilities Python-dotenv, TQDM, Pandas

🧾 Key Files

File Purpose
app/streamlit_app.py Main Streamlit interface
app/app.py FastAPI REST backend (upload, process, chat endpoints)
app/main.py CLI pipeline runner for local testing
vectordb/create_vector_db.py Creates LanceDB vector store
utils/pdf_extractor.py PDF text extraction
utils/pdf_to_txt.py Converts PDF to text
agents/*.py Multi-agent logic for report extraction, analysis, and chat

βš™οΈ .gitignore Overview

Your .gitignore excludes:

data/knowledge_base/
venv/
.env
.cache/
__pycache__/

β†’ Ensuring sensitive or auto-generated data is never uploaded.


πŸ§ͺ Example Workflow

  1. Launch the Streamlit app.
  2. Input your API keys and initialize.
  3. Upload a lab report (PDF).
  4. AI agents extract, analyze, and summarize results.
  5. Review the generated final report.
  6. Chat interactively with the app about your results.

βš–οΈ Disclaimer

MedGuide provides AI-generated educational insights based on lab data.
It is not a medical diagnostic tool β€” always consult a certified doctor for medical decisions.


πŸ’‘ Future Enhancements

  • Expand multi-language report interpretation.
  • Support FHIR / HL7 medical data formats.
  • Implement persistent chat memory across sessions and report history.
  • Add user authentication for personalized report management.
  • Deploy as a Docker container on cloud platforms (AWS, GCP, Azure).

πŸ“œ License

This project is licensed under the MIT License.


πŸ™Œ Acknowledgements

  • OpenAI for GPT models
  • Cohere for Reranker API
  • LanceDB for high-speed vector storage
  • Streamlit for a smooth frontend experience
  • Agno and LangChain for agent orchestration

πŸ’– Contributions

Pull requests and suggestions are welcome!
If you’d like to contribute, please fork the repository and create a PR.


πŸ”— Connect

πŸ‘¨β€πŸ’» Author: Sahil Aggarwal
πŸ“‚ GitHub: Sahil0015
βœ‰οΈ Email: sahilaggarwal1532003@gmail.com

About

AI-powered health report assistant that analyzes blood and lab test reports using multi-agent reasoning, hybrid RAG (LanceDB + Cohere), and LLMs to generate structured medical insights and contextual chat.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors