File size: 4,843 Bytes
3973c7a 19d6abb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | ---
title: Multi-Agent AI Health System
emoji: π₯
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
license: mit
---
# PRESAGE: Multi-Agent AI Health Prediction System
A sophisticated medical AI system that uses multiple specialized agents to analyze patient health data and generate personalized 90-day prevention plans.
## π Quick Start
### Option 1: Automated Startup (Recommended)
**Windows (Batch):**
```bash
start-presage.bat
```
**Windows (PowerShell):**
```powershell
.\start-presage.ps1
```
### Option 2: Manual Startup
**Terminal 1 - Start API Backend:**
```bash
uvicorn api.main:app --reload --host 127.0.0.1 --port 8000
```
**Terminal 2 - Start React Frontend:**
```bash
cd client
npm install
npm run dev
```
The system will be available at:
- **React UI**: http://localhost:3000
- **API Backend**: http://127.0.0.1:8000
- **API Docs**: http://127.0.0.1:8000/docs
## π Project Structure
```
presage/
βββ core/ # Core modules
β βββ llm.py # Groq LLM integration
β βββ patient.py # Patient data models
β βββ vector_store.py # ChromaDB vector store
β
βββ agents/ # Specialized agents
β βββ data_agent.py # Data validation & flagging
β βββ risk_agent.py # ML-based risk assessment
β βββ literature_agent.py # PubMed literature search
β βββ intervention_agent.py # 90-day plan generation
β βββ orchestrator.py # Pipeline coordinator
β
βββ api/ # FastAPI backend
β βββ main.py # REST API endpoints
β
βββ client/ # React (Next.js) frontend
β βββ ... # Next.js project structure
β
βββ data/ # Data storage
β βββ risk_models/ # Pre-trained ML models
β
βββ .env # Environment variables (API keys)
βββ requirements.txt # Python dependencies
βββ README.md # This file
```
## π§ Configuration
### Environment Variables
Create or update `.env` file in the root directory:
```
GROQ_API_KEY=your_api_key_here
```
Get your API key from: https://console.groq.com
## π¨ Troubleshooting
### Timeout Error: "Read timed out (read timeout=45/120)"
**Cause:** API server isn't running or is processing too slowly
**Solution:**
1. Make sure API server is running: `uvicorn api.main:app --reload`
2. Check API health: `curl http://127.0.0.1:8000/health`
3. Check terminal logs for errors
4. Increase timeout in the API client if needed
### Connection Error: "Cannot connect to API server"
**Solution:**
- Ensure FastAPI is running on port 8000
- Check if port 8000 is already in use: `netstat -ano | findstr :8000`
- Try a different port: `uvicorn api.main:app --port 8001`
### Import Errors
**Solution:**
```bash
pip install -r requirements.txt
```
### Groq API Key Error
**Solution:**
1. Verify `.env` file exists in root directory
2. Check that `GROQ_API_KEY=...` is correct
3. Generate a new key at https://console.groq.com
## π Pipeline Overview
The PRESAGE system operates through a coordinated multi-agent pipeline:
1. **Data Agent** β Validates patient metrics and flags abnormalities
2. **Risk Agent** β Predicts disease risk percentages using ML models
3. **Literature Agent** β Searches PubMed for evidence-based interventions
4. **Intervention Agent** β Synthesizes findings into a 90-day plan
5. **Orchestrator** β Coordinates parallel execution and aggregates results
## π Security
- API keys are stored in `.env` (never commit to Git)
- `.gitignore` prevents accidental exposure
- No sensitive data is logged
- CORS enabled for frontend-backend communication
## π¦ Dependencies
- **groq**: LLM API client
- **fastapi**: Backend framework
- **Next.js/React**: Frontend framework
- **Tailwind CSS**: UI styling
- **scikit-learn**: ML models
- **chromadb**: Vector database
- **pydantic**: Data validation
- **requests**: HTTP client
## π§ͺ Testing
Run the orchestrator test:
```bash
python test_orchestrator.py
```
## π API Documentation
Interactive API docs available at:
```
http://127.0.0.1:8000/docs
```
## π€ Contributing
To add new agents or features:
1. Add agent to `agents/` folder
2. Implement `run_presage_pipeline()` updates
3. Update API schema if needed
4. Test with `test_orchestrator.py`
## π License
Proprietary Medical AI System
## π Resources
- [Groq Console](https://console.groq.com)
- [FastAPI Docs](https://fastapi.tiangolo.com)
- [Next.js Docs](https://nextjs.org/docs)
- [ChromaDB Docs](https://docs.trychroma.com)
|