Spaces:
Running
on
Zero
Running
on
Zero
Y Phung Nguyen
commited on
Commit
Β·
32c6eaa
1
Parent(s):
c8562d7
Upd README
Browse files- .gitignore +0 -1
- README.md +38 -38
- sample.md +59 -0
.gitignore
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
.env
|
| 2 |
.setup.txt
|
| 3 |
__pycache__/
|
| 4 |
-
sample.txt
|
|
|
|
| 1 |
.env
|
| 2 |
.setup.txt
|
| 3 |
__pycache__/
|
|
|
README.md
CHANGED
|
@@ -18,6 +18,7 @@ tags:
|
|
| 18 |
|
| 19 |
[Demo](https://huggingface.co/spaces/MCP-1st-Birthday/MedLLM-Agent)
|
| 20 |
|
|
|
|
| 21 |
# π©Ί MedLLM Agent
|
| 22 |
|
| 23 |
**Advanced Medical AI Assistant** powered by fine-tuned MedSwin models with comprehensive knowledge retrieval capabilities.
|
|
@@ -31,6 +32,7 @@ tags:
|
|
| 31 |
- Mitigates hallucination by grounding responses in your documents
|
| 32 |
- Toggle RAG on/off - when disabled, provides concise clinical answers without document context
|
| 33 |
|
|
|
|
| 34 |
### π **Web Search Integration (MCP Protocol)**
|
| 35 |
- **Native MCP Support**: Uses Model Context Protocol (MCP) tools for web search and content extraction
|
| 36 |
- **Automatic Fallback**: Gracefully falls back to direct library calls if MCP is not configured
|
|
@@ -39,6 +41,7 @@ tags:
|
|
| 39 |
- **Automatic Summarization**: Summarizes web search results using Gemini MCP
|
| 40 |
- **Enriches Context**: Combines document RAG + web sources for comprehensive answers
|
| 41 |
|
|
|
|
| 42 |
### π§ **MedSwin Medical Specialist Models**
|
| 43 |
- **MedSwin TA** (default) - Task-Aware merged model
|
| 44 |
- **MedSwin SFT** - Supervised Fine-Tuned model
|
|
@@ -46,6 +49,7 @@ tags:
|
|
| 46 |
- Models download on-demand for efficient resource usage
|
| 47 |
- Fine-tuned on MedAlpaca-7B for medical domain expertise
|
| 48 |
|
|
|
|
| 49 |
### π **Multi-Language Support**
|
| 50 |
- Automatic language detection
|
| 51 |
- Non-English queries automatically translated to English
|
|
@@ -53,17 +57,21 @@ tags:
|
|
| 53 |
- Responses translated back to original language
|
| 54 |
- Powered by Gemini MCP for translation
|
| 55 |
|
|
|
|
| 56 |
### π§Ύ **Clinical Intake Q&A Breakdown**
|
| 57 |
- Gemini intake triage checks whether the userβs concern needs additional questioning (up to 5 follow-ups) and keeps per-session state.
|
| 58 |
- Intake agent conducts focused Q&A, then auto-summarizes the transcript into patient profile, refined problem statement, and key findings with actionable handoff notes.
|
| 59 |
- Pipeline injects both the structured insights and raw transcript back into the supervisor so downstream planning, RAG, and search stay grounded in what the patient actually said.
|
| 60 |
-
- Users can toggle the intake flow directly in the UI; disabling clears any pending follow-up state.
|
|
|
|
|
|
|
| 61 |
|
| 62 |
### π€ **Voice Features**
|
| 63 |
- **Speech-to-Text**: Voice input transcription using Gemini MCP
|
| 64 |
- **Inline Mic Experience**: Built-in microphone widget with live recording timer that drops transcripts straight into the chat box
|
| 65 |
- **Text-to-Speech**: Voice output generation using Maya1 TTS model (optional, fallback to MCP if unavailable) plus a one-click "Play Response" control for the latest answer
|
| 66 |
|
|
|
|
| 67 |
### π€ **MAC Architecture (Multi-Agent Collaboration)**
|
| 68 |
- **Gemini Supervisor**: Orchestrates query processing by breaking queries into flexible sub-topics (up to 10 based on complexity, explores different approaches)
|
| 69 |
- **MedSwin Specialist**: Executes tasks sequentially, providing concise clinical answers
|
|
@@ -76,11 +84,13 @@ tags:
|
|
| 76 |
- **Markdown Format**: Final answers use bullet points (tables automatically converted)
|
| 77 |
- **Deterministic Mode**: `Disable agentic reasoning` switch runs MedSwin alone for offline-friendly, model-only answers
|
| 78 |
|
|
|
|
| 79 |
### β‘ **Adaptive Strategy & Diagnostics**
|
| 80 |
- **Autonomous Planner**: Gemini reasoning now enables/disables RAG and web search dynamically per query while respecting user toggles.
|
| 81 |
- **Parallel Search Flow**: Multi-strategy web lookups run concurrently with cached MCP tool discovery and shared embeddings to cut latency.
|
| 82 |
- **Pipeline Telemetry**: Every session logs stage durations, strategy decisions, and search outcomes for fast troubleshooting and quality tracking.
|
| 83 |
|
|
|
|
| 84 |
### βοΈ **Advanced Configuration**
|
| 85 |
- Customizable generation parameters (temperature, top-p, top-k)
|
| 86 |
- Adjustable retrieval settings (top-k, merge threshold)
|
|
@@ -89,6 +99,7 @@ tags:
|
|
| 89 |
- Dynamic system prompts based on RAG status
|
| 90 |
- One-click agentic toggle to run MedSwin alone (no RAG/web search) for deterministic, offline-safe answers
|
| 91 |
|
|
|
|
| 92 |
## π Usage
|
| 93 |
|
| 94 |
1. **Upload Documents**: Drag and drop PDF, Word, or text files containing medical information
|
|
@@ -102,6 +113,7 @@ tags:
|
|
| 102 |
- Web sources (if web search enabled)
|
| 103 |
- Medical model's training knowledge
|
| 104 |
|
|
|
|
| 105 |
## π§ Technical Details
|
| 106 |
|
| 107 |
- **Medical Models**: MedSwin/MedSwin-7B-SFT, MedSwin-7B-KD, MedSwin-Merged-TA-SFT-0.7
|
|
@@ -117,6 +129,7 @@ tags:
|
|
| 117 |
- **Web Search**: MCP tools with automatic fallback to DuckDuckGo
|
| 118 |
- **MCP Server**: Bundled Python-based Gemini MCP server (agent.py)
|
| 119 |
|
|
|
|
| 120 |
## π Requirements
|
| 121 |
|
| 122 |
See `requirements.txt` for full dependency list. Key dependencies:
|
|
@@ -127,27 +140,24 @@ See `requirements.txt` for full dependency list. Key dependencies:
|
|
| 127 |
- **Utilities**: `langdetect`, `gradio`, `spaces`, `soundfile`
|
| 128 |
- **TTS**: Optional - `TTS` package (voice features work with MCP fallback if unavailable)
|
| 129 |
|
| 130 |
-
### π MCP Configuration
|
| 131 |
|
|
|
|
| 132 |
The application uses a bundled Gemini MCP server (agent.py) for translation, document parsing, transcription, and summarization. Configure via environment variables
|
| 133 |
|
| 134 |
**Setup Steps:**
|
| 135 |
-
|
| 136 |
1. **Install Dependencies** (already in requirements.txt):
|
| 137 |
```bash
|
| 138 |
pip install mcp nest-asyncio google-genai
|
| 139 |
-
```
|
| 140 |
-
|
| 141 |
2. **Get Gemini API Key**:
|
| 142 |
- Visit [Google AI Studio](https://aistudio.google.com/) to get your API key
|
| 143 |
-
- Set it: `export GEMINI_API_KEY="your-api-key"`
|
| 144 |
-
|
| 145 |
3. **Run the Application**:
|
| 146 |
- The bundled MCP server (agent.py) will be used automatically
|
| 147 |
-
- No additional MCP server installation required
|
| 148 |
-
|
| 149 |
**Note**: The application requires Gemini MCP for translation, document parsing, transcription, and summarization. Web search supports fallback to direct DuckDuckGo API if MCP web search tools are unavailable.
|
| 150 |
|
|
|
|
| 151 |
## π― Use Cases
|
| 152 |
|
| 153 |
- **Clinical Decision Support**: Evidence-based answers from documents and current medical literature
|
|
@@ -156,14 +166,13 @@ The application uses a bundled Gemini MCP server (agent.py) for translation, doc
|
|
| 156 |
- **Research Assistance**: Synthesize information from multiple medical sources
|
| 157 |
- **Drug Information**: Comprehensive drug information with interaction analysis
|
| 158 |
|
| 159 |
-
## π₯ Enterprise-Level Clinical Decision Support
|
| 160 |
|
| 161 |
-
|
| 162 |
|
|
|
|
| 163 |
MedLLM Agent is designed to support **doctors, clinicians, and medical specialists** in making informed clinical decisions by leveraging the power of Large Language Models (LLMs) and Model Context Protocol (MCP). This system transforms how medical professionals access, analyze, and synthesize medical information in real-time.
|
| 164 |
|
| 165 |
-
### **Key Enterprise Capabilities**
|
| 166 |
-
|
| 167 |
#### 1. **MAC Architecture (Multi-Agent Collaboration)**
|
| 168 |
- **Gemini Supervisor Agent**:
|
| 169 |
- Breaks user queries into flexible sub-topics (up to 10 based on complexity, explores different approaches/angles)
|
|
@@ -172,8 +181,7 @@ MedLLM Agent is designed to support **doctors, clinicians, and medical specialis
|
|
| 172 |
- In search mode: creates 1-4 search strategies, executes ddgs (1-2 sources each), summarizes briefly
|
| 173 |
- Conditional search trigger: Can trigger additional searches if answer is unclear or has gaps (only when search mode enabled)
|
| 174 |
- In RAG mode: brainstorms retrieved documents into 1-4 concise contexts
|
| 175 |
-
- All supervisor decisions logged internally, not displayed
|
| 176 |
-
|
| 177 |
- **MedSwin Specialist Agent**:
|
| 178 |
- Executes tasks assigned by Gemini Supervisor (GPU-tagged)
|
| 179 |
- Processes each sub-topic sequentially with focused context
|
|
@@ -184,20 +192,18 @@ MedLLM Agent is designed to support **doctors, clinicians, and medical specialis
|
|
| 184 |
- **Internal Thoughts Hidden**: All Gemini-MedSwin conversations logged only
|
| 185 |
- **Final Answer Only**: Users see only the polished, final answer
|
| 186 |
- **Structured Output**: Markdown bullets, no internal planning tables
|
| 187 |
-
- **Efficient Processing**: Contexts kept brief to respect token limits
|
| 188 |
|
| 189 |
-
### **Enterprise Use Cases for Medical Specialists**
|
| 190 |
|
| 191 |
-
|
| 192 |
-
- **Diagnostic Assistance**: Upload patient records, lab results, and medical histories. Ask complex diagnostic questions and receive evidence-based answers grounded in your documents and current medical literature.
|
| 193 |
-
|
| 194 |
-
- **Treatment Planning**: Query treatment protocols, drug interactions, and therapeutic guidelines. The system autonomously retrieves relevant information from your clinical documents and current medical databases.
|
| 195 |
|
|
|
|
|
|
|
|
|
|
| 196 |
- **Drug Information & Interactions**: Get comprehensive drug information, contraindications, and interaction analyses by combining your formulary documents with up-to-date web sources.
|
| 197 |
|
| 198 |
#### **Research & Evidence Synthesis**
|
| 199 |
-
- **Literature Review Support**: Upload research papers, clinical trials, and medical literature. The system helps synthesize findings, identify connections, and answer research questions.
|
| 200 |
-
|
| 201 |
- **Clinical Guideline Analysis**: Compare and analyze multiple clinical guidelines, protocols, and best practices from your document library.
|
| 202 |
|
| 203 |
#### **Multi-Language Clinical Support**
|
|
@@ -211,53 +217,47 @@ MedLLM Agent is designed to support **doctors, clinicians, and medical specialis
|
|
| 211 |
- Current medical guidelines
|
| 212 |
- **MCP Protocol Benefits**: Standardized, modular tool integration allows easy switching between search providers and enhanced reliability
|
| 213 |
|
| 214 |
-
### **How It Works: MAC Architecture in Action**
|
| 215 |
|
|
|
|
| 216 |
1. **Gemini Supervisor - Query Breakdown** β Analyzes query and breaks into flexible sub-topics (up to 10 based on complexity):
|
| 217 |
- Example: "What are the treatment options for Type 2 diabetes in elderly patients with renal impairment?"
|
| 218 |
- Explores different approaches (clinical, diagnostic, treatment, prevention perspectives)
|
| 219 |
- Creates structured sub-topics: treatment options, age considerations, renal function impact, drug interactions, monitoring protocols
|
| 220 |
- Number of subtasks adapts to query complexity (not limited to 4)
|
| 221 |
-
- All planning logged internally, not displayed to user
|
| 222 |
-
|
| 223 |
2. **Gemini Supervisor - Context Preparation**:
|
| 224 |
- **Search Mode**: Creates 1-4 search strategies β executes ddgs (1-2 sources each) β summarizes briefly
|
| 225 |
- **RAG Mode**: Retrieves documents β brainstorms into 1-4 concise contexts for MedSwin
|
| 226 |
-
- Contexts kept brief to respect MedSwin token limits
|
| 227 |
-
|
| 228 |
3. **MedSwin Specialist - Task Execution** (GPU-tagged):
|
| 229 |
- Executes each sub-topic task sequentially
|
| 230 |
- Receives focused context from Gemini Supervisor
|
| 231 |
- Generates concise clinical answers (Markdown bullets, no tables)
|
| 232 |
-
- All execution logged internally
|
| 233 |
-
|
| 234 |
4. **Gemini Supervisor - Answer Synthesis**:
|
| 235 |
- Synthesizes all MedSwin responses with clear context
|
| 236 |
- Integrates information from all sub-topics seamlessly
|
| 237 |
- Creates coherent, comprehensive final answer
|
| 238 |
-
- Provides better context than simple concatenation
|
| 239 |
-
|
| 240 |
5. **Gemini Supervisor - Challenge & Enhancement Loop**:
|
| 241 |
- Evaluates answer quality (completeness, accuracy, clarity)
|
| 242 |
- Challenges answer if not optimal
|
| 243 |
- Provides specific enhancement instructions
|
| 244 |
- Enhances answer iteratively (up to 2 iterations)
|
| 245 |
-
- Continues until answer confirmed optimal
|
| 246 |
-
|
| 247 |
6. **Conditional Search Trigger** (only when search mode enabled):
|
| 248 |
- Supervisor checks if answer is unclear or has gaps
|
| 249 |
- If needed, generates specific search queries to fill gaps
|
| 250 |
- Executes additional searches
|
| 251 |
-
- Enhances answer with new search context
|
| 252 |
-
|
| 253 |
7. **Final Answer Assembly**:
|
| 254 |
- Converts any tables to Markdown bullets
|
| 255 |
- Adds citations if web sources used
|
| 256 |
- Translates back if needed
|
| 257 |
- **Only final answer displayed** - all internal thoughts remain in logs
|
| 258 |
|
| 259 |
-
### **Enterprise Benefits**
|
| 260 |
|
|
|
|
| 261 |
β
**Time Efficiency**: Reduces time spent searching through documents and medical databases
|
| 262 |
β
**Evidence-Based Decisions**: Grounds answers in uploaded documents and current medical literature
|
| 263 |
β
**Reduced Hallucination**: RAG ensures answers are based on actual documents and verified sources
|
|
@@ -270,8 +270,8 @@ MedLLM Agent is designed to support **doctors, clinicians, and medical specialis
|
|
| 270 |
β
**Clinical Workflow Integration**: Designed to fit into existing clinical decision-making processes
|
| 271 |
β
**MCP Protocol**: Standardized tool integration for reliable, maintainable web search capabilities
|
| 272 |
|
| 273 |
-
### **Implementation in Clinical Settings**
|
| 274 |
|
|
|
|
| 275 |
- **Hospital Systems**: Clinical decision support with EMR integration and institutional medical libraries
|
| 276 |
- **Specialty Clinics**: Customize with specialty-specific documents and guidelines
|
| 277 |
- **Medical Education**: Comprehensive, evidence-based answers for training and education
|
|
|
|
| 18 |
|
| 19 |
[Demo](https://huggingface.co/spaces/MCP-1st-Birthday/MedLLM-Agent)
|
| 20 |
|
| 21 |
+
|
| 22 |
# π©Ί MedLLM Agent
|
| 23 |
|
| 24 |
**Advanced Medical AI Assistant** powered by fine-tuned MedSwin models with comprehensive knowledge retrieval capabilities.
|
|
|
|
| 32 |
- Mitigates hallucination by grounding responses in your documents
|
| 33 |
- Toggle RAG on/off - when disabled, provides concise clinical answers without document context
|
| 34 |
|
| 35 |
+
|
| 36 |
### π **Web Search Integration (MCP Protocol)**
|
| 37 |
- **Native MCP Support**: Uses Model Context Protocol (MCP) tools for web search and content extraction
|
| 38 |
- **Automatic Fallback**: Gracefully falls back to direct library calls if MCP is not configured
|
|
|
|
| 41 |
- **Automatic Summarization**: Summarizes web search results using Gemini MCP
|
| 42 |
- **Enriches Context**: Combines document RAG + web sources for comprehensive answers
|
| 43 |
|
| 44 |
+
|
| 45 |
### π§ **MedSwin Medical Specialist Models**
|
| 46 |
- **MedSwin TA** (default) - Task-Aware merged model
|
| 47 |
- **MedSwin SFT** - Supervised Fine-Tuned model
|
|
|
|
| 49 |
- Models download on-demand for efficient resource usage
|
| 50 |
- Fine-tuned on MedAlpaca-7B for medical domain expertise
|
| 51 |
|
| 52 |
+
|
| 53 |
### π **Multi-Language Support**
|
| 54 |
- Automatic language detection
|
| 55 |
- Non-English queries automatically translated to English
|
|
|
|
| 57 |
- Responses translated back to original language
|
| 58 |
- Powered by Gemini MCP for translation
|
| 59 |
|
| 60 |
+
|
| 61 |
### π§Ύ **Clinical Intake Q&A Breakdown**
|
| 62 |
- Gemini intake triage checks whether the userβs concern needs additional questioning (up to 5 follow-ups) and keeps per-session state.
|
| 63 |
- Intake agent conducts focused Q&A, then auto-summarizes the transcript into patient profile, refined problem statement, and key findings with actionable handoff notes.
|
| 64 |
- Pipeline injects both the structured insights and raw transcript back into the supervisor so downstream planning, RAG, and search stay grounded in what the patient actually said.
|
| 65 |
+
- Users can toggle the intake flow directly in the UI; disabling clears any pending follow-up state.
|
| 66 |
+
|
| 67 |
+
Sample [conversation](sample.md) between MAC-system and patient are recorded.
|
| 68 |
|
| 69 |
### π€ **Voice Features**
|
| 70 |
- **Speech-to-Text**: Voice input transcription using Gemini MCP
|
| 71 |
- **Inline Mic Experience**: Built-in microphone widget with live recording timer that drops transcripts straight into the chat box
|
| 72 |
- **Text-to-Speech**: Voice output generation using Maya1 TTS model (optional, fallback to MCP if unavailable) plus a one-click "Play Response" control for the latest answer
|
| 73 |
|
| 74 |
+
|
| 75 |
### π€ **MAC Architecture (Multi-Agent Collaboration)**
|
| 76 |
- **Gemini Supervisor**: Orchestrates query processing by breaking queries into flexible sub-topics (up to 10 based on complexity, explores different approaches)
|
| 77 |
- **MedSwin Specialist**: Executes tasks sequentially, providing concise clinical answers
|
|
|
|
| 84 |
- **Markdown Format**: Final answers use bullet points (tables automatically converted)
|
| 85 |
- **Deterministic Mode**: `Disable agentic reasoning` switch runs MedSwin alone for offline-friendly, model-only answers
|
| 86 |
|
| 87 |
+
|
| 88 |
### β‘ **Adaptive Strategy & Diagnostics**
|
| 89 |
- **Autonomous Planner**: Gemini reasoning now enables/disables RAG and web search dynamically per query while respecting user toggles.
|
| 90 |
- **Parallel Search Flow**: Multi-strategy web lookups run concurrently with cached MCP tool discovery and shared embeddings to cut latency.
|
| 91 |
- **Pipeline Telemetry**: Every session logs stage durations, strategy decisions, and search outcomes for fast troubleshooting and quality tracking.
|
| 92 |
|
| 93 |
+
|
| 94 |
### βοΈ **Advanced Configuration**
|
| 95 |
- Customizable generation parameters (temperature, top-p, top-k)
|
| 96 |
- Adjustable retrieval settings (top-k, merge threshold)
|
|
|
|
| 99 |
- Dynamic system prompts based on RAG status
|
| 100 |
- One-click agentic toggle to run MedSwin alone (no RAG/web search) for deterministic, offline-safe answers
|
| 101 |
|
| 102 |
+
|
| 103 |
## π Usage
|
| 104 |
|
| 105 |
1. **Upload Documents**: Drag and drop PDF, Word, or text files containing medical information
|
|
|
|
| 113 |
- Web sources (if web search enabled)
|
| 114 |
- Medical model's training knowledge
|
| 115 |
|
| 116 |
+
|
| 117 |
## π§ Technical Details
|
| 118 |
|
| 119 |
- **Medical Models**: MedSwin/MedSwin-7B-SFT, MedSwin-7B-KD, MedSwin-Merged-TA-SFT-0.7
|
|
|
|
| 129 |
- **Web Search**: MCP tools with automatic fallback to DuckDuckGo
|
| 130 |
- **MCP Server**: Bundled Python-based Gemini MCP server (agent.py)
|
| 131 |
|
| 132 |
+
|
| 133 |
## π Requirements
|
| 134 |
|
| 135 |
See `requirements.txt` for full dependency list. Key dependencies:
|
|
|
|
| 140 |
- **Utilities**: `langdetect`, `gradio`, `spaces`, `soundfile`
|
| 141 |
- **TTS**: Optional - `TTS` package (voice features work with MCP fallback if unavailable)
|
| 142 |
|
|
|
|
| 143 |
|
| 144 |
+
### π MCP Configuration
|
| 145 |
The application uses a bundled Gemini MCP server (agent.py) for translation, document parsing, transcription, and summarization. Configure via environment variables
|
| 146 |
|
| 147 |
**Setup Steps:**
|
|
|
|
| 148 |
1. **Install Dependencies** (already in requirements.txt):
|
| 149 |
```bash
|
| 150 |
pip install mcp nest-asyncio google-genai
|
| 151 |
+
```
|
|
|
|
| 152 |
2. **Get Gemini API Key**:
|
| 153 |
- Visit [Google AI Studio](https://aistudio.google.com/) to get your API key
|
| 154 |
+
- Set it: `export GEMINI_API_KEY="your-api-key"`
|
|
|
|
| 155 |
3. **Run the Application**:
|
| 156 |
- The bundled MCP server (agent.py) will be used automatically
|
| 157 |
+
- No additional MCP server installation required
|
|
|
|
| 158 |
**Note**: The application requires Gemini MCP for translation, document parsing, transcription, and summarization. Web search supports fallback to direct DuckDuckGo API if MCP web search tools are unavailable.
|
| 159 |
|
| 160 |
+
|
| 161 |
## π― Use Cases
|
| 162 |
|
| 163 |
- **Clinical Decision Support**: Evidence-based answers from documents and current medical literature
|
|
|
|
| 166 |
- **Research Assistance**: Synthesize information from multiple medical sources
|
| 167 |
- **Drug Information**: Comprehensive drug information with interaction analysis
|
| 168 |
|
|
|
|
| 169 |
|
| 170 |
+
## π₯ Enterprise-Level Clinical Decision Support
|
| 171 |
|
| 172 |
+
### **Empowering Medical Specialists with AI-Powered Decision Support**
|
| 173 |
MedLLM Agent is designed to support **doctors, clinicians, and medical specialists** in making informed clinical decisions by leveraging the power of Large Language Models (LLMs) and Model Context Protocol (MCP). This system transforms how medical professionals access, analyze, and synthesize medical information in real-time.
|
| 174 |
|
| 175 |
+
### **Key Enterprise Capabilities**
|
|
|
|
| 176 |
#### 1. **MAC Architecture (Multi-Agent Collaboration)**
|
| 177 |
- **Gemini Supervisor Agent**:
|
| 178 |
- Breaks user queries into flexible sub-topics (up to 10 based on complexity, explores different approaches/angles)
|
|
|
|
| 181 |
- In search mode: creates 1-4 search strategies, executes ddgs (1-2 sources each), summarizes briefly
|
| 182 |
- Conditional search trigger: Can trigger additional searches if answer is unclear or has gaps (only when search mode enabled)
|
| 183 |
- In RAG mode: brainstorms retrieved documents into 1-4 concise contexts
|
| 184 |
+
- All supervisor decisions logged internally, not displayed
|
|
|
|
| 185 |
- **MedSwin Specialist Agent**:
|
| 186 |
- Executes tasks assigned by Gemini Supervisor (GPU-tagged)
|
| 187 |
- Processes each sub-topic sequentially with focused context
|
|
|
|
| 192 |
- **Internal Thoughts Hidden**: All Gemini-MedSwin conversations logged only
|
| 193 |
- **Final Answer Only**: Users see only the polished, final answer
|
| 194 |
- **Structured Output**: Markdown bullets, no internal planning tables
|
| 195 |
+
- **Efficient Processing**: Contexts kept brief to respect token limits
|
| 196 |
|
|
|
|
| 197 |
|
| 198 |
+
### **Enterprise Use Cases for Medical Specialists**
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
+
#### **Clinical Decision Support**
|
| 201 |
+
- **Diagnostic Assistance**: Upload patient records, lab results, and medical histories. Ask complex diagnostic questions and receive evidence-based answers grounded in your documents and current medical literature.
|
| 202 |
+
- **Treatment Planning**: Query treatment protocols, drug interactions, and therapeutic guidelines. The system autonomously retrieves relevant information from your clinical documents and current medical databases.
|
| 203 |
- **Drug Information & Interactions**: Get comprehensive drug information, contraindications, and interaction analyses by combining your formulary documents with up-to-date web sources.
|
| 204 |
|
| 205 |
#### **Research & Evidence Synthesis**
|
| 206 |
+
- **Literature Review Support**: Upload research papers, clinical trials, and medical literature. The system helps synthesize findings, identify connections, and answer research questions.
|
|
|
|
| 207 |
- **Clinical Guideline Analysis**: Compare and analyze multiple clinical guidelines, protocols, and best practices from your document library.
|
| 208 |
|
| 209 |
#### **Multi-Language Clinical Support**
|
|
|
|
| 217 |
- Current medical guidelines
|
| 218 |
- **MCP Protocol Benefits**: Standardized, modular tool integration allows easy switching between search providers and enhanced reliability
|
| 219 |
|
|
|
|
| 220 |
|
| 221 |
+
### **How It Works: MAC Architecture in Action**
|
| 222 |
1. **Gemini Supervisor - Query Breakdown** β Analyzes query and breaks into flexible sub-topics (up to 10 based on complexity):
|
| 223 |
- Example: "What are the treatment options for Type 2 diabetes in elderly patients with renal impairment?"
|
| 224 |
- Explores different approaches (clinical, diagnostic, treatment, prevention perspectives)
|
| 225 |
- Creates structured sub-topics: treatment options, age considerations, renal function impact, drug interactions, monitoring protocols
|
| 226 |
- Number of subtasks adapts to query complexity (not limited to 4)
|
| 227 |
+
- All planning logged internally, not displayed to user
|
|
|
|
| 228 |
2. **Gemini Supervisor - Context Preparation**:
|
| 229 |
- **Search Mode**: Creates 1-4 search strategies β executes ddgs (1-2 sources each) β summarizes briefly
|
| 230 |
- **RAG Mode**: Retrieves documents β brainstorms into 1-4 concise contexts for MedSwin
|
| 231 |
+
- Contexts kept brief to respect MedSwin token limits
|
|
|
|
| 232 |
3. **MedSwin Specialist - Task Execution** (GPU-tagged):
|
| 233 |
- Executes each sub-topic task sequentially
|
| 234 |
- Receives focused context from Gemini Supervisor
|
| 235 |
- Generates concise clinical answers (Markdown bullets, no tables)
|
| 236 |
+
- All execution logged internally
|
|
|
|
| 237 |
4. **Gemini Supervisor - Answer Synthesis**:
|
| 238 |
- Synthesizes all MedSwin responses with clear context
|
| 239 |
- Integrates information from all sub-topics seamlessly
|
| 240 |
- Creates coherent, comprehensive final answer
|
| 241 |
+
- Provides better context than simple concatenation
|
|
|
|
| 242 |
5. **Gemini Supervisor - Challenge & Enhancement Loop**:
|
| 243 |
- Evaluates answer quality (completeness, accuracy, clarity)
|
| 244 |
- Challenges answer if not optimal
|
| 245 |
- Provides specific enhancement instructions
|
| 246 |
- Enhances answer iteratively (up to 2 iterations)
|
| 247 |
+
- Continues until answer confirmed optimal
|
|
|
|
| 248 |
6. **Conditional Search Trigger** (only when search mode enabled):
|
| 249 |
- Supervisor checks if answer is unclear or has gaps
|
| 250 |
- If needed, generates specific search queries to fill gaps
|
| 251 |
- Executes additional searches
|
| 252 |
+
- Enhances answer with new search context
|
|
|
|
| 253 |
7. **Final Answer Assembly**:
|
| 254 |
- Converts any tables to Markdown bullets
|
| 255 |
- Adds citations if web sources used
|
| 256 |
- Translates back if needed
|
| 257 |
- **Only final answer displayed** - all internal thoughts remain in logs
|
| 258 |
|
|
|
|
| 259 |
|
| 260 |
+
### **Enterprise Benefits**
|
| 261 |
β
**Time Efficiency**: Reduces time spent searching through documents and medical databases
|
| 262 |
β
**Evidence-Based Decisions**: Grounds answers in uploaded documents and current medical literature
|
| 263 |
β
**Reduced Hallucination**: RAG ensures answers are based on actual documents and verified sources
|
|
|
|
| 270 |
β
**Clinical Workflow Integration**: Designed to fit into existing clinical decision-making processes
|
| 271 |
β
**MCP Protocol**: Standardized tool integration for reliable, maintainable web search capabilities
|
| 272 |
|
|
|
|
| 273 |
|
| 274 |
+
### **Implementation in Clinical Settings**
|
| 275 |
- **Hospital Systems**: Clinical decision support with EMR integration and institutional medical libraries
|
| 276 |
- **Specialty Clinics**: Customize with specialty-specific documents and guidelines
|
| 277 |
- **Medical Education**: Comprehensive, evidence-based answers for training and education
|
sample.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# A Sample MAC-system conversation to the patient in Chronic Migraine topic
|
| 2 |
+
|
| 3 |
+
**Patient:** Provide strategic treatment plan for a longterm chronic migraine patient
|
| 4 |
+
|
| 5 |
+
**Model:** How often do you experience migraines, and how long do they typically last?
|
| 6 |
+
**Patient:** I have it usually like once per month, they sharply last about half an hour but could repetitively occurs multiple time in the next 5-6 days
|
| 7 |
+
|
| 8 |
+
**Model:** Can you describe the pain? For example, is it throbbing, sharp, dull, or a pressure sensation?
|
| 9 |
+
**Patient:** Like stabbing pain, especially in one hemisphere or the frontal globe, near eyes part
|
| 10 |
+
|
| 11 |
+
**Model:** On a scale of 0 to 10, with 10 being the worst pain imaginable, how severe is this stabbing pain when it occurs?
|
| 12 |
+
**Patient:** I would say around 4-7 differed by occasions
|
| 13 |
+
|
| 14 |
+
**Model:** Are there any specific triggers you've noticed that seem to bring on your migraines, such as certain foods, stress, or environmental factors?
|
| 15 |
+
**Patient:** I'm not sure but typically it could be cold weather or overwhelming work habit
|
| 16 |
+
|
| 17 |
+
**Model:** Have you experienced any other symptoms along with the stabbing pain, such as nausea, vomiting, sensitivity to light or sound, or visual disturbances like flashing lights or blind spots?
|
| 18 |
+
**Patient:** We have all of that like nausea, vomiting, sensitivity to light, and blind spots
|
| 19 |
+
|
| 20 |
+
**Model:** When these symptoms like nausea, vomiting, sensitivity to light, and blind spots occur, do they happen at the same time as the stabbing pain, or at a different time?
|
| 21 |
+
**Patient:** Those pain only occurs in peak/climax migraine, last for like 10 mins, not necessarily the same time
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
# Final Answer:
|
| 26 |
+
## **Characterization of Paroxysmal Migraine Pain**
|
| 27 |
+
Brief, intense, paroxysmal pain phenomena such as flashes of light, zigzag lines, blind spots, or temporary vision loss typically lasting about 5-20 seconds may occur during the peak/climax phase of a migraine attack. These are often described by patients as "auras" but do not involve hallucinations. The exact cause of these symptoms remains unknown, although they may be related to changes in blood flow or neurotransmitter activity within the brain. Treatment options include medication and lifestyle modifications.
|
| 28 |
+
|
| 29 |
+
## **Nomenclature and Classification**
|
| 30 |
+
Brief, intense "thunderclap" headaches that occur at the peak of a migraine are known as "migralepsy". These headaches can be differentiated from other headache types by their duration (<15 minutes), intensity (maximal), and temporal relationship to the migraine attack itself. Migralepsy may also present with autonomic symptoms such as nausea/vomiting, photophobia, phonophobia, and sweating. While not common, it's important for healthcare providers to recognize this subtype of migraine in order to optimize treatment strategies and prevent potential complications.
|
| 31 |
+
|
| 32 |
+
## **Differential Diagnosis and Related Conditions**
|
| 33 |
+
The following are some of the differential diagnosis for short duration, intense pain during peak migraine:
|
| 34 |
+
|
| 35 |
+
1) Primary Stabbing Headache (Ice Pick Headache) - Characterized by sudden, sharp, stabbing pains that lasts less than one minute, often triggered by physical activity such as chewing or talking. It may be associated with nausea/vomiting and sensitivity to light/sound.
|
| 36 |
+
|
| 37 |
+
2) Trigeminal Neuralgia - Pain along the path of the trigeminal nerve, usually unilateral, severe in intensity, spontaneous, shooting, electric shock-like quality. May occur at rest.
|
| 38 |
+
|
| 39 |
+
3) Other Paroxysmal Cranial Nervagias - Includes cluster headaches, hemicrania continua, paroxysmal hemicranias, etc., which present similarly but have different etiologies.
|
| 40 |
+
|
| 41 |
+
4) Migraine without Aura - Classic migraines can also present with similar symptoms if they are severe enough.
|
| 42 |
+
|
| 43 |
+
5) Temporomandibular Joint Disease - Can cause referred facial pain mimicking migraine.
|
| 44 |
+
|
| 45 |
+
6) Orofacial Pain Syndrome - General term encompassing various types of chronic facial pain not related to dentistry.
|
| 46 |
+
|
| 47 |
+
7) Sinusitis / Otitis Media - Considered if there's recent history of sinus congestion or ear infection.
|
| 48 |
+
|
| 49 |
+
8) Brain Tumor - Rarely presents with this type of pain, but should always be considered in patients over age 50 who develop new-onset headache.
|
| 50 |
+
|
| 51 |
+
9) Medication Overuse Headache - If patient has been taking frequent medications for migraine prophylaxis.
|
| 52 |
+
|
| 53 |
+
10) Psychogenic Non-Epileptic Seizures - Patients describe their attacks as "feeling like an electrical storm" in the brain.
|
| 54 |
+
|
| 55 |
+
## **Pathophysiological Mechanisms**
|
| 56 |
+
The exact mechanism underlying the precipitation of severe headache in migraines remains unclear; however, several theories have been proposed. One theory suggests that migraine attacks are triggered by abnormalities in serotonergic signaling within the trigeminal nerve nucleus caudalis (Vc). Serotonin receptors located here can be activated by vasoactive peptides released from sensory neurons innervating blood vessels supplying the brain. This activation leads to vasodilation and increased release of inflammatory mediators such as prostaglandins and bradykinin, which cause pain and other symptoms characteristic of a migraine. Another hypothesis proposes that cortical spread depression (CSD) plays an important role in triggering migraine attacks. CSD refers to transient electrical silence between adjacent regions of the cortex due to reduced Na+ conductance, leading to depolarization blockade and subsequent spread of action potentials. It has been shown that CSD occurs more frequently in patients with migraine compared to healthy controls, suggesting it might contribute to the initiation of migraine episodes. Other factors involved in migraine include genetic predisposition, environmental triggers, and changes in autonomic nervous system activity. Further research is needed to fully elucidate the complex interplay among these different mechanisms.
|
| 57 |
+
|
| 58 |
+
## **Acute and Preventive Management Strategies**
|
| 59 |
+
Acute treatment options for migraines include NSAIDs or triptans. Preventative treatments may involve daily medications like topiramate or amitriptyline, or more targeted therapies such as CGRP monoclonal antibodies. It's important to note that individual patient factors should be considered before starting any new medication.
|