Skip to main content

title: MedReport AI emoji: 🏥 colorFrom: blue colorTo: indigo sdk: docker app_port: 8000 pinned: false

MedReport AI 🏥

Ask plain-language questions about any medical PDF — every answer is grounded in the document with exact source citations.

Python FastAPI Groq FAISS Docker License


What it does

Upload any medical PDF (discharge summaries, lab reports, referral letters) and ask questions in plain English. The app retrieves the most relevant passages from your document and uses Llama 3.3-70B via Groq to answer — never hallucinating beyond what the document says.

Feature Detail
📄 PDF ingestion PyMuPDF text extraction, 400-word chunks with 80-word overlap
🔍 Semantic search sentence-transformers all-MiniLM-L6-v2 + FAISS cosine similarity
🤖 LLM Groq llama-3.3-70b-versatile — fast, free tier available
💬 Chat UI Dark-themed glass-morphism interface, source citations, page references
🔒 Privacy Everything runs locally / in your container — no data leaves your server

Architecture

PDF Upload
    │
    ▼
PyMuPDF ──► Text Chunks (400w / 80w overlap)
                │
                ▼
        SentenceTransformer          FAISS IndexFlatIP
        (all-MiniLM-L6-v2)    ──►   (cosine similarity)
                                          │
User Question ──► embed ──────────────► top-5 chunks
                                          │
                                          ▼
                                  Groq llama-3.3-70b
                                  (system + context prompt)
                                          │
                                          ▼
                               Answer + Citations (page, score)

Quick start

Prerequisites

1. Clone & install

git clone https://github.com/abdullahkousa2/medreport-ai.git
cd medreport-ai
pip install -r requirements.txt

2. Set your API key

cp .env.example .env
# then edit .env and paste your Groq key:
# GROQ_API_KEY=gsk_...

3. Run

uvicorn app.main:app --host 127.0.0.1 --port 8000

Open http://localhost:8000 — drop in a PDF and start asking questions.


Docker

docker build -t medreport-ai .
docker run -p 8000:8000 -e GROQ_API_KEY=gsk_your_key_here medreport-ai

API Reference

Endpoint Method Description
GET / GET Serve the chat UI
POST /api/upload POST Upload a PDF → returns session_id
POST /api/ask POST Ask a question → returns answer + citations
GET /health GET Health check

Upload

POST /api/upload
Content-Type: multipart/form-data

file: <your-pdf>
{
  "session_id": "uuid-string",
  "filename": "report.pdf",
  "chunks_indexed": 47,
  "message": "Indexed 47 text segments — ready to answer questions."
}

Ask

POST /api/ask
Content-Type: application/json

{ "session_id": "uuid-string", "question": "What medications were prescribed?" }
{
  "answer": "According to Source 2, the patient was prescribed Aspirin 75mg...",
  "citations": [
    { "source": 1, "page": 4, "excerpt": "...", "score": 0.891 }
  ]
}

Sample report

A realistic fake cardiac discharge summary (sample_medical_report.pdf) is included for testing. Regenerate it with:

pip install reportlab
python generate_sample_report.py

Project structure

medreport-ai/
├── app/
│   ├── main.py              # FastAPI app, routes, static files
│   ├── rag_engine.py        # PDF processing, FAISS index, Groq Q&A
│   ├── routers/
│   │   └── api.py           # /api/upload and /api/ask endpoints
│   └── static/
│       ├── index.html       # Chat UI
│       ├── style.css        # Design system (dark glass-morphism)
│       └── app.js           # Upload, chat, citations logic
├── Dockerfile
├── requirements.txt
├── .env.example
├── generate_sample_report.py
└── sample_medical_report.pdf

Tech stack

Layer Technology
Web framework FastAPI 0.111
LLM Groq API — llama-3.3-70b-versatile
Embeddings sentence-transformersall-MiniLM-L6-v2
Vector search FAISS IndexFlatIP (cosine via L2-normalised inner product)
PDF parsing PyMuPDF (fitz)
Frontend Vanilla HTML / CSS / JS — no framework
Container Docker (python:3.10-slim)

License

MIT — free to use, modify, and deploy.

Release files for medreport-ai 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for medreport-ai 0.1.1
File Size Uploaded
medreport_ai-0.1.1.tar.gz 21.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for medreport-ai 0.1.1
File Interpreter ABI Platform
medreport_ai-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 41.0 kB

Release files / medreport_ai-0.1.1.tar.gz

Download URL medreport_ai-0.1.1.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ab982bcdac257dbb3163f92e84c1efbd61d9c0902a8adf41ef1953b5c9d6ac66
BLAKE2b-256 checksum
How to use checksums
c1fdfd3fe6fd3d0435379fdc67c6f0569781d7944841cb94b286f2beaa3c1e6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.9

Release files / medreport_ai-0.1.1-py3-none-any.whl

Download URL medreport_ai-0.1.1-py3-none-any.whl
Size 19.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a32e0c2ecaec5ee59cdd44e28ac12a72294be756e7052fbb43fa16fbeafcab41
BLAKE2b-256 checksum
How to use checksums
5c45283316e384711834e55f77d7e5094d8ff652d7802a4bd7d5b9b8dafaaaef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.9

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page