"""Caliper — LLM measurement lab (Hugging Face Space). Demo mode needs no token: it evaluates simulated subjects with *known* ability, calibration skew, robustness and contamination, so you can watch each statistical instrument detect the pathology you injected. Live mode evaluates any chat model on HF Inference Providers with your own token (used only for this session, never stored). """ from __future__ import annotations import sys import tempfile from pathlib import Path sys.path.insert(0, str(Path(__file__).parent / "src")) import gradio as gr import numpy as np from caliper.adapters import SimulatedJudge, SimulatedSubject from caliper.irt import run_adaptive from caliper.judge import PairwiseJudge from caliper.report import render_html, run_fingerprint from caliper.report.html import _line_chart, _radar_svg from caliper.robustness import evaluate_robustness from caliper.robustness.perturb import PERTURBATIONS from caliper.types import ItemBank BANK = ItemBank.bundled() CSS = """ .svgbox { background: var(--background-fill-primary); border-radius: 8px; padding: 8px; } .small-note { color: var(--body-text-color-subdued); font-size: 0.85em; } """ # The report SVGs reference CSS custom properties that only exist inside the # standalone report document, and Gradio's HTML component sanitizes