Swasthagi is an intelligent healthcare platform that provides AI-driven medical advice and patient management through multi-agent systems. The project demonstrates two different approaches to building collaborative AI agents for healthcare applications.
Swasthagi includes two implementations:
The primary implementation using Agent-to-Agent communication patterns. Multiple specialized agents run on different ports and collaborate to provide comprehensive healthcare services.
Key Components:
- MedGemma Advisor: Medical symptom analysis and advice (port 7778)
- Doctor Office Agent: Patient registration and dashboard management (port 7779)
- WhatsApp Orchestrator: User-facing coordinator that orchestrates interactions between agents (port 7777)
Architecture: Agents communicate via HTTP/REST APIs, enabling a distributed microservice-like architecture.
An alternative multiagent approach without explicit Agent-to-Agent communication. Uses a team-based coordination model where agents work together in a unified context.
Key Features:
- Memory management and persistent patient records
- Multi-language support with translation capabilities
- WhatsApp integration for direct user access
- Dashboard for patient record visualization
β¨ Medical Consultation
- Symptom analysis using medical AI models
- Evidence-based health recommendations
- Integration with local medical models (MedGemma)
π± WhatsApp Integration
- Direct patient interaction via WhatsApp
- Natural language health queries
- Persistent conversation history
π₯ Patient Management
- Patient registration and profile management
- Medical history tracking
- Dashboard visualization of patient records
π Multi-language Support
- Support for Indian languages and Romanized text
- Automatic translation between languages
πΎ Persistent Storage
- SQLite-based patient records
- Patient information and consultation history
- Python 3.10+
- Ollama with models:
functiongemma:270mhf.co/unsloth/medgemma-4b-it-GGUF:Q2_K_XL
- API Keys (depending on implementation):
- Google Gemini API Key (for Google models)
- Sarvam AI Key (optional, for language models)
- WhatsApp Business API credentials
-
Setup Environment:
cd a2a python -m venv .venv # Windows PowerShell .\.venv\Scripts\activate # Or Linux/Mac source .venv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt
-
Run Services (in separate terminals):
Terminal 1 - MedGemma Advisor:
python medgemma.py
Runs on http://localhost:7778
Terminal 2 - Doctor Office:
python doctor_office_agent.py
Runs on http://localhost:7779 Dashboard: http://localhost:7779/patientspage
Terminal 3 - WhatsApp Orchestrator:
$env:GOOGLE_API_KEY="<your_google_api_key>" python whatsapp_agent.py
Runs on http://localhost:7777
-
Setup Environment:
cd teams python -m venv .venv .\.venv\Scripts\activate
-
Install Dependencies:
pip install -r requirements.txt
-
Run Dashboard:
python dashboard.py
Access at http://localhost:8000
-
Run Main Agent:
$env:GOOGLE_API_KEY="<your_google_api_key>" python main.py
swasthagi/
βββ a2a/ # Main A2A Implementation
β βββ doctor_office_agent.py # Patient registry & dashboard
β βββ medgemma.py # Medical advice agent
β βββ whatsapp_agent.py # WhatsApp orchestrator
β βββ patients.json # Patient data storage
β βββ index.html # Web interface
β βββ requirements.txt
β
βββ teams/ # Multiagent Team Implementation
β βββ main.py # Team coordination
β βββ dashboard.py # Patient dashboard
β βββ test.py # Testing utilities
β βββ requirements.txt
β
βββ templates/ # HTML templates
β βββ dashboard.html
β
βββ tmp/ # Temporary/data files
β βββ records.csv
β
βββ README.md # This file
| Aspect | A2A | Teams |
|---|---|---|
| Agent Communication | HTTP/REST APIs | Direct team coordination |
| Scalability | Horizontal (add agents as services) | Vertical (single process) |
| Complexity | Higher (distributed) | Lower (unified) |
| Deployment | Multiple processes/services | Single process |
| Memory Sharing | Via API calls | Shared context |
- agno - AI agent framework
- fastapi - Web framework
- uvicorn - ASGI server
- ollama - Local LLM support
- google-genai - Google Gemini integration
- openai - OpenAI compatibility
- requests - HTTP client
- sqlalchemy - Database ORM
- beautifulsoup4 - Web scraping (Teams only)
- googlesearch-python - Google search integration
Set these before running:
# Google API
$env:GOOGLE_API_KEY="your_google_api_key_here"
# Optional: Sarvam AI for language models
$env:SARVAM_KEY="your_sarvam_key_here"Ensure Ollama is running and has required models:
ollama run functiongemma:270m
ollama run hf.co/unsloth/medgemma-4b-it-GGUF:Q2_K_XLSend health-related queries to the connected WhatsApp number. The system will:
- Understand your symptoms
- Provide medical advice
- Register you as a patient (A2A) or store records (Teams)
- Maintain conversation history
- A2A: Visit http://localhost:7779/patientspage to view registered patients
- Teams: Visit http://localhost:8000 to view patient records and history
# A2A - Register a patient
curl -X POST http://localhost:7779/register_patient \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"illness": "Common Cold",
"description": "Symptoms include cough and fever"
}'The system is optimized for:
- Local Inference: Uses lightweight models (MedGemma 4B, FunctionGemma 270M)
- Memory Efficiency: Persistent storage prevents data loss
- Low Latency: WhatsApp API integration for real-time responses
Solution: Ensure Ollama is running:
ollama serveSolution: Set environment variables before running agents
Solution: Verify WhatsApp Business API credentials and webhook configuration
- Multi-language support expansion
- Integration with real medical databases
- Appointment scheduling system
- Prescription management
- Telemedicine features
- Mobile app interface
Contributions are welcome! Areas for improvement:
- Medical model accuracy and fine-tuning
- UI/UX improvements
- Additional language support
- Performance optimization
- Test coverage
[Add appropriate license here]
Built with:
- Agno Framework - AI Agent Framework
- FastAPI - Web Framework
- Ollama - Local LLM Support
- Google Gemini API - Advanced LLM
For issues, questions, or suggestions:
- Check existing documentation
- Review sample implementations in code
- Check logs for detailed error information
Swasthagi means "Health" in Sanskrit. This project aims to make quality healthcare advice accessible through AI agents.