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.