| --- |
| 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) |
|
|