A Stanford University methodology for systematic medical device innovation, enhanced with multi-agent LLM implementation for intelligent medical needs analysis
This project implements the Stanford Biodesign Methodology using a sophisticated multi-agent LLM system to systematize and enhance the medical device innovation process. The system features specialized AI agents (Medical Expert, Systems Engineer, and Needs Collector) that collaborate to identify and analyze healthcare needs through structured discussions.
Biodesign is a systematic approach to medical device innovation developed by Stanford University. The methodology consists of three core phases:
This phase focuses on discovering significant unmet healthcare needs through:
- Clinical environment immersion
- Observation of complete care cycles (diagnosis β treatment β recovery β billing)
- Problem and opportunity identification
- Need gathering and prioritization based on potential impact
During this phase, teams:
- Brainstorm diverse solution concepts
- Create and test rapid prototypes
- Implement "think-build-rethink" iteration cycles
- Evaluate concepts for:
- Technical feasibility
- Intellectual property potential
- Business model viability
- Regulatory pathway considerations
The final phase involves:
- Technology refinement
- Development of regulatory approval strategies
- Reimbursement planning
- Market potential assessment
- Funding source exploration
- Collaboration with industry mentors
This implementation enhances the Biodesign methodology with three specialized AI agents:
- π©Ί Medical Expert Agent: Analyzes healthcare needs from clinical and medical perspectives
- βοΈ Systems Engineer Agent: Provides technical solutions and system optimization insights
- π Needs Collector Agent: Synthesizes discussions and extracts actionable medical device requirements
bio-design/
βββ src/
β βββ agents/ # Multi-agent LLM implementation
β β βββ need_finder.py # Core reflection system
β β βββ need_finder_realtime.py # Real-time analysis system
β β βββ evaluator.py # Needs evaluation system
β β βββ ...
β βββ docs/ # API and setup documentation
βββ static/
β βββ index.html # Basic Web UI interface
β βββ need_statement_debate.html # π Need Statement Debate System Frontend
βββ experiments/ # Jupyter notebooks and experiments
βββ tests/ # Test files
βββ run.py # FastAPI server
βββ pyproject.toml # UV project configuration
βββ README.md # This file
- Python 3.10 or higher
- UV package manager (recommended) or pip
- OpenAI API key
# On macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# On Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"# Clone the repository
git clone https://github.com/SeanLinH/bio-design.git
cd bio-design
# copy .env.example to .env and setup API_KEY
cp .env.example .env
# Create virtual environment and install dependencies
uv sync
# Activate the virtual environment
source .venv/bin/activate # Linux/macOS
# or
.venv\Scripts\activate # Windows# Create environment file
cp .env.example .env
# Edit .env file and add your OpenAI API key
echo "OPENAI_API_KEY=your_openai_api_key_here" > .env# Start the FastAPI server
uv run python run.py
# Or alternatively
python run.pyThe service will be available at http://localhost:8000
We provide a specialized frontend interface that allows users to easily input medical needs and watch multi-agent debate processes in real-time:
- π Intuitive Input: Large text input area supporting multi-line Need Statement input
- π― Intelligent Debate: Multi-agent collaborative debate including Medical Expert, Systems Engineer, and Needs Collector
- π Real-time Display: Three view modes: Debate Process, Debate Results, and Needs Summary
- β‘ Progress Tracking: Real-time progress bar and status indicators
- π± Responsive Design: Support for desktop and mobile devices
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π¦· Need Statement Debate System β
β LLM Agent-based Biodesign Methodology β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββ
β π Input Panelβ β π€ Debate Display Panel β
β β β β
β Need Statement: β β π©Ί Medical Expert Agent β
β [Enter your β β From a medical perspective, this need β
β medical need β β involves... β
β description...]β β β
β β β βοΈ Systems Engineer Agent β
β Debate Rounds: β β From a technical perspective, this β
β [3 rounds] β β need requires... β
β β β β
β π Start Debate β β π Needs Collector Agent β
β Analysis β β Based on both experts' analysis, I β
β β β identify... β
β π‘ Example β β β
β Needs: β β π Progress: ββββββββββββββββββββ 100% β
β β’ Diabetes β β β
β β’ Dental β β [Debate Process] [Results] [Summary] β
β β’ Elderly Care β β β
βββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββ
- After starting the server, visit:
http://localhost:8000/static/need_statement_debate.html - Enter your medical need description on the left side
- Select debate rounds (2-5 rounds)
- Click "Start Debate Analysis" button
- Watch multi-agent debate process in real-time
- Switch between different views to see analysis results
- π©Ί Medical Expert Agent: Analyzes needs from clinical medical perspective
- βοΈ Systems Engineer Agent: Evaluates feasibility from technical engineering perspective
- π Needs Collector Agent: Integrates discussion results and forms actionable recommendations
Open your browser and navigate to http://localhost:8000 to access the interactive web interface.
- Query Input: Large text area for entering medical scenarios or questions
- Discussion Rounds: Configurable number of agent discussion rounds (2-5)
- Analysis Modes:
- Standard Analysis: Traditional batch processing
- β‘ Real-time Analysis: Live agent discussions with status updates
When using real-time analysis, you'll see:
- Live Agent Status: Real-time updates showing which agent is currently thinking
- Discussion Progress: Round-by-round conversation between Medical Expert and Systems Engineer
- Agent Messages: Color-coded messages from different agents:
- π΄ Medical Expert (Red border)
- π’ Systems Engineer (Green border)
- π Needs Collector (Orange border)
- π£ System Messages (Purple border)
- π Analysis Results: Structured needs analysis with medical insights
- β Evaluation: Automated scoring and prioritization of identified needs
- π Prioritization: Ranking and implementation recommendations
- π§ Raw Data: Complete conversation logs and technical details
Try this example query to see the system in action:
An older patient with multiple chronic diseases faces problems with poor medication adherence, lack of real-time monitoring, and personalized support during home care and outpatient follow-ups.
GET /- Web UI interfacePOST /api/reflection- Submit standard analysis requestPOST /api/reflection-realtime- Submit real-time analysis requestGET /api/reflection/{session_id}- Get analysis resultsGET /api/evaluation/{session_id}- Get needs evaluationGET /api/prioritization/{session_id}- Get prioritization results
GET /api/reflection-stream/{session_id}- Server-Sent Events for real-time updates
GET /health- Service health checkGET /api/sessions- List active analysis sessions
- Open
http://localhost:8000in your browser - Enter a medical scenario in the query text area
- Select the number of discussion rounds (3 recommended)
- Choose analysis mode:
- "Start Analysis" for standard processing
- "β‘ Start Real-time Analysis" for live updates
- Monitor progress in real-time (if selected)
- Review results in the tabbed interface
import requests
# Submit analysis request
response = requests.post("http://localhost:8000/api/reflection", json={
"query": "Your medical scenario here...",
"max_rounds": 3
})
session_id = response.json()["session_id"]
# Get results
results = requests.get(f"http://localhost:8000/api/reflection/{session_id}")
print(results.json())import requests
import sseclient # pip install sseclient-py
# Start real-time analysis
response = requests.post("http://localhost:8000/api/reflection-realtime", json={
"query": "Your medical scenario here...",
"max_rounds": 3
})
session_id = response.json()["session_id"]
# Stream real-time updates
stream = sseclient.SSEClient(f"http://localhost:8000/api/reflection-stream/{session_id}")
for event in stream:
if event.data:
print(f"Update: {event.data}")# Run all tests
uv run pytest tests/
# Run specific test
uv run python tests/test_api.py# Start with auto-reload for development
uv run uvicorn run:app --host 0.0.0.0 --port 8000 --reloadExplore the experiments/ directory for interactive notebooks demonstrating various features:
multi_agent.ipynb- Multi-agent system explorationagent_supervisor.ipynb- Agent coordination patternsreflection.ipynb- Reflection methodology implementation
OPENAI_API_KEY: Your OpenAI API key (required)OPENAI_BASE_URL: Custom OpenAI compatible endpoint (optional)LOG_LEVEL: Logging level (default: INFO)
The system uses gpt-4.1-mini by default. You can modify the model in the agent configuration files.
The system generates structured analysis including:
- Medical Needs: Identified healthcare requirements
- Technical Solutions: Engineering and system recommendations
- Implementation Strategies: Prioritized action plans
- Evaluation Metrics: Scoring and ranking of needs
- Full Conversation Logs: Complete agent discussions
# Verify your API key is set
echo $OPENAI_API_KEY
# Test OpenAI connection
uv run python test_openai.py# Use a different port
uv run python run.py --port 8001# Reinstall dependencies
uv sync --reinstall[License information to be added]
[Contribution guidelines to be added]
[Contact information to be added]