Die erste Fassung der Oberfläche war inhaltlich und optisch schwach. Neu: drei Reiter (Benchmark, Ergebnisse, Einstellungen). Modelle werden in den Einstellungen mit Adapter (Ollama oder OpenAI-kompatibel), URL, Modell-ID und Schlüssel-Variable angelegt, mit Verbindungstest. config.toml speichert die Liste. Bewertung absolut in Prozent: ein Wert je Bereich A bis D und eine Gesamtnote, gewichtet nach weight. Batch-Verlauf, Schritt-Ansicht, Erklärung der Bewertung. 55 Unit-Tests grün, svelte-check ohne Fehler. Im Browser mit Beispieldaten geprüft, nicht in der echten App. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
353 lines
10 KiB
Svelte
353 lines
10 KiB
Svelte
<script lang="ts">
|
||
import { onMount, untrack } from "svelte";
|
||
import {
|
||
api,
|
||
fmtDuration,
|
||
fmtPct,
|
||
groupLabel,
|
||
pctColor,
|
||
type BatchInfo,
|
||
type Ranking,
|
||
type RunRow,
|
||
type StepRow,
|
||
} from "$lib/api";
|
||
|
||
let { selected = $bindable(null) }: { selected: number | null } = $props();
|
||
|
||
let batches = $state<BatchInfo[]>([]);
|
||
let ranking = $state<Ranking | null>(null);
|
||
let rows = $state<RunRow[]>([]);
|
||
let error = $state("");
|
||
let loading = $state(false);
|
||
let detail = $state<{ run: RunRow; steps: StepRow[] } | null>(null);
|
||
let showRuns = $state(false);
|
||
|
||
async function loadBatches() {
|
||
try {
|
||
batches = await api.batches();
|
||
if (selected === null && batches.length > 0) selected = batches[0].id;
|
||
} catch (e) {
|
||
error = String(e);
|
||
}
|
||
}
|
||
|
||
async function loadBatch(id: number | null) {
|
||
ranking = null;
|
||
rows = [];
|
||
detail = null;
|
||
if (id === null) return;
|
||
loading = true;
|
||
error = "";
|
||
try {
|
||
[ranking, rows] = await Promise.all([api.ranking(id), api.results(id)]);
|
||
} catch (e) {
|
||
error = String(e);
|
||
} finally {
|
||
loading = false;
|
||
}
|
||
}
|
||
|
||
onMount(loadBatches);
|
||
|
||
// Beim Wechsel des Batches neu laden. Neue Batches erscheinen nach dem Lauf in der Liste.
|
||
$effect(() => {
|
||
const id = selected;
|
||
untrack(() => {
|
||
loadBatch(id);
|
||
if (id !== null && !batches.some((b) => b.id === id)) loadBatches();
|
||
});
|
||
});
|
||
|
||
async function showSteps(run: RunRow) {
|
||
if (selected === null) return;
|
||
detail = { run, steps: await api.steps(selected, run) };
|
||
}
|
||
|
||
function cell(model: string, task: string) {
|
||
return ranking?.cells.find((c) => c.model === model && c.task_id === task);
|
||
}
|
||
|
||
function batchLabel(b: BatchInfo): string {
|
||
return `Batch ${b.id} · ${b.created_at.slice(0, 16)} · ${b.runs} Läufe`;
|
||
}
|
||
|
||
// Bereiche mit wenigen Aufgaben sind nur grobe Hinweise.
|
||
const FEW_TASKS = 3;
|
||
</script>
|
||
|
||
<section class="card">
|
||
<div class="head">
|
||
<h2>Bewertung</h2>
|
||
{#if batches.length > 0}
|
||
<select bind:value={selected} aria-label="Batch wählen">
|
||
{#each batches as b (b.id)}
|
||
<option value={b.id}>{batchLabel(b)}</option>
|
||
{/each}
|
||
</select>
|
||
{/if}
|
||
</div>
|
||
|
||
{#if error}<p class="error">{error}</p>{/if}
|
||
{#if batches.length === 0 && !error}
|
||
<p class="muted">Noch keine Ergebnisse. Starte im Reiter „Benchmark“ einen Lauf.</p>
|
||
{/if}
|
||
{#if loading}<p class="muted">Lade …</p>{/if}
|
||
|
||
{#if ranking && ranking.models.length > 0}
|
||
<div class="scroll">
|
||
<table class="rank">
|
||
<thead>
|
||
<tr>
|
||
<th class="num">#</th>
|
||
<th>Modell</th>
|
||
<th class="total">Gesamt</th>
|
||
{#each ranking.groups as g (g)}
|
||
<th class="grp" title={groupLabel(g)}>{g}<br /><span class="gl">{groupLabel(g)}</span></th>
|
||
{/each}
|
||
<th>Schwächster Bereich</th>
|
||
<th class="num">Bestanden</th>
|
||
<th class="num">Median-Dauer</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{#each ranking.models as m (m.model)}
|
||
<tr>
|
||
<td class="num">{m.rank}</td>
|
||
<td><strong>{m.model}</strong></td>
|
||
<td class="total">
|
||
<div class="pct big" style:color={pctColor(m.total_percent)}>{fmtPct(m.total_percent)}</div>
|
||
<div class="meter"><div style:width="{m.total_percent}%" style:background={pctColor(m.total_percent)}></div></div>
|
||
</td>
|
||
{#each m.groups as g (g.group)}
|
||
<td class="grp">
|
||
{#if g.percent === null}
|
||
<span class="muted">–</span>
|
||
{:else}
|
||
<div class="pct" style:color={pctColor(g.percent)}>{fmtPct(g.percent)}</div>
|
||
<div class="meter small"><div style:width="{g.percent}%" style:background={pctColor(g.percent)}></div></div>
|
||
<div class="n" class:few={g.tasks < FEW_TASKS} title={g.tasks < FEW_TASKS ? "Wenige Aufgaben: der Wert ist nur ein grober Hinweis." : ""}>
|
||
{g.tasks} Aufg.{g.tasks < FEW_TASKS ? " (grob)" : ""}
|
||
</div>
|
||
{/if}
|
||
</td>
|
||
{/each}
|
||
<td>
|
||
{#if m.weakest_group}
|
||
{m.weakest_group} · {groupLabel(m.weakest_group)}
|
||
{:else}
|
||
<span class="muted">–</span>
|
||
{/if}
|
||
</td>
|
||
<td class="num">{m.successes} / {m.runs}</td>
|
||
<td class="num">{fmtDuration(m.median_duration_ms)}</td>
|
||
</tr>
|
||
{/each}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<details class="how">
|
||
<summary>So wird bewertet</summary>
|
||
<ul>
|
||
<li>
|
||
Die Bewertung ist <strong>absolut</strong>, nicht im Vergleich zu einem Referenzmodell. 100 % heißt: alle
|
||
Prüfungen der Aufgaben bestanden.
|
||
</li>
|
||
<li>
|
||
Je Aufgabe zählt der Mittelwert der Durchläufe. Teilpunkte aus <code>check.sh</code> gehen anteilig ein.
|
||
</li>
|
||
<li>
|
||
Wert je Bereich: gewichteter Mittelwert der Aufgaben im Bereich. Gesamt: gewichteter Mittelwert über alle
|
||
Aufgaben des Batches. Die Gewichte stehen als <code>weight</code> in <code>task.toml</code>.
|
||
</li>
|
||
<li>Fehlt einem Modell ein Bereich, bleibt das Feld leer und zählt nicht in die Gesamtnote.</li>
|
||
<li>Die Reihenfolge richtet sich nach der Gesamtnote. Bei Gleichstand gewinnt die kürzere Median-Dauer.</li>
|
||
<li>Bereiche mit weniger als {FEW_TASKS} Aufgaben sind nur grobe Hinweise.</li>
|
||
</ul>
|
||
</details>
|
||
|
||
<h3>Aufgaben im Detail</h3>
|
||
<div class="scroll">
|
||
<table class="matrix">
|
||
<thead>
|
||
<tr>
|
||
<th>Modell</th>
|
||
{#each ranking.tasks as t (t.id)}
|
||
<th class="num" title={groupLabel(t.group)}>{t.id}</th>
|
||
{/each}
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{#each ranking.models as m (m.model)}
|
||
<tr>
|
||
<td>{m.model}</td>
|
||
{#each ranking.tasks as t (t.id)}
|
||
{@const c = cell(m.model, t.id)}
|
||
<td
|
||
class="num"
|
||
style:background={c ? `color-mix(in srgb, ${pctColor(c.mean_score * 100)} 28%, transparent)` : ""}
|
||
title={c ? `${Math.round(c.mean_score * 100)} %, ${c.successes} von ${c.runs} bestanden` : "keine Läufe"}
|
||
>
|
||
{c ? `${Math.round(c.mean_score * 100)} %` : "–"}
|
||
</td>
|
||
{/each}
|
||
</tr>
|
||
{/each}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<h3>
|
||
Einzelne Läufe
|
||
<button class="link" onclick={() => (showRuns = !showRuns)}>{showRuns ? "ausblenden" : `anzeigen (${rows.length})`}</button>
|
||
</h3>
|
||
{#if showRuns}
|
||
<div class="scroll">
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Modell</th>
|
||
<th>Aufgabe</th>
|
||
<th class="num">Durchlauf</th>
|
||
<th>Ergebnis</th>
|
||
<th class="num">Score</th>
|
||
<th class="num">Schritte</th>
|
||
<th class="num">Dauer</th>
|
||
<th></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{#each rows as r (`${r.model}|${r.task_id}|${r.repeat_idx}`)}
|
||
<tr>
|
||
<td>{r.model}</td>
|
||
<td>{r.task_id}</td>
|
||
<td class="num">{r.repeat_idx}</td>
|
||
<td class={r.error_class === "ok" ? "ok" : "error"}>{r.error_class === "ok" ? "bestanden" : r.error_class}</td>
|
||
<td class="num">{Math.round(r.score * 100)} %</td>
|
||
<td class="num">{r.steps}</td>
|
||
<td class="num">{fmtDuration(r.duration_ms)}</td>
|
||
<td><button onclick={() => showSteps(r)}>Schritte</button></td>
|
||
</tr>
|
||
{/each}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
{/if}
|
||
|
||
{#if detail}
|
||
<div class="detail">
|
||
<h3>
|
||
Schritte: {detail.run.model} · {detail.run.task_id} · Durchlauf {detail.run.repeat_idx}
|
||
<button class="link" onclick={() => (detail = null)}>schließen</button>
|
||
</h3>
|
||
{#if detail.run.check_output}
|
||
<p class="muted">Prüfung (<code>check.sh</code>):</p>
|
||
<pre>{detail.run.check_output}</pre>
|
||
{/if}
|
||
<ol class="steps">
|
||
{#each detail.steps as st (st.idx)}
|
||
<li>
|
||
<strong>{st.role}</strong>
|
||
{#if st.tool_name}<span class="chip">{st.tool_name}</span> <code>{st.tool_args_json ?? ""}</code>{/if}
|
||
{#if st.content}<pre>{st.content}</pre>{/if}
|
||
</li>
|
||
{/each}
|
||
</ol>
|
||
</div>
|
||
{/if}
|
||
{:else if ranking && !loading}
|
||
<p class="muted">Dieser Batch hat noch keine fertigen Läufe.</p>
|
||
{/if}
|
||
</section>
|
||
|
||
<style>
|
||
.head {
|
||
display: flex;
|
||
gap: 1rem;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
margin-bottom: 0.8rem;
|
||
}
|
||
.head h2 {
|
||
margin: 0;
|
||
flex: 1;
|
||
}
|
||
.head select {
|
||
max-width: 100%;
|
||
}
|
||
.scroll {
|
||
overflow-x: auto;
|
||
margin-bottom: 1rem;
|
||
}
|
||
.rank td,
|
||
.rank th {
|
||
vertical-align: top;
|
||
}
|
||
.matrix th {
|
||
text-transform: none;
|
||
}
|
||
.rank .total {
|
||
min-width: 7.5rem;
|
||
}
|
||
.rank .grp {
|
||
min-width: 6rem;
|
||
}
|
||
.gl {
|
||
font-weight: 400;
|
||
text-transform: none;
|
||
letter-spacing: 0;
|
||
}
|
||
.pct {
|
||
font-weight: 700;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
.pct.big {
|
||
font-size: 1.6rem;
|
||
line-height: 1.1;
|
||
}
|
||
.meter {
|
||
height: 7px;
|
||
background: var(--surface-2);
|
||
border-radius: 999px;
|
||
overflow: hidden;
|
||
margin: 0.25rem 0;
|
||
}
|
||
.meter.small {
|
||
height: 5px;
|
||
}
|
||
.meter > div {
|
||
height: 100%;
|
||
}
|
||
.n {
|
||
font-size: 0.75rem;
|
||
color: var(--muted);
|
||
}
|
||
.n.few {
|
||
color: var(--danger);
|
||
}
|
||
.how {
|
||
margin: 0.5rem 0 1.2rem;
|
||
color: var(--muted);
|
||
}
|
||
.how summary {
|
||
cursor: pointer;
|
||
}
|
||
.detail {
|
||
margin-top: 1rem;
|
||
border-top: 1px solid var(--border);
|
||
padding-top: 1rem;
|
||
}
|
||
.steps pre,
|
||
.detail > pre {
|
||
white-space: pre-wrap;
|
||
overflow-wrap: anywhere;
|
||
max-height: 12rem;
|
||
overflow-y: auto;
|
||
background: var(--bg);
|
||
border: 1px solid var(--border);
|
||
border-radius: 6px;
|
||
padding: 0.5rem;
|
||
margin: 0.3rem 0;
|
||
}
|
||
</style>
|