
In the era of intelligent healthcare, reliable and privacy-preserving AI assistance has become crucial for both professionals and patients. However, most medical chatbots depend on external cloud APIs, leading to privacy risks, limited explainability, and potential misinformation. MEDIBOT introduces a multi-agent, retrieval-augmented, and privacy-focused medical conversational system that operates with strict domain control and dynamic reasoning.
By orchestrating specialized AI agents—ranging from Drug Information and Diagnosis to Lifestyle Guidance, Research Summarization, and Medical Image Generation—MEDIBOT provides clinically relevant, context-aware, and ethically aligned responses.
Leveraging LangChain, FAISS, and Google Gemini LLMs, this system unifies retrieval-augmented generation (RAG), long-term memory management, and semantic evaluation to create a comprehensive and safe medical dialogue experience.
🩺 Medical-grade RAG pipeline with factual retrieval
🧠 Multi-agent orchestration (Diagnosis → Drug → Research → Lifestyle → Image)
🔍 Semantic evaluation for factual accuracy
⚕️ Strict domain filtration & safety enforcement
💡 Hybrid multimodal outputs (text + medical diagrams)
MEDIBOT is built on a layered, modular design that combines retrieval-based intelligence, domain-specific agent workflows, and memory-aware conversation control.
The system starts with a user query, which is first screened through a Medical Domain Filter. Based on the detected intent (e.g., symptoms, drugs, diet, research), the query is routed to the corresponding specialized agent. Each agent performs its own reasoning, retrieval, or generation task and returns a structured medical response.
At its core, the LangChain ConversationalRetrievalChain powers MEDIBOT’s reasoning loop, supported by:
FAISS Vector Store for semantic medical knowledge retrieval.
Google Gemini 2.0 Flash for controlled, evidence-based natural language generation.
ConversationBufferMemory and summary mechanisms for context retention.
| Agent 1 | Description | 
|---|---|
| Diagnosis Agent | Fetches PubMed abstracts, builds contextual FAISS vector stores, and generates possible diagnoses with reasoning and test recommendations. | 
| Drug Information Agent | Queries the OpenFDA API for accurate drug label data, dosage, contraindications, and safety warnings. | 
| BMI Agent | Computes body mass index from user input and classifies the category with tailored lifestyle advice. | 
| Lifestyle & Prevention Agent | Combines WGER API data with Gemini-driven reasoning to provide exercise, diet, and wellness plans. | 
| Medical Research Agent | Retrieves latest medical studies from Europe PMC and summarizes findings using LLM-based synthesis. | 
| Image Agent | Generates medical diagrams using Gemini 2.5 Image Model and Hugging Face Stable Diffusion XL as backup. | 
Performs symptom extraction using regex and heuristic matching.
Searches PubMed via E-utilities and fetches recent abstracts.
Creates an on-the-fly FAISS vector store for symptom-specific retrieval.
Generates differential diagnoses, suggested tests, and clinical reasoning.
Calls OpenFDA endpoints for official drug labeling data.
Displays indications, dosage, contraindications, and warnings.
Presents information in an easy-to-read, structured format.
Extracts height and weight values from text.
Calculates BMI and classifies user into WHO categories.
3, Returns actionable diet and health advice.
Uses Gemini to detect intent (exercise, diet, or mixed).
Fetches real exercises and food suggestions from WGER.
Generates motivating, structured wellness plans with emojis and personalization.
Retrieves top scientific articles from Europe PMC API.
Summarizes study highlights, authors, journals, and publication years.
Generates a readable summary or detailed synthesis based on query type.
Creates labeled medical diagrams via Gemini image generation.
Falls back to Stable Diffusion XL if Gemini API quota is exceeded.
Saves outputs with timestamps for reproducibility and visual education.
Conversation Memory: Tracks 5 most recent dialogue turns using LangChain’s ConversationBufferMemory.
Summary Memory: Compresses older chats into a brief context string for continuity.
Semantic Evaluation: Measures factual alignment between retrieved context and generated answers using cosine similarity on HuggingFace embeddings.
Non-Medical Filter: Blocks unrelated, political, or humorous inputs to maintain medical domain integrity.
| Component | Purpose | Key Features | 
|---|---|---|
| LangChain | Core orchestration | Conversation chains, memory, and prompt templates | 
| FAISS | Vector database | Fast semantic retrieval for medical documents | 
| Google Gemini | Text & image generation | Context-aware reasoning and multimodal outputs | 
| Hugging Face Models | Backup image generation | High-resolution medical illustrations | 
| OpenFDA / PubMed / Europe PMC APIs | Data sources | Verified, real-world medical datasets | 
| Rich Console + CSV Logging | UI & tracking | Colorized terminal output with semantic similarity logs | 
To help visualize how the system works internally, consider the following architecture diagram:

.png?Expires=1762225587&Key-Pair-Id=K2V2TN6YBJQHTG&Signature=Kv89CmS-l86Kr21wiE478kxrxX8LtwIMp905QGXh0ej4XZigJAbNiQNDP9J5VhXqHwzpNjwMwzQG7k5vJtUXt7aqifpDv4E1jk~tk71OoCuvqbMVZn9a6HvlPLkXd2mbEybz6rWcUFxFstbyiSA2tswCrsRi0QSoyKUYi9vZ7FSJGQsMGJRhwpwLWRYVtAvCaHOHpJX93KHtEA3bLrAp5M5cEZYOVaY5pP0mx8DLrm9ggzZ~8EBLxyss9I1PIiQvGHvjq9zfe6B6EK2meAXBUdymbYxeQHmkvQMBkG6gDLXriVUyAaIRG8uKzEHX~BRGbRbP8jqN4B-bdPzMolXUWg__)
User: “I have fever, sore throat, and body ache.”
Agent Activated: Diagnosis Agent
Output:
Possible Diagnoses: Influenza, Streptococcal Pharyngitis, Viral Infection
Recommended Tests: Throat swab, CBC, PCR
Reasoning: Based on symptom cluster, most likely viral etiology with supportive management.
Sources: PubMed abstracts from 2022–2024
.png?Expires=1762225587&Key-Pair-Id=K2V2TN6YBJQHTG&Signature=hlH87aJZpH-KlABqVreRm3~Cmhv1GD55NaJfq0BrZzD1obaNhoSvAXl-PGieAQ1ycE5eMpnx~r6svvT~7JzJsyojR7kw~pouum8Y4mredjahPSJqbnU9v6R7cS1BGWVp4gSYWT8-dId2bNvZ4n9DIp8CmT7BjUZ0JcXYqRv0tvrcHdzsTy6tD6RYHrgGxCsimNE7HFTP0IghFv8ogaGKZjwfRMIk9oeu1gHAapRV01vP8P~E2LotZ7aVm83ySgKhT9Dl6LHhbyFKnkx9GwmdvH9k2ZF6ftDSt2EGSi7FUvYL0hyihLVnjbBn1Ez7KQprrhplEBuN4vgsBMriAlIh5w__)
User: “Tell me about Insulin”
Agent Activated: Drug Info Agent
Output Summary:
Brand & Generic: Tylenol | Paracetamol
Indications: Fever, mild to moderate pain relief
Dosage: 500 mg every 6 hours (max 4g/day)
Contraindications: Liver disease, alcohol use
Source: FDA Drug Label Database
.png?Expires=1762225587&Key-Pair-Id=K2V2TN6YBJQHTG&Signature=FeH6Yutv0MnQI-I9kT8BSXGbCQ1OMoYEee4safajz1alA825F6WOyLnwP3q~Xoxrn0Q6SHSnnQSidTPfuicxvf6X4E1gDxAp8BEb4TiDNjA21RLOJ~sH1qJEooyFxENhjlVKM4yZKmiAdoQfCKs7CRKfJmwSHdHnZySS-N0jVrpwsZFjSGwwyT1LBc79CHTWNpseW-KrSExOiFTrFclC0NGu5Wb1FspmuhsIDjshtbj8zsx0Xkg5GIl1hgggvA2ruJfNmuMdP4E7iFc9i-SylDdt0L3rf-m-FIOHInydbl7BhPcyDZZbT4qXwdXOMawp3iZH5gjz7CU7S3LQ7n9zVg__)
Output (Image Generation Example)
User: “Generate a  diagram of the human heart.”
Agent Activated: Image Agent
Output:
Generated via Gemini 2.5 Flash Preview
Backup available via Stable Diffusion XL
Output saved under /images/20251103_153455/

| Metric | Description | Average Score | 
|---|---|---|
| Semantic Similarity | Alignment between RAG context & LLM answer | 0.91 | 
| Diagnosis Accuracy | Correct condition detection (manual evaluation) | 88% | 
| Drug Info Reliability | FDA-verified content accuracy | 94% | 
| Lifestyle Plan Relevance | Practical alignment with user goals | 90% | 
| Context Retention (10 turns) | Maintained continuity without drift | ✅ Stable | 
MEDIBOT represents a major advancement in domain-focused, explainable, and multimodal medical AI. Its agent-based architecture allows distinct reasoning modules to operate collaboratively—each focused on reliability, interpretability, and ethical AI alignment.
By integrating retrieval-augmented generation, semantic validation, and LLM reasoning, MEDIBOT achieves both factual robustness and contextual empathy. It can assist in medical education, patient support, and clinical decision pre-processing—all while maintaining strict data safety boundaries.
Future improvements will include voice-based conversational interfaces, multi-language support, and integration with EMR (Electronic Medical Records) for personalized insights.
This system demonstrates that responsible, modular AI can bring trustworthy, research-backed medical guidance to users worldwide.
✔️ Commercial & private use
✔️ Distribution & modification
✔️ Patent use
Permissions of this strong copyleft license are conditioned on making available complete source code of licensed works and modifications, which include larger works using a licensed work, under the same license. Copyright and license notices must be preserved. Contributors provide an express grant of patent rights.
A full license text is available in the accompanying LICENSE file.
When redistributing, please retain copyright
and attribution notices.
External LLMs and APIs (e.g., Google Gemini, Hugging Face, WGER, OpenFDA) are governed by their respective creators’ licenses.
Ensure compliance when integrating or extending third-party components.
| Asset | Link / Location | 
|---|---|
| Source Code | https://github.com/pamuarun/MEDIBOT-Multi-Agent-System/blob/main/agents1.py | 
| Example Outputs | medibot_logs.csv (chat logs with semantic evaluation) and images/ folder (AI-generated diagrams) | 
By orchestrating specialized medical AI agents with strict retrieval and safety mechanisms, MEDIBOT demonstrates that accurate, explainable, and privacy-aware healthcare chatbots can be achieved without relying solely on opaque cloud systems.
This framework can inspire healthcare developers, medical educators, and research institutions to adopt open, agentic AI architectures for clinical education and patient assistance—while maintaining transparency, safety, and reproducibility.