Ergebnisse: Token-Verbrauch je Modell und Batch, Fehlergrund je Lauf, Ergebnisdateien mit Vorschau und Ordner öffnen
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -1,16 +1,20 @@
|
||||
<script lang="ts">
|
||||
import { onMount, untrack } from "svelte";
|
||||
import { revealItemInDir } from "@tauri-apps/plugin-opener";
|
||||
import {
|
||||
api,
|
||||
errorLabel,
|
||||
fmtDuration,
|
||||
fmtPct,
|
||||
fmtTps,
|
||||
fmtTokens,
|
||||
failureReason,
|
||||
isInfrastructure,
|
||||
groupLabel,
|
||||
pctColor,
|
||||
type BatchInfo,
|
||||
type Ranking,
|
||||
type FilesReport,
|
||||
type RunRow,
|
||||
type StepRow,
|
||||
} from "$lib/api";
|
||||
@ -22,7 +26,7 @@
|
||||
let rows = $state<RunRow[]>([]);
|
||||
let error = $state("");
|
||||
let loading = $state(false);
|
||||
let detail = $state<{ run: RunRow; steps: StepRow[] } | null>(null);
|
||||
let detail = $state<{ run: RunRow; steps: StepRow[]; files: FilesReport | null; filesError: string } | null>(null);
|
||||
let showRuns = $state(false);
|
||||
|
||||
async function loadBatches() {
|
||||
@ -43,6 +47,7 @@
|
||||
error = "";
|
||||
try {
|
||||
[ranking, rows] = await Promise.all([api.ranking(id), api.results(id)]);
|
||||
showRuns = rows.length <= 40;
|
||||
} catch (e) {
|
||||
error = String(e);
|
||||
} finally {
|
||||
@ -63,9 +68,31 @@
|
||||
|
||||
async function showSteps(run: RunRow) {
|
||||
if (selected === null) return;
|
||||
detail = { run, steps: await api.steps(selected, run) };
|
||||
const steps = await api.steps(selected, run);
|
||||
detail = { run, steps, files: null, filesError: "" };
|
||||
// Die Ergebnisdateien kommen getrennt: Fehlen sie, soll die Schrittliste trotzdem erscheinen.
|
||||
try {
|
||||
const files = await api.files(selected, run);
|
||||
if (detail && detail.run === run) detail.files = files;
|
||||
} catch (e) {
|
||||
if (detail && detail.run === run) detail.filesError = String(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function reveal(path: string) {
|
||||
try {
|
||||
await revealItemInDir(path);
|
||||
} catch {
|
||||
// Ohne Dateimanager bleibt der Pfad als Text sichtbar.
|
||||
}
|
||||
}
|
||||
|
||||
// Verbrauch im ganzen Batch (alle gespeicherten Läufe, auch nicht gewertete).
|
||||
let batchTokens = $derived({
|
||||
prompt: rows.reduce((a, r) => a + r.prompt_tokens, 0),
|
||||
completion: rows.reduce((a, r) => a + r.completion_tokens, 0),
|
||||
});
|
||||
|
||||
// Angebundene Modelle zuerst, dann die Referenzen (von Hand gelöst, ohne Rang).
|
||||
let ordered = $derived(
|
||||
ranking ? [...ranking.models.filter((m) => !m.external), ...ranking.models.filter((m) => m.external)] : [],
|
||||
@ -136,7 +163,7 @@
|
||||
{#if !m.external}
|
||||
<span title="Median der Laufzeit">⏱ {fmtDuration(m.median_duration_ms)}</span>
|
||||
<span title="Tokens pro Sekunde: Tokens geteilt durch die gesamte Laufzeit eines Laufs, also inklusive Tool- und Prüfzeit. Nicht die reine Erzeugungsgeschwindigkeit.">⚡ {fmtTps(m.median_tps)}</span>
|
||||
<span title="Durchschnittlich erzeugte Tokens je Lauf">∅ {Math.round(m.mean_completion_tokens)} Tokens</span>
|
||||
<span title="Verbrauch in diesem Batch: {fmtTokens(m.prompt_tokens_total)} Prompt-Tokens (gesendet) und {fmtTokens(m.completion_tokens_total)} Ausgabe-Tokens (erzeugt). Durchschnittlich {Math.round(m.mean_completion_tokens)} Ausgabe-Tokens je Lauf.">Σ {fmtTokens(m.prompt_tokens_total + m.completion_tokens_total)} Tokens</span>
|
||||
{:else}
|
||||
<span>Zeit und Tokens nicht gemessen</span>
|
||||
{/if}
|
||||
@ -180,6 +207,14 @@
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
{#if batchTokens.prompt + batchTokens.completion > 0}
|
||||
<p class="muted small legend">
|
||||
Verbrauch in diesem Batch: <strong>{fmtTokens(batchTokens.prompt + batchTokens.completion)} Tokens</strong>
|
||||
({fmtTokens(batchTokens.prompt)} gesendet, {fmtTokens(batchTokens.completion)} erzeugt). Bei Anbietern mit Kontingent
|
||||
(z. B. Ollama Cloud) zählt das gegen dein Limit.
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
{#if bestRef}
|
||||
<p class="muted small legend">
|
||||
<span class="tick-demo"></span> Strich im Balken = Referenz <strong>{bestRef.model}</strong> (extern, von Hand gelöst, anderes Harness).
|
||||
@ -267,6 +302,7 @@
|
||||
<th>Ergebnis</th>
|
||||
<th class="num">Score</th>
|
||||
<th class="num">Schritte</th>
|
||||
<th class="num">Tokens</th>
|
||||
<th class="num">Dauer</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@ -280,9 +316,11 @@
|
||||
<td class={r.error_class === "ok" ? "ok" : isInfrastructure(r.error_class) ? "muted" : "error"}>
|
||||
{errorLabel(r.error_class)}
|
||||
{#if isInfrastructure(r.error_class)}<span class="chip" title="Zählt nicht in die Bewertung">nicht gewertet</span>{/if}
|
||||
{#if r.error_class !== "ok"}<div class="reason small">{failureReason(r)}</div>{/if}
|
||||
</td>
|
||||
<td class="num">{Math.round(r.score * 100)} %</td>
|
||||
<td class="num">{r.steps}</td>
|
||||
<td class="num" title="{r.prompt_tokens} gesendet, {r.completion_tokens} erzeugt">{r.external ? "–" : fmtTokens(r.prompt_tokens + r.completion_tokens)}</td>
|
||||
<td class="num">{fmtDuration(r.duration_ms)}</td>
|
||||
<td><button onclick={() => showSteps(r)}>Schritte</button></td>
|
||||
</tr>
|
||||
@ -301,10 +339,53 @@
|
||||
{#if detail.run.external}
|
||||
<p class="muted">Extern gelöst, keine Schritte aufgezeichnet. Der Ergebnisordner steht unter <code>{detail.run.artifact_path ?? "unbekannt"}</code>.</p>
|
||||
{/if}
|
||||
{#if detail.run.error_class !== "ok"}
|
||||
<div class="why">
|
||||
<strong>Warum nicht voll bestanden?</strong>
|
||||
{failureReason(detail.run)}
|
||||
<span class="muted small">({errorLabel(detail.run.error_class)}, Score {Math.round(detail.run.score * 100)} %)</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if detail.run.summary}
|
||||
<p class="muted">Antwort des Modells am Ende:</p>
|
||||
<pre>{detail.run.summary}</pre>
|
||||
{/if}
|
||||
<p class="muted small">
|
||||
Verbrauch: {fmtTokens(detail.run.prompt_tokens)} Tokens gesendet, {fmtTokens(detail.run.completion_tokens)} erzeugt,
|
||||
{detail.run.steps} Schritte, {fmtDuration(detail.run.duration_ms)}.
|
||||
</p>
|
||||
|
||||
<h4>Ergebnisdateien</h4>
|
||||
{#if detail.filesError}
|
||||
<p class="muted small">{detail.filesError}</p>
|
||||
{:else if !detail.files}
|
||||
<p class="muted small">Lade …</p>
|
||||
{:else}
|
||||
<p class="small">
|
||||
<code>{detail.files.dir}</code>
|
||||
<button class="link" onclick={() => reveal(detail!.files!.dir)}>im Dateimanager öffnen</button>
|
||||
</p>
|
||||
{#if detail.files.files.length === 0}
|
||||
<p class="muted small">Das Modell hat keine Dateien hinterlassen.</p>
|
||||
{/if}
|
||||
{#each detail.files.files as f (f.path)}
|
||||
<details class="file">
|
||||
<summary><code>{f.path}</code> <span class="muted small">{f.size} Bytes</span></summary>
|
||||
{#if f.text !== null}
|
||||
<pre>{f.text}{f.truncated ? "\n… gekürzt" : ""}</pre>
|
||||
{:else}
|
||||
<p class="muted small">Binärdatei, keine Vorschau.</p>
|
||||
{/if}
|
||||
</details>
|
||||
{/each}
|
||||
{#if detail.files.more}<p class="muted small">Es gibt weitere Dateien, die hier nicht angezeigt werden.</p>{/if}
|
||||
{/if}
|
||||
|
||||
{#if detail.run.check_output}
|
||||
<p class="muted">Prüfung (<code>check.sh</code>):</p>
|
||||
<h4>Ausgabe der Prüfung (<code>check.sh</code>)</h4>
|
||||
<pre>{detail.run.check_output}</pre>
|
||||
{/if}
|
||||
<h4>Schritte des Modells</h4>
|
||||
<ol class="steps">
|
||||
{#each detail.steps as st (st.idx)}
|
||||
<li>
|
||||
@ -477,6 +558,30 @@
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
.reason {
|
||||
color: var(--muted);
|
||||
max-width: 26rem;
|
||||
white-space: normal;
|
||||
}
|
||||
.why {
|
||||
border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
|
||||
background: color-mix(in srgb, var(--danger) 10%, transparent);
|
||||
border-radius: 10px;
|
||||
padding: 0.6rem 0.9rem;
|
||||
margin: 0.6rem 0;
|
||||
}
|
||||
.file {
|
||||
margin: 0.2rem 0;
|
||||
}
|
||||
.file summary {
|
||||
cursor: pointer;
|
||||
}
|
||||
.detail h4 {
|
||||
margin: 1rem 0 0.3rem;
|
||||
}
|
||||
.small {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
.how {
|
||||
margin: 0.5rem 0 1.2rem;
|
||||
color: var(--muted);
|
||||
|
||||
@ -88,6 +88,8 @@ export type ModelRank = {
|
||||
successes: number;
|
||||
median_duration_ms: number;
|
||||
mean_completion_tokens: number;
|
||||
prompt_tokens_total: number;
|
||||
completion_tokens_total: number;
|
||||
median_tps: number | null;
|
||||
};
|
||||
export type MatrixCell = { model: string; task_id: string; runs: number; successes: number; mean_score: number };
|
||||
@ -109,6 +111,8 @@ export type BatchEvent =
|
||||
| { kind: "model_unavailable"; model: string; reason: string }
|
||||
| { kind: "progress"; done: number; total: number };
|
||||
|
||||
export type FileEntry = { path: string; size: number; text: string | null; truncated: boolean };
|
||||
export type FilesReport = { dir: string; files: FileEntry[]; more: boolean };
|
||||
export type ExportResult = { dir: string; folders: number };
|
||||
export type ImportSummary = { imported: number; passed: number; skipped: string[] };
|
||||
|
||||
@ -132,6 +136,8 @@ export const api = {
|
||||
batches: () => invoke<BatchInfo[]>("list_batches"),
|
||||
results: (batchId: number) => invoke<RunRow[]>("batch_results", { batchId }),
|
||||
ranking: (batchId: number) => invoke<Ranking>("batch_ranking", { batchId }),
|
||||
files: (batchId: number, r: RunRow) =>
|
||||
invoke<FilesReport>("run_files", { batchId, model: r.model, taskId: r.task_id, repeatIdx: r.repeat_idx }),
|
||||
steps: (batchId: number, r: RunRow) =>
|
||||
invoke<StepRow[]>("run_steps", { batchId, model: r.model, taskId: r.task_id, repeatIdx: r.repeat_idx }),
|
||||
};
|
||||
@ -189,3 +195,26 @@ export function fmtDuration(ms: number): string {
|
||||
export function fmtTps(t: number | null): string {
|
||||
return t === null ? "–" : `${t < 10 ? t.toFixed(1) : Math.round(t)} Tok/s`;
|
||||
}
|
||||
|
||||
/** Tokens lesbar: 1 234 oder 12,3 Tsd. */
|
||||
export function fmtTokens(n: number): string {
|
||||
return n >= 100000 ? `${(n / 1000).toFixed(0)} Tsd.` : n.toLocaleString("de-DE");
|
||||
}
|
||||
|
||||
/** Warum ein Lauf nicht voll bestanden hat, in einem Satz. Leer bei bestandenen Läufen. */
|
||||
export function failureReason(r: { error_class: string; score: number; check_output: string; summary: string | null }): string {
|
||||
if (r.error_class === "ok") return "";
|
||||
if (r.error_class === "check_failed") {
|
||||
// `check.sh` darf als letzte Zeile {"score": …, "notes": "…"} schreiben.
|
||||
const last = r.check_output.split("\n").map((l) => l.trim()).filter(Boolean).pop() ?? "";
|
||||
try {
|
||||
const j = JSON.parse(last);
|
||||
if (j && typeof j.notes === "string" && j.notes) return j.notes;
|
||||
} catch {
|
||||
// keine JSON-Zeile
|
||||
}
|
||||
const lines = r.check_output.split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("exit "));
|
||||
return lines.length > 0 ? lines.slice(-2).join(" ") : "Die Prüfung ist fehlgeschlagen.";
|
||||
}
|
||||
return errorLabel(r.error_class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user