from __future__ import annotations
# index 0-4 = teachers (aligns with MODEL_COLORS[1:] in _fig.py)
_TEACHER_COLORS = ["#7c3aed", "#06b6d4", "#f59e0b", "#34d399", "#f472b6"]
def gate_html(gate_weights: list[float], teacher_names: list[str]) -> str:
"""Horizontal bar chart sorted by weight descending."""
ranked = sorted(
enumerate(zip(gate_weights, teacher_names)),
key=lambda x: x[1][0],
reverse=True,
)
rows = []
for orig_idx, (w, name) in ranked:
color = _TEACHER_COLORS[orig_idx % len(_TEACHER_COLORS)]
bar_pct = int(w * 100)
rows.append(
f'
'
f'
{name}'
f'
'
f'
{w:.2f}'
f'
'
)
return (
''
'
'
'TEACHER INFLUENCE
'
+ "".join(rows)
+ "
"
)
def task_html(gate_weights: list[float], teacher_names: list[str]) -> str:
"""Badge for argmax teacher + runner-up."""
best_idx = max(range(len(gate_weights)), key=lambda i: gate_weights[i])
second_idx = sorted(range(len(gate_weights)), key=lambda i: gate_weights[i])[-2]
color = _TEACHER_COLORS[best_idx % len(_TEACHER_COLORS)]
best = teacher_names[best_idx].upper()
second = teacher_names[second_idx].upper()
w2 = gate_weights[second_idx]
n = len(teacher_names)
return (
''
'
'
'DOMINANT TEACHER
'
'
'
f''
f'{best}'
f''
f'runner-up {second} · {w2:.2f}'
f'
'
f'
'
f'gate picked this teacher for your prompt ({n} total)
'
'
'
)
def header_html() -> str:
"""App header with ∀ logo, wordmark, and status pills."""
def pill(color: str, dot_color: str, text: str, pulse: bool = False) -> str:
dot_class = ' class="live-dot"' if pulse else ''
return (
f''
f''
f'{text}'
)
return (
''
# Left: logo + title
'
'
'
'
'∀'
'
'
'
'
'
One for All
'
'
multi-teacher soul distillation
'
'
'
# Right: pills
'
'
+ pill("#06b6d4", "#06b6d4", "STUDENT · Qwen2.5-0.5B", pulse=True)
+ pill("#7c3aed", "#7c3aed", "5 TEACHERS")
+ pill("#f59e0b", "#f59e0b", "PATH B · GEOMETRY")
+ '
'
# Divider with glow
''
)