Intelligent multi-agent workflow for temporal skin lesion analysis using LangGraph + fine-tuned MedGemma.
- 5-node LangGraph workflow with intelligent conditional routing
- Fine-tuned MedGemma 1.5 4B for temporal change detection (via HuggingFace Inference API)
- ABCDE knowledge base for educational content retrieval
- Multi-factor routing based on image quality, change detection, and urgency
- LangSmith integration for workflow observability and debugging
START
↓
router (quality assessment)
↓
├─→ vision_analysis (MedGemma API)
│ ↓
│ ├─→ knowledge_base (ABCDE content) [if change detected]
│ │ ↓
│ └─→ synthesis (urgency-aware content generation)
│ ↓
└─→ validation (urgency assignment)
↓
END
# 1. Install dependencies
cd backend
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# 2. Configure environment
cp .env.example .env
# Edit .env and add your HF_TOKEN
# 3. Initialize knowledge base
python3 -c "
import asyncio
from src.tools.knowledge_base import get_knowledge_base
async def init():
kb = await get_knowledge_base()
print('Knowledge base initialized')
asyncio.run(init())
"
# 4. Run demo
python3 demo.py
# 5. Run tests
pytest tests/ -vSee COMPETITION_DEMO.ipynb for interactive demonstration of intelligent routing scenarios.
backend/
├── src/
│ ├── graph/ # LangGraph workflow
│ │ ├── state.py # AgentState schema
│ │ ├── nodes.py # Node functions
│ │ └── workflow.py # StateGraph assembly
│ ├── tools/ # External integrations
│ │ ├── medgemma.py # HuggingFace client
│ │ ├── knowledge_base.py # Knowledge base
│ │ └── image_quality.py # Quality checker
│ └── config/
│ └── settings.py # Environment config
├── tests/
│ ├── test_nodes.py # Unit tests
│ └── test_workflow.py # Integration tests
├── data/
│ └── abcde_content.json # Educational content
├── docs/
│ └── workflow_diagram.md # Architecture diagrams
├── demo.py # Routing demo script
└── COMPETITION_DEMO.ipynb # Competition notebook
# Unit tests (nodes + routing)
pytest tests/test_nodes.py -v
# Integration tests (full workflows)
pytest tests/test_workflow.py -v
# All tests
pytest tests/ -v --cov=srcTest Coverage:
- 14 unit tests for node functions and routing logic
- 4 integration tests for complete workflow paths
- All routing scenarios validated
Enable workflow tracing:
# .env
LANGCHAIN_TRACING_V2=true
LANGCHAIN_API_KEY=your_langsmith_key
LANGCHAIN_PROJECT=dermacheck-agentic-backendView traces at: https://smith.langchain.com
This backend targets the Agentic Workflow Prize by demonstrating:
✅ Multi-agent orchestration - 5-node LangGraph workflow with conditional routing ✅ Intelligent routing - Multi-factor decisions (quality, change detection, urgency) ✅ Tool integration - HuggingFace Inference API + Knowledge base + Quality checker ✅ State management - TypedDict with Annotated reducers for parallel safety ✅ Observability - LangSmith tracing enabled ✅ Educational framing - ABCDE knowledge base with relevance scoring
MIT