This repository provides a proof-of-concept (POC) system for healthcare triage, developed using the OpenAI Swarm Framework. The POC is designed to handle dynamic healthcare scenarios, with multiple agent roles to assess patient symptoms, make real-time decisions, and escalate cases to human medical professionals when needed.
This POC simulates a healthcare triage system using Swarm's agent-based approach, where agents operate as a team to conduct patient assessments. It demonstrates how agents could triage processes in healthcare. Key functions include symptom assessment, severity evaluation, and Human-in-the-Loop (HITL) functionality for cases that require medical professional oversight.
This POC is not intended for deployment in real healthcare settings but instead showcases the potential of agent-based AI for complex decision-making.
- Multiple Agent Roles: Agents collaborate to triage, escalate, and respond to patient symptoms.
- Dynamic Decision-Making: Decisions adapt based on symptom severity.
- HITL (Human-in-the-Loop) Functionality: Supports human intervention for high-risk or complex cases.
- Escalation to Emergency Services: Critical cases are automatically escalated to emergency services.
- Content Filtering: Leveraging Azure OpenAI's built-in content filters for added safety and compliance.
This POC relies on several coordinated agents, each with distinct responsibilities:
- Triage Agent: Assesses patient symptoms and determines the appropriate response level.
- Doctor Agent: Handles cases requiring medical intervention, including prescriptions.
- Escalation Agent: Manages emergency escalation to 911 or appropriate authorities.
Sequence Diagram:
Not to overwhelm you with details, here's a simplified sequence diagram of the system's operation, it'very high-level and hides some details. The second diagram is more detailed and shows the interactions between the agents and the user.
- Azure OpenAI API Access: This POC uses Azure's OpenAI API, but you can substitute with other OpenAI API instances.
- GPT-4 Model: The code is optimized for OpenAI’s GPT-4o-mini, using its function calling feature.
- Dependencies:
pip install -r requirements.txt
Define the following environment variables in a .env file (see .env.example):
AZURE_OPENAI_KEY=your_azure_openai_key
AZURE_OPENAI_ENDPOINT=your_openai_endpoint_url- Run the Triage System:
python ./src/app.py
- Agent Interaction: The agents will interact with users based on the provided input and escalate to HITL when needed.
Note: The POC relies on OpenAI's function-calling feature, which currently only supports OpenAI’s proprietary models, meaning local or open-source alternatives cannot be used here.
The POC implements several specialized agents, each playing a unique role:
- Purpose: Initial responder for assessing symptoms.
- Purpose: Evaluates and provides recommendations for medical cases.
- Purpose: Manages emergencies, contacts 911 if necessary.
- While it's promising, it's not ready for real healthcare settings yet - you'd need serious validation and testing first.
- We're also locked into using OpenAI's GPT models since they're the only ones with these specific function-calling features. That might affect how you plan to scale or modify this in the future.
- While we've got some basic protections in place, you'll need much more robust security and privacy measures before this goes anywhere near real patient data. We're talking HIPAA-grade safeguards here.
This system is a proof of concept and should not be used in any live healthcare setting. It cannot detect or diagnose medical conditions. The POC is purely for demonstration and educational purposes, highlighting potential applications of Swarm-based agents in healthcare scenarios.
If you are experiencing a medical emergency, please contact emergency services immediately.