Skip to content

VirusDumb/swasthagi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Swasthagi - AI-Powered Healthcare Assistant

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.

Overview

Swasthagi includes two implementations:

1. A2A (Agent-to-Agent) - Main Implementation

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.

2. Teams - A2A-less Multiagent Implementation

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

Features

✨ 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

Prerequisites

  • Python 3.10+
  • Ollama with models:
    • functiongemma:270m
    • hf.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

Quick Start

A2A Implementation

  1. Setup Environment:

    cd a2a
    python -m venv .venv
    # Windows PowerShell
    .\.venv\Scripts\activate
    # Or Linux/Mac
    source .venv/bin/activate
  2. Install Dependencies:

    pip install -r requirements.txt
  3. 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

Teams Implementation

  1. Setup Environment:

    cd teams
    python -m venv .venv
    .\.venv\Scripts\activate
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Run Dashboard:

    python dashboard.py

    Access at http://localhost:8000

  4. Run Main Agent:

    $env:GOOGLE_API_KEY="<your_google_api_key>"
    python main.py

Project Structure

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

Architecture Comparison

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

Dependencies

Core

  • agno - AI agent framework
  • fastapi - Web framework
  • uvicorn - ASGI server
  • ollama - Local LLM support

APIs & LLMs

  • google-genai - Google Gemini integration
  • openai - OpenAI compatibility
  • requests - HTTP client

Optional

  • sqlalchemy - Database ORM
  • beautifulsoup4 - Web scraping (Teams only)
  • googlesearch-python - Google search integration

Configuration

Environment Variables

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"

Ollama Models

Ensure Ollama is running and has required models:

ollama run functiongemma:270m
ollama run hf.co/unsloth/medgemma-4b-it-GGUF:Q2_K_XL

Usage

Through WhatsApp

Send health-related queries to the connected WhatsApp number. The system will:

  1. Understand your symptoms
  2. Provide medical advice
  3. Register you as a patient (A2A) or store records (Teams)
  4. Maintain conversation history

Through Dashboard

Direct API Calls

# 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"
  }'

Performance & Memory

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

Troubleshooting

Issue: "Ollama connection refused"

Solution: Ensure Ollama is running:

ollama serve

Issue: "API key not found"

Solution: Set environment variables before running agents

Issue: WhatsApp not receiving messages

Solution: Verify WhatsApp Business API credentials and webhook configuration

Future Enhancements

  • Multi-language support expansion
  • Integration with real medical databases
  • Appointment scheduling system
  • Prescription management
  • Telemedicine features
  • Mobile app interface

Contributing

Contributions are welcome! Areas for improvement:

  • Medical model accuracy and fine-tuning
  • UI/UX improvements
  • Additional language support
  • Performance optimization
  • Test coverage

License

[Add appropriate license here]

Acknowledgments

Built with:

Support

For issues, questions, or suggestions:

  1. Check existing documentation
  2. Review sample implementations in code
  3. Check logs for detailed error information

Swasthagi means "Health" in Sanskrit. This project aims to make quality healthcare advice accessible through AI agents.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors