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