In today's digital health era, there's a growing need for tools that help users make sense of complex medical documents. This is where MedAI Pro comes into play β a streamlined, AI-powered assistant built with Streamlit, CAMEL-AI Agent, and LLaMA 4 via the GROQ-API, designed to interpret and explain PDF-based medical reports in a conversational manner.
In this blog, weβll break down how the project works, explore the key technologies used, and guide you through how you can run or extend the app yourself.
β¨ What is MedAI Pro?
MedAI Pro is a web application where users can upload their medical reports in PDF format, ask natural language questions about the content, and receive both a written and spoken response powered by a Large Language Model.
Key Features:
- Upload and parse medical reports in PDF format
- Chat interface for asking questions
- Text and audio-based responses
- Role-based CAMEL-AI agents for contextual answers
π©Ί Imagine this... You're a doctor, student, or just someone trying to understand a lab report. You open a 50-page PDF filled with blood work, medical terms, and charts.
You have one question:
βIs the patientβs WBC count normal?β
But you're stuck scanning through paragraphs.
"Imagine asking a question and receiving the answer in just secondsβdelivered seamlessly in both text and audio formats. Instant, accurate, and fully interactive!"
π₯ Meet Med-AI Med-AI is a blazing-fast PDF Q&A assistant for medical documents.
π Project Structure
Hereβs what the repository contains:
MedAi/
βββ app.py # Streamlit frontend and orchestrator
βββ camel_agents.py # CAMEL-style agent logic with LLaMA 4 and Groq API
βββ parse_report.py # PDF parsing logic using PyMuPDF
βββ requirements.txt # All required Python packages
βββ .env # For storing API keys securely
π Under the Hood: Code Breakdown
app.py: The Streamlit Web Interface
The main UI and logic control center. It lets users upload a
medical PDF, input a question, and then displays (and plays)
the AIβs response.
Streamlit is used to create an intuitive UI
PDF Uploading: st.file_uploader() allows users to upload a PDF
Parsing: Calls parse_report.py to extract readable text
Query Handling: User question and extracted report are sent to
camel_agents.pyResponse: Displays the model's answer and converts it to audio
using gTTS
parse_report.py: Extracting Text from PDF
This module uses PyMuPDF (fitz) to read and extract text from
every page of the uploaded PDF.
import fitz # PyMuPDF
def extract_text_from_pdf(file):
pdf = fitz.open(stream=file.read(), filetype="pdf")
text = "\n".join(page.get_text() for page in pdf)
return text
This ensures that medical data is accurately captured for AI processing
camel_agents.py: Role-Based Prompting with CAMEL + LLaMA 4
This module goes beyond traditional prompt engineering and implements a true CAMEL-style role-based agent architecture, using the official CAMEL AI structure β including:
ChatAgent
BaseMessage
RoleTypeonse.
π¨ββοΈ Role: Doctor Agent
Instead of just using raw strings to define prompts, MedAI uses a Doctor agent object with predefined role behavior. Here's how it looks:
doctor = ChatAgent(
system_message=BaseMessage(
role_name="Doctor",
role_type=RoleType.ASSISTANT,
content="""You are a medical expert. Analyze reports and
provide concise, medically accurate answers.
Focus on lab values, terminology, and
conditions. Be factual, not speculative."""
)
)
βοΈ Model Initialization: LLaMA 4 via Groq with CAMELβs ModelFactory
The MedAI project leverages CAMEL AIβs modular model factory to connect with the latest LLaMA 4 model hosted on Groq. This is done through the ModelFactory API provided in the CAMEL agent framework.
self.model = ModelFactory.create(
model_platform=ModelPlatformType.GROQ,
model_type="meta-llama/llama-4-maverick-17b-128e-instruct"
)
.env: API Security
The .env file stores your Groq API key safely. Itβs loaded using python-dotenv
GROQ_API_KEY=your_actual_key_here
π Running the Project
Step 1: Clone the Repo
git clone https://github.com/tushar80rt/MedAi
cd MedAi
Step 2:π¦ Installation
camel-ai[all]
PyMuPDF==1.23.9
python-dotenv==1.0.1
streamlit
gTTS==2.5.1
groq
Step 3: Install Dependencies
pip install -r requirements.txt
Step 3: Add Your API Key
Create a .env file with your Groq key:
GROQ_API_KEY=your_api_key
Step 4: Run the App
streamlit run app.py
Visit http://localhost:8501, upload a report, and start asking questions.
π Tech Stack
Frontend: Streamlit
PDF Parsing: PyMuPDF
LLM: LLaMA 4 via Groq API
Prompting Strategy: CAMEL AI-style agents
Audio Output: gTTS
π Final Thoughts
MedAI Pro is a powerful yet minimalistic prototype that combines the power of modern LLMs, voice output, and agent-style prompting to deliver valuable insights from medical reports. By leveraging the CAMEL AI architecture and Groq-hosted LLaMA 4, it sets a strong foundation for future intelligent healthcare tools.
Fork it, run it, and build something impactful.
GitHub: https://github.com/tushar80rt/MedAi
Author: Tushar Singh
Have questions or suggestions? Drop a comment or open an issue!



Top comments (1)
MedAI Pro is a web app that helps users understand complex medical reports by letting them upload PDFs and ask questions in natural language. It uses Streamlit for the interface, PyMuPDF to extract text, and CAMEL-AI agents with a Doctor role for accurate medical answers. For users interested in a Saudi medical report check, this system could be adapted to parse and interpret reports issued in Saudi Arabia. LLaMA 4 via Groq handles AI processing, and users get both text and audio responses, making it easier to interpret lab results or medical data quickly. The project is open-source, easy to run locally, and designed to be extendable.