Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

DermaCheck Agentic Backend

Intelligent multi-agent workflow for temporal skin lesion analysis using LangGraph + fine-tuned MedGemma.

Features

  • 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

Architecture

START
  ↓
router (quality assessment)
  ↓
  ├─→ vision_analysis (MedGemma API)
  │     ↓
  │     ├─→ knowledge_base (ABCDE content) [if change detected]
  │     │     ↓
  │     └─→ synthesis (urgency-aware content generation)
  │           ↓
  └─→ validation (urgency assignment)
        ↓
       END

Quick Start

# 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/ -v

Competition Demo

See COMPETITION_DEMO.ipynb for interactive demonstration of intelligent routing scenarios.

Project Structure

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

Testing

# 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=src

Test Coverage:

  • 14 unit tests for node functions and routing logic
  • 4 integration tests for complete workflow paths
  • All routing scenarios validated

LangSmith Integration

Enable workflow tracing:

# .env
LANGCHAIN_TRACING_V2=true
LANGCHAIN_API_KEY=your_langsmith_key
LANGCHAIN_PROJECT=dermacheck-agentic-backend

View traces at: https://smith.langchain.com

Competition Alignment

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

License

MIT