Anbieter statt Modelle: Benchmark wählt 1. Anbieter, 2. Modelle aus der Server-Liste, 3. Aufgaben; Konfiguration mit Migration, Auswahl wird gemerkt
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -10,27 +10,32 @@
|
||||
pctColor,
|
||||
type BatchEvent,
|
||||
type LoadReport,
|
||||
type ModelInfo,
|
||||
modelLabel,
|
||||
type Paths,
|
||||
type ProviderInfo,
|
||||
type Selection,
|
||||
type Ranking,
|
||||
type TaskInfo,
|
||||
} from "$lib/api";
|
||||
|
||||
let {
|
||||
models,
|
||||
providers,
|
||||
tasks,
|
||||
paths,
|
||||
ongotosettings,
|
||||
onfinished,
|
||||
}: {
|
||||
models: ModelInfo[];
|
||||
providers: ProviderInfo[];
|
||||
tasks: LoadReport | null;
|
||||
paths: Paths | null;
|
||||
ongotosettings: () => void;
|
||||
onfinished: (batchId: number) => void;
|
||||
} = $props();
|
||||
|
||||
let chosenModels = $state<string[]>([]);
|
||||
// Auswahl: erst Anbieter, dann Modelle dieser Anbieter. Ein Lauf-Modell ist Anbieter plus Modell-ID.
|
||||
let chosenProviders = $state<string[]>([]);
|
||||
let chosenModels = $state<Selection[]>([]);
|
||||
let modelLabels = $derived(chosenModels.map((m) => modelLabel(m.provider, m.model)));
|
||||
let chosenTasks = $state<string[]>([]);
|
||||
let repeats = $state(1);
|
||||
let running = $state(false);
|
||||
@ -61,7 +66,104 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Modelle je Anbieter, vom Server geholt (nur die Liste, es wird nichts geladen).
|
||||
type Reach = { state: "prüft" | "ok" | "fehler"; models: string[]; message: string };
|
||||
let reach = $state<Record<string, Reach>>({});
|
||||
let filters = $state<Record<string, string>>({});
|
||||
let manual = $state<Record<string, string>>({});
|
||||
const SHOW_MAX = 60;
|
||||
|
||||
async function loadModels(p: ProviderInfo) {
|
||||
reach[p.name] = { state: "prüft", models: reach[p.name]?.models ?? [], message: "" };
|
||||
try {
|
||||
const list = await api.discoverModels(p.adapter, p.url, p.api_key_env, p.name, null);
|
||||
reach[p.name] = { state: "ok", models: list, message: "" };
|
||||
} catch (e) {
|
||||
reach[p.name] = { state: "fehler", models: [], message: String(e) };
|
||||
}
|
||||
}
|
||||
|
||||
const STORE_KEY = "cb.auswahl";
|
||||
|
||||
function saveChoice() {
|
||||
try {
|
||||
localStorage.setItem(STORE_KEY, JSON.stringify({ providers: chosenProviders, models: chosenModels, tasks: chosenTasks, repeats }));
|
||||
} catch {
|
||||
// Ohne Speicher bleibt die Auswahl nur für diese Sitzung.
|
||||
}
|
||||
}
|
||||
|
||||
function restoreChoice() {
|
||||
try {
|
||||
const raw = JSON.parse(localStorage.getItem(STORE_KEY) ?? "null");
|
||||
if (!raw) return;
|
||||
const names = providers.map((p) => p.name);
|
||||
chosenProviders = (raw.providers ?? []).filter((n: string) => names.includes(n));
|
||||
chosenModels = (raw.models ?? []).filter((m: Selection) => chosenProviders.includes(m.provider));
|
||||
if (Number.isInteger(raw.repeats) && raw.repeats >= 1) repeats = raw.repeats;
|
||||
const ids = (tasks?.tasks ?? []).map((t) => t.id);
|
||||
if (ids.length > 0) chosenTasks = (raw.tasks ?? []).filter((id: string) => ids.includes(id));
|
||||
} catch {
|
||||
// Beschädigte Auswahl wird ignoriert.
|
||||
}
|
||||
}
|
||||
|
||||
function toggleProvider(p: ProviderInfo) {
|
||||
if (chosenProviders.includes(p.name)) {
|
||||
chosenProviders = chosenProviders.filter((n) => n !== p.name);
|
||||
chosenModels = chosenModels.filter((m) => m.provider !== p.name);
|
||||
} else {
|
||||
chosenProviders = [...chosenProviders, p.name];
|
||||
if (!reach[p.name]) loadModels(p);
|
||||
}
|
||||
}
|
||||
|
||||
function allProviders(on: boolean) {
|
||||
for (const p of providers) {
|
||||
if (on !== chosenProviders.includes(p.name)) toggleProvider(p);
|
||||
}
|
||||
}
|
||||
|
||||
function isChosen(provider: string, model: string): boolean {
|
||||
return chosenModels.some((m) => m.provider === provider && m.model === model);
|
||||
}
|
||||
|
||||
function toggleModel(provider: string, model: string) {
|
||||
chosenModels = isChosen(provider, model)
|
||||
? chosenModels.filter((m) => !(m.provider === provider && m.model === model))
|
||||
: [...chosenModels, { provider, model }];
|
||||
}
|
||||
|
||||
function addManual(provider: string) {
|
||||
const id = (manual[provider] ?? "").trim();
|
||||
if (!id) return;
|
||||
if (!isChosen(provider, id)) chosenModels = [...chosenModels, { provider, model: id }];
|
||||
manual[provider] = "";
|
||||
}
|
||||
|
||||
// Liste eines Anbieters: gewählte zuerst, dann die Treffer des Filters.
|
||||
function visibleModels(provider: string): string[] {
|
||||
const all = reach[provider]?.models ?? [];
|
||||
const f = (filters[provider] ?? "").trim().toLowerCase();
|
||||
const hits = f ? all.filter((n) => n.toLowerCase().includes(f)) : all;
|
||||
const picked = chosenModels.filter((m) => m.provider === provider).map((m) => m.model);
|
||||
return [...picked, ...hits.filter((n) => !picked.includes(n))];
|
||||
}
|
||||
|
||||
// Zuerst die gemerkte Auswahl laden, sonst überschriebe der Merk-Effekt sie mit leeren Werten.
|
||||
restoreChoice();
|
||||
|
||||
$effect(() => {
|
||||
// Auswahl merken, sobald sie sich ändert.
|
||||
chosenProviders;
|
||||
chosenModels;
|
||||
chosenTasks;
|
||||
repeats;
|
||||
saveChoice();
|
||||
});
|
||||
|
||||
onMount(async () => {
|
||||
for (const p of providers.filter((p) => chosenProviders.includes(p.name))) loadModels(p);
|
||||
loadLast();
|
||||
unlisten = await listen<BatchEvent>("batch-event", (ev) => onEvent(ev.payload));
|
||||
});
|
||||
@ -128,10 +230,6 @@
|
||||
chosenTasks = on ? [...new Set([...chosenTasks, ...ids])] : chosenTasks.filter((id) => !ids.includes(id));
|
||||
}
|
||||
|
||||
function allModels(on: boolean) {
|
||||
chosenModels = on ? models.map((m) => m.name) : [];
|
||||
}
|
||||
|
||||
function lastTask(id: string): { models: number; mean: number } | null {
|
||||
const cs = last?.cells.filter((c) => c.task_id === id) ?? [];
|
||||
if (cs.length === 0) return null;
|
||||
@ -147,16 +245,16 @@
|
||||
return last?.models.find((m) => m.model === model) ?? null;
|
||||
}
|
||||
|
||||
let totalRuns = $derived(chosenModels.length * chosenTasks.length * repeats);
|
||||
let totalRuns = $derived(modelLabels.length * chosenTasks.length * repeats);
|
||||
let canStart = $derived(!running && chosenModels.length > 0 && chosenTasks.length > 0 && repeats >= 1);
|
||||
|
||||
// Geschätzte Dauer aus den Median-Laufzeiten früherer Läufe. Fehlt ein Modell, zählt der Schnitt der übrigen.
|
||||
let estimate = $derived.by(() => {
|
||||
const known = chosenModels.map((m) => lastRank(m)?.median_duration_ms).filter((x): x is number => typeof x === "number" && x > 0);
|
||||
const known = modelLabels.map((m) => lastRank(m)?.median_duration_ms).filter((x): x is number => typeof x === "number" && x > 0);
|
||||
if (known.length === 0 || totalRuns === 0) return null;
|
||||
const avg = known.reduce((a, b) => a + b, 0) / known.length;
|
||||
const ms = chosenModels.reduce((sum, m) => sum + (lastRank(m)?.median_duration_ms || avg) * chosenTasks.length * repeats, 0);
|
||||
return { minutes: Math.max(1, Math.round(ms / 60000)), basis: known.length, of: chosenModels.length };
|
||||
const ms = modelLabels.reduce((sum, m) => sum + (lastRank(m)?.median_duration_ms || avg) * chosenTasks.length * repeats, 0);
|
||||
return { minutes: Math.max(1, Math.round(ms / 60000)), basis: known.length, of: modelLabels.length };
|
||||
});
|
||||
|
||||
function chosenTaskInfos(): TaskInfo[] {
|
||||
@ -170,7 +268,7 @@
|
||||
finishedBatch = null;
|
||||
cancelled = false;
|
||||
cells = {};
|
||||
for (const m of chosenModels) for (const t of chosenTaskInfos()) cells[key(m, t.id)] = { state: "planned", n: 0, sum: 0, cls: "" };
|
||||
for (const m of modelLabels) for (const t of chosenTaskInfos()) cells[key(m, t.id)] = { state: "planned", n: 0, sum: 0, cls: "" };
|
||||
running = true;
|
||||
try {
|
||||
const s = await api.startBatch($state.snapshot(chosenModels), $state.snapshot(chosenTasks), repeats, "", resumeBatch);
|
||||
@ -194,44 +292,41 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if models.length === 0}
|
||||
{#if providers.length === 0}
|
||||
<section class="card empty">
|
||||
<h2>Noch kein Modell angebunden</h2>
|
||||
<p class="muted">Bevor ein Benchmark laufen kann, braucht coding-bench mindestens ein Modell.</p>
|
||||
<h2>Noch kein Anbieter angebunden</h2>
|
||||
<p class="muted">Bevor ein Benchmark laufen kann, braucht coding-bench mindestens einen Anbieter, also einen Server mit Modellen.</p>
|
||||
<ol class="muted steps">
|
||||
<li>Modell mit Adapter und Server-URL anlegen</li>
|
||||
<li>Anbieter anlegen (Ollama, Ollama Cloud, OpenRouter …) und bei Bedarf den API-Schlüssel eingeben</li>
|
||||
<li>Container-Image bauen (einmalig)</li>
|
||||
<li>Hier Modelle und Aufgaben wählen und starten</li>
|
||||
<li>Hier Anbieter, Modelle und Aufgaben wählen und starten</li>
|
||||
</ol>
|
||||
<button class="primary" onclick={ongotosettings}>Modell in den Einstellungen anlegen</button>
|
||||
<button class="primary" onclick={ongotosettings}>Anbieter in den Einstellungen anlegen</button>
|
||||
</section>
|
||||
{:else}
|
||||
<section class="card">
|
||||
<div class="head">
|
||||
<h2>1. Modelle</h2>
|
||||
<button class="link" disabled={running} onclick={() => allModels(true)}>alle</button>
|
||||
<button class="link" disabled={running} onclick={() => allModels(false)}>keine</button>
|
||||
<h2>1. Anbieter</h2>
|
||||
<button class="link" disabled={running} onclick={() => allProviders(true)}>alle</button>
|
||||
<button class="link" disabled={running} onclick={() => allProviders(false)}>keine</button>
|
||||
</div>
|
||||
<div class="model-grid">
|
||||
{#each models as m (m.name)}
|
||||
{@const r = lastRank(m.name)}
|
||||
<label class="mcard" class:on={chosenModels.includes(m.name)}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={chosenModels.includes(m.name)}
|
||||
disabled={running}
|
||||
onchange={() => (chosenModels = toggle(chosenModels, m.name))}
|
||||
/>
|
||||
{#each providers as p (p.name)}
|
||||
{@const r = reach[p.name]}
|
||||
<label class="mcard" class:on={chosenProviders.includes(p.name)}>
|
||||
<input type="checkbox" checked={chosenProviders.includes(p.name)} disabled={running} onchange={() => toggleProvider(p)} />
|
||||
<span class="mtext">
|
||||
<strong>{m.name}</strong>
|
||||
<span class="muted small">{m.adapter === "ollama" ? "Ollama" : "OpenAI-kompatibel"} · {m.url}</span>
|
||||
{#if r}
|
||||
<span class="small" style:color={pctColor(r.total_percent)}>zuletzt {fmtPct(r.total_percent)} gesamt</span>
|
||||
{:else}
|
||||
<span class="muted small">noch nicht gemessen</span>
|
||||
<strong>{p.name}</strong>
|
||||
<span class="muted small">{p.adapter === "ollama" ? "Ollama" : "OpenAI-kompatibel"} · {p.url}</span>
|
||||
{#if r?.state === "ok"}
|
||||
<span class="ok small">erreichbar, {r.models.length} Modelle</span>
|
||||
{:else if r?.state === "fehler"}
|
||||
<span class="error small" title={r.message}>nicht erreichbar</span>
|
||||
{:else if r?.state === "prüft"}
|
||||
<span class="muted small">prüfe …</span>
|
||||
{/if}
|
||||
{#if m.api_key_env && !m.api_key_set}
|
||||
<span class="error small">Schlüssel-Variable {m.api_key_env} nicht gesetzt</span>
|
||||
{#if p.api_key_env && !p.api_key_set}
|
||||
<span class="error small">Schlüssel-Variable {p.api_key_env} nicht gesetzt</span>
|
||||
{/if}
|
||||
</span>
|
||||
</label>
|
||||
@ -240,7 +335,71 @@
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2>2. Aufgaben</h2>
|
||||
<h2>2. Modelle</h2>
|
||||
{#if chosenProviders.length === 0}
|
||||
<p class="muted">Wähle oben einen Anbieter. Dann erscheinen hier seine Modelle zur Auswahl.</p>
|
||||
{/if}
|
||||
{#each providers.filter((p) => chosenProviders.includes(p.name)) as p (p.name)}
|
||||
{@const r = reach[p.name]}
|
||||
{@const list = visibleModels(p.name)}
|
||||
{@const picked = chosenModels.filter((m) => m.provider === p.name).length}
|
||||
<div class="pgroup">
|
||||
<div class="head">
|
||||
<h3>{p.name} <span class="muted">({picked} gewählt)</span></h3>
|
||||
<button class="link" disabled={running} onclick={() => loadModels(p)}>neu laden</button>
|
||||
</div>
|
||||
{#if r?.state === "prüft"}
|
||||
<p class="muted small">Frage den Server nach seinen Modellen …</p>
|
||||
{:else if r?.state === "fehler"}
|
||||
<p class="error small">Modell-Liste nicht abrufbar: {r.message}</p>
|
||||
{/if}
|
||||
{#if (r?.models.length ?? 0) > 0}
|
||||
<input
|
||||
class="filter"
|
||||
bind:value={filters[p.name]}
|
||||
placeholder="Filtern, z. B. qwen oder gpt-oss ({r?.models.length} Modelle)"
|
||||
disabled={running}
|
||||
/>
|
||||
<ul class="mlist">
|
||||
{#each list.slice(0, SHOW_MAX) as name (name)}
|
||||
<li>
|
||||
<label class="mrow" class:on={isChosen(p.name, name)}>
|
||||
<input type="checkbox" checked={isChosen(p.name, name)} disabled={running} onchange={() => toggleModel(p.name, name)} />
|
||||
<span class="mono">{name}</span>
|
||||
{#if lastRank(modelLabel(p.name, name))}
|
||||
{@const lr = lastRank(modelLabel(p.name, name))}
|
||||
<span class="small" style:color={pctColor(lr!.total_percent)}>zuletzt {fmtPct(lr!.total_percent)}</span>
|
||||
{/if}
|
||||
</label>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{#if list.length > SHOW_MAX}
|
||||
<p class="muted small">{list.length - SHOW_MAX} weitere. Filter eingrenzen.</p>
|
||||
{:else if list.length === 0}
|
||||
<p class="muted small">Kein Treffer.</p>
|
||||
{/if}
|
||||
{/if}
|
||||
<div class="manual">
|
||||
<input
|
||||
bind:value={manual[p.name]}
|
||||
placeholder="Modell-ID von Hand eintragen"
|
||||
disabled={running}
|
||||
onkeydown={(e) => e.key === "Enter" && addManual(p.name)}
|
||||
/>
|
||||
<button disabled={running || !(manual[p.name] ?? "").trim()} onclick={() => addManual(p.name)}>hinzufügen</button>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
{#if chosenModels.length > 0}
|
||||
<p class="muted small chosen">
|
||||
Gewählt: {modelLabels.join(", ")}
|
||||
</p>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2>3. Aufgaben</h2>
|
||||
{#if !tasks}
|
||||
<p class="muted">Lade Aufgaben …</p>
|
||||
{:else if tasks.tasks.length === 0}
|
||||
@ -321,7 +480,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each chosenModels as m (m)}
|
||||
{#each modelLabels as m (m)}
|
||||
<tr>
|
||||
<td>{m}</td>
|
||||
{#each chosenTaskInfos() as t (t.id)}
|
||||
@ -381,7 +540,7 @@
|
||||
<div class="summary">
|
||||
{#if totalRuns > 0}
|
||||
<strong>{totalRuns} Läufe</strong>
|
||||
<span class="muted">{chosenModels.length} Modell(e) × {chosenTasks.length} Aufgabe(n) × {repeats}</span>
|
||||
<span class="muted">{modelLabels.length} Modell(e) × {chosenTasks.length} Aufgabe(n) × {repeats}</span>
|
||||
{#if estimate}
|
||||
<span class="muted" title="Median-Laufzeit früherer Läufe, {estimate.basis} von {estimate.of} Modellen gemessen">
|
||||
≈ {estimate.minutes} min
|
||||
@ -481,6 +640,59 @@
|
||||
.group {
|
||||
margin-bottom: 1.1rem;
|
||||
}
|
||||
.pgroup {
|
||||
border-top: 1px solid var(--border);
|
||||
padding-top: 0.8rem;
|
||||
margin-top: 0.8rem;
|
||||
}
|
||||
.pgroup:first-of-type {
|
||||
border-top: none;
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
.filter {
|
||||
width: 100%;
|
||||
color: var(--text);
|
||||
}
|
||||
.mlist {
|
||||
list-style: none;
|
||||
margin: 0.5rem 0 0;
|
||||
padding: 0;
|
||||
max-height: 15rem;
|
||||
overflow-y: auto;
|
||||
display: grid;
|
||||
gap: 0.1rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
background: var(--bg);
|
||||
}
|
||||
.mrow {
|
||||
display: flex;
|
||||
gap: 0.6rem;
|
||||
align-items: baseline;
|
||||
padding: 0.25rem 0.6rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.mrow.on {
|
||||
background: var(--accent-soft);
|
||||
}
|
||||
.mono {
|
||||
font-family: ui-monospace, Menlo, monospace;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
.manual {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin-top: 0.6rem;
|
||||
}
|
||||
.manual input {
|
||||
flex: 1;
|
||||
color: var(--text);
|
||||
}
|
||||
.chosen {
|
||||
margin: 0.8rem 0 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.gbadge {
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
|
||||
@ -4,24 +4,24 @@
|
||||
import {
|
||||
api,
|
||||
type ImageStatus,
|
||||
type ModelEntry,
|
||||
type ModelInput,
|
||||
type ModelInfo,
|
||||
type ModelTest,
|
||||
type Paths,
|
||||
type ProviderEntry,
|
||||
type ProviderInfo,
|
||||
type ProviderInput,
|
||||
type RuntimeStatus,
|
||||
} from "$lib/api";
|
||||
|
||||
let {
|
||||
models,
|
||||
providers,
|
||||
paths,
|
||||
runtime,
|
||||
onsaved,
|
||||
}: {
|
||||
models: ModelInfo[];
|
||||
providers: ProviderInfo[];
|
||||
paths: Paths | null;
|
||||
runtime: RuntimeStatus | null;
|
||||
onsaved: (m: ModelInfo[]) => void;
|
||||
onsaved: (p: ProviderInfo[]) => void;
|
||||
} = $props();
|
||||
|
||||
const ADAPTERS = [
|
||||
@ -29,29 +29,27 @@
|
||||
{ id: "openai", label: "OpenAI-kompatibel", hint: "http://host:8082/v1 oder https://openrouter.ai/api/v1" },
|
||||
];
|
||||
|
||||
// Bearbeitungsstand eines Modells. Der Schlüssel liegt nur hier im Speicher, bis man speichert.
|
||||
type Draft = ModelEntry & { previous_name: string | null; api_key: string; stored: boolean; clear_key: boolean };
|
||||
// Bearbeitungsstand eines Anbieters. Der Schlüssel liegt nur hier im Speicher, bis man speichert.
|
||||
type Draft = ProviderEntry & { previous_name: string | null; api_key: string; stored: boolean; clear_key: boolean };
|
||||
|
||||
function toEntry(m: ModelInfo): Draft {
|
||||
function toDraft(p: ProviderInfo): Draft {
|
||||
return {
|
||||
name: m.name,
|
||||
adapter: m.adapter,
|
||||
url: m.url,
|
||||
model: m.model,
|
||||
api_key_env: m.api_key_env,
|
||||
previous_name: m.name,
|
||||
name: p.name,
|
||||
adapter: p.adapter,
|
||||
url: p.url,
|
||||
api_key_env: p.api_key_env,
|
||||
previous_name: p.name,
|
||||
api_key: "",
|
||||
stored: m.api_key_stored,
|
||||
stored: p.api_key_stored,
|
||||
clear_key: false,
|
||||
};
|
||||
}
|
||||
|
||||
function toInput(d: Draft): ModelInput {
|
||||
function toInput(d: Draft): ProviderInput {
|
||||
return {
|
||||
name: d.name,
|
||||
adapter: d.adapter,
|
||||
url: d.url,
|
||||
model: d.model,
|
||||
api_key_env: d.api_key_env,
|
||||
previous_name: d.previous_name,
|
||||
api_key: d.api_key.trim() ? d.api_key : null,
|
||||
@ -61,26 +59,27 @@
|
||||
|
||||
// Bearbeitungsstand: Kopie beim Öffnen, bewusst vom Original gelöst. Gilt erst nach „Speichern“.
|
||||
// svelte-ignore state_referenced_locally
|
||||
let draft = $state<Draft[]>(models.map(toEntry));
|
||||
let draft = $state<Draft[]>(providers.map(toDraft));
|
||||
let dirty = $state(false);
|
||||
let saveError = $state("");
|
||||
let saving = $state(false);
|
||||
let tests = $state<Record<string, ModelTest | "läuft">>({});
|
||||
let tests = $state<Record<number, ModelTest | "läuft">>({});
|
||||
let testModelId = $state<Record<number, string>>({});
|
||||
|
||||
function markDirty() {
|
||||
dirty = true;
|
||||
saveError = "";
|
||||
}
|
||||
|
||||
// Vorlagen für häufige Anbieter. Der Schlüssel bleibt eine Umgebungsvariable.
|
||||
const PRESETS: Record<string, ModelEntry> = {
|
||||
ollama: { name: "Ollama lokal", adapter: "ollama", url: "http://127.0.0.1:11434", model: "", api_key_env: "" },
|
||||
ollamacloud: { name: "Ollama Cloud", adapter: "ollama", url: "https://ollama.com", model: "", api_key_env: "" },
|
||||
openrouter: { name: "OpenRouter", adapter: "openai", url: "https://openrouter.ai/api/v1", model: "", api_key_env: "" },
|
||||
openai: { name: "OpenAI-kompatibel", adapter: "openai", url: "", model: "", api_key_env: "" },
|
||||
// Vorlagen für häufige Anbieter. Der Schlüssel wird danach in der App eingegeben.
|
||||
const PRESETS: Record<string, ProviderEntry> = {
|
||||
ollama: { name: "Ollama lokal", adapter: "ollama", url: "http://127.0.0.1:11434", api_key_env: "" },
|
||||
ollamacloud: { name: "Ollama Cloud", adapter: "ollama", url: "https://ollama.com", api_key_env: "" },
|
||||
openrouter: { name: "OpenRouter", adapter: "openai", url: "https://openrouter.ai/api/v1", api_key_env: "" },
|
||||
openai: { name: "OpenAI-kompatibel", adapter: "openai", url: "", api_key_env: "" },
|
||||
};
|
||||
|
||||
function addModel(preset = "ollama") {
|
||||
function addProvider(preset = "ollama") {
|
||||
draft.push({ ...PRESETS[preset], previous_name: null, api_key: "", stored: false, clear_key: false });
|
||||
const i = draft.length - 1;
|
||||
open = [...open, i];
|
||||
@ -88,31 +87,7 @@
|
||||
if (draft[i].url) check(i);
|
||||
}
|
||||
|
||||
// Modellauswahl aus der Liste des Servers.
|
||||
let picking = $state<number | null>(null);
|
||||
let filter = $state("");
|
||||
const SHOW_MAX = 60;
|
||||
|
||||
function pickList(i: number): string[] {
|
||||
const all = reach[i]?.models ?? [];
|
||||
const f = filter.trim().toLowerCase();
|
||||
return f ? all.filter((n) => n.toLowerCase().includes(f)) : all;
|
||||
}
|
||||
|
||||
function choose(i: number, name: string) {
|
||||
draft[i].model = name;
|
||||
picking = null;
|
||||
filter = "";
|
||||
markDirty();
|
||||
}
|
||||
|
||||
async function startPick(i: number) {
|
||||
picking = picking === i ? null : i;
|
||||
filter = "";
|
||||
if (picking === i && !reach[i]?.models.length) await check(i);
|
||||
}
|
||||
|
||||
function removeModel(i: number) {
|
||||
function removeProvider(i: number) {
|
||||
draft.splice(i, 1);
|
||||
reach = {};
|
||||
open = [];
|
||||
@ -128,8 +103,8 @@
|
||||
saving = true;
|
||||
saveError = "";
|
||||
try {
|
||||
const saved = await api.saveModels($state.snapshot(draft).map(toInput));
|
||||
draft = saved.map(toEntry);
|
||||
const saved = await api.saveProviders($state.snapshot(draft).map(toInput));
|
||||
draft = saved.map(toDraft);
|
||||
dirty = false;
|
||||
onsaved(saved);
|
||||
draft.forEach((_, k) => check(k));
|
||||
@ -140,19 +115,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function test(name: string) {
|
||||
tests[name] = "läuft";
|
||||
async function test(i: number) {
|
||||
tests[i] = "läuft";
|
||||
try {
|
||||
tests[name] = await api.testModel(name);
|
||||
tests[i] = await api.testModel(draft[i].name, testModelId[i] ?? "");
|
||||
} catch (e) {
|
||||
tests[name] = { ok: false, duration_ms: 0, message: String(e) };
|
||||
tests[i] = { ok: false, duration_ms: 0, message: String(e) };
|
||||
}
|
||||
}
|
||||
|
||||
function savedInfo(name: string): ModelInfo | undefined {
|
||||
return models.find((m) => m.name === name);
|
||||
function savedInfo(name: string): ProviderInfo | undefined {
|
||||
return providers.find((p) => p.name === name);
|
||||
}
|
||||
|
||||
// Container-Images: Zustand, Bauen auf Knopfdruck, Ausgabe live.
|
||||
|
||||
|
||||
let images = $state<ImageStatus[]>([]);
|
||||
let imagesError = $state("");
|
||||
let building = $state<string | null>(null);
|
||||
@ -205,20 +183,18 @@
|
||||
todo: "Unten das Image bauen.",
|
||||
},
|
||||
{
|
||||
ok: models.length > 0,
|
||||
label: models.length > 0 ? `${models.length} Modell(e) angelegt` : "Noch kein Modell angelegt",
|
||||
todo: "Ein Modell hinzufügen und speichern.",
|
||||
ok: providers.length > 0,
|
||||
label: providers.length > 0 ? `${providers.length} Anbieter angelegt` : "Noch kein Anbieter angelegt",
|
||||
todo: "Einen Anbieter hinzufügen und speichern.",
|
||||
},
|
||||
{
|
||||
ok: anyReachable,
|
||||
label: anyReachable ? "Mindestens ein Server antwortet" : "Kein Server geprüft oder erreichbar",
|
||||
todo: "Server-URL prüfen. Ist der Server an?",
|
||||
todo: "Server-URL und Schlüssel prüfen. Ist der Server an?",
|
||||
},
|
||||
]);
|
||||
let ready = $derived(checks.every((c) => c.ok));
|
||||
|
||||
// Container-Images: Zustand, Bauen auf Knopfdruck, Ausgabe live.
|
||||
|
||||
async function loadImages() {
|
||||
try {
|
||||
images = await api.imageStatus();
|
||||
@ -270,14 +246,15 @@
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2>Modelle</h2>
|
||||
<h2>Anbieter</h2>
|
||||
<p class="muted">
|
||||
Jedes Modell hat einen Adapter. Er bestimmt, wie coding-bench mit dem Server spricht. Einen API-Schlüssel gibst du hier
|
||||
direkt ein. Er wird getrennt von der Konfiguration auf diesem Rechner gespeichert und nie angezeigt oder weitergegeben.
|
||||
Ein Anbieter ist ein Server mit Adapter, Adresse und optional einem API-Schlüssel, zum Beispiel Ollama lokal, Ollama
|
||||
Cloud oder OpenRouter. Welche Modelle du dort testest, wählst du später im Reiter „Benchmark“. Den Schlüssel gibst du
|
||||
hier direkt ein. Er wird getrennt von der Konfiguration auf diesem Rechner gespeichert und nie angezeigt oder weitergegeben.
|
||||
</p>
|
||||
|
||||
{#if draft.length === 0}
|
||||
<p class="muted">Noch kein Modell angebunden.</p>
|
||||
<p class="muted">Noch kein Anbieter angebunden.</p>
|
||||
{/if}
|
||||
|
||||
{#each draft as m, i (i)}
|
||||
@ -286,11 +263,11 @@
|
||||
<div class="model" class:open={isOpen}>
|
||||
<button class="mhead" onclick={() => toggleOpen(i)} aria-expanded={isOpen}>
|
||||
<span class="dot {r?.state ?? 'unbekannt'}" title={r?.message || "noch nicht geprüft"}></span>
|
||||
<strong>{m.name || "Neues Modell"}</strong>
|
||||
<strong>{m.name || "Neuer Anbieter"}</strong>
|
||||
<span class="muted small">{ADAPTERS.find((a) => a.id === m.adapter)?.label} · {m.url || "keine URL"}</span>
|
||||
<span class="spacer"></span>
|
||||
<span class="muted small">
|
||||
{r?.state === "ok" ? "erreichbar" : r?.state === "fehler" ? "nicht erreichbar" : r?.state === "prüft" ? "prüfe …" : ""}
|
||||
{r?.state === "ok" ? `erreichbar, ${r.models.length} Modelle` : r?.state === "fehler" ? "nicht erreichbar" : r?.state === "prüft" ? "prüfe …" : ""}
|
||||
</span>
|
||||
<span class="chev">{isOpen ? "▾" : "▸"}</span>
|
||||
</button>
|
||||
@ -299,7 +276,7 @@
|
||||
<div class="grid">
|
||||
<label>
|
||||
Name
|
||||
<input bind:value={m.name} oninput={markDirty} placeholder="z. B. Qwen3 lokal" />
|
||||
<input bind:value={m.name} oninput={markDirty} placeholder="z. B. Ollama Cloud" />
|
||||
</label>
|
||||
<label>
|
||||
Adapter
|
||||
@ -313,13 +290,6 @@
|
||||
Server-URL
|
||||
<input bind:value={m.url} oninput={markDirty} onchange={() => check(i)} placeholder={hintFor(m.adapter)} />
|
||||
</label>
|
||||
<label>
|
||||
Modell-ID beim Server
|
||||
<span class="idrow">
|
||||
<input bind:value={m.model} oninput={markDirty} placeholder="leer = Name" />
|
||||
<button type="button" onclick={() => startPick(i)}>{picking === i ? "Liste schließen" : "Aus Liste wählen"}</button>
|
||||
</span>
|
||||
</label>
|
||||
<label class="wide">
|
||||
API-Schlüssel
|
||||
<span class="idrow">
|
||||
@ -366,30 +336,7 @@
|
||||
<input bind:value={m.api_key_env} oninput={markDirty} placeholder="z. B. OLLAMA_API_KEY, leer = nicht nutzen" />
|
||||
</label>
|
||||
</div>
|
||||
{#if picking === i}
|
||||
<div class="picker">
|
||||
{#if r?.state === "prüft"}
|
||||
<p class="muted small">Frage den Server …</p>
|
||||
{:else if r?.state === "fehler"}
|
||||
<p class="error small">{r.message}</p>
|
||||
{:else}
|
||||
<input bind:value={filter} placeholder="Filtern, z. B. qwen oder gpt-oss ({r?.models.length ?? 0} Modelle)" />
|
||||
{@const list = pickList(i)}
|
||||
<ul>
|
||||
{#each list.slice(0, SHOW_MAX) as name (name)}
|
||||
<li><button type="button" class:sel={name === m.model} onclick={() => choose(i, name)}>{name}</button></li>
|
||||
{/each}
|
||||
</ul>
|
||||
{#if list.length > SHOW_MAX}
|
||||
<p class="muted small">{list.length - SHOW_MAX} weitere. Filter eingrenzen.</p>
|
||||
{:else if list.length === 0}
|
||||
<p class="muted small">Kein Treffer.</p>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{:else if r?.state === "fehler"}
|
||||
<p class="error small">{r.message}</p>
|
||||
{/if}
|
||||
{#if r?.state === "fehler"}<p class="error small">{r.message}</p>{/if}
|
||||
<div class="row">
|
||||
{#if m.api_key_env && savedInfo(m.name) && !savedInfo(m.name)?.api_key_set}
|
||||
<span class="chip error" title="Die App sieht nur Variablen, die beim Start gesetzt waren">
|
||||
@ -397,24 +344,38 @@
|
||||
</span>
|
||||
{/if}
|
||||
<span class="spacer"></span>
|
||||
{#if tests[m.name] === "läuft"}
|
||||
{#if tests[i] === "läuft"}
|
||||
<span class="muted">teste …</span>
|
||||
{:else if tests[m.name]}
|
||||
{@const t = tests[m.name] as ModelTest}
|
||||
{:else if tests[i]}
|
||||
{@const t = tests[i] as ModelTest}
|
||||
<span class={t.ok ? "ok" : "error"}>
|
||||
{t.ok ? "Antwort ok" : "Fehler"}: {t.message}
|
||||
{#if t.duration_ms}({(t.duration_ms / 1000).toFixed(1)} s){/if}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="testmodel">
|
||||
Modell für den Antwort-Test
|
||||
<input
|
||||
bind:value={testModelId[i]}
|
||||
list={`test-models-${i}`}
|
||||
placeholder={r?.models.length ? "aus der Liste wählen oder tippen" : "Modell-ID tippen"}
|
||||
/>
|
||||
<datalist id={`test-models-${i}`}>
|
||||
{#each (r?.models ?? []).slice(0, 300) as name (name)}<option value={name}></option>{/each}
|
||||
</datalist>
|
||||
</label>
|
||||
<span class="spacer"></span>
|
||||
<button onclick={() => check(i)}>Server prüfen</button>
|
||||
<button
|
||||
onclick={() => test(m.name)}
|
||||
disabled={dirty || !savedInfo(m.name)}
|
||||
onclick={() => test(i)}
|
||||
disabled={dirty || !savedInfo(m.name) || !(testModelId[i] ?? "").trim()}
|
||||
title={dirty ? "Erst speichern" : "Schickt eine kurze Frage an das Modell und lädt es dabei"}
|
||||
>
|
||||
Antwort testen
|
||||
</button>
|
||||
<button class="danger" onclick={() => removeModel(i)}>Entfernen</button>
|
||||
<button class="danger" onclick={() => removeProvider(i)}>Entfernen</button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@ -422,10 +383,10 @@
|
||||
|
||||
<div class="row">
|
||||
<span class="muted small">Hinzufügen:</span>
|
||||
<button onclick={() => addModel("ollama")}>Ollama lokal</button>
|
||||
<button onclick={() => addModel("ollamacloud")}>Ollama Cloud</button>
|
||||
<button onclick={() => addModel("openrouter")}>OpenRouter</button>
|
||||
<button onclick={() => addModel("openai")}>Anderer OpenAI-Server</button>
|
||||
<button onclick={() => addProvider("ollama")}>Ollama lokal</button>
|
||||
<button onclick={() => addProvider("ollamacloud")}>Ollama Cloud</button>
|
||||
<button onclick={() => addProvider("openrouter")}>OpenRouter</button>
|
||||
<button onclick={() => addProvider("openai")}>Anderer OpenAI-Server</button>
|
||||
<span class="spacer"></span>
|
||||
{#if saveError}<span class="error">{saveError}</span>{/if}
|
||||
{#if dirty}<span class="muted">Ungespeicherte Änderungen</span>{/if}
|
||||
@ -524,39 +485,6 @@
|
||||
.idrow input {
|
||||
flex: 1;
|
||||
}
|
||||
.picker {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
background: var(--bg);
|
||||
padding: 0.6rem;
|
||||
margin-top: 0.6rem;
|
||||
}
|
||||
.picker ul {
|
||||
list-style: none;
|
||||
margin: 0.5rem 0 0;
|
||||
padding: 0;
|
||||
max-height: 14rem;
|
||||
overflow-y: auto;
|
||||
display: grid;
|
||||
gap: 0.15rem;
|
||||
}
|
||||
.picker li button {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
border: none;
|
||||
background: none;
|
||||
padding: 0.3rem 0.5rem;
|
||||
font-family: ui-monospace, Menlo, monospace;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
.picker li button:hover,
|
||||
.picker li button.sel {
|
||||
background: var(--accent-soft);
|
||||
}
|
||||
.picker > input {
|
||||
width: 100%;
|
||||
color: var(--text);
|
||||
}
|
||||
.chev {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@ -17,16 +17,22 @@ export type TaskInfo = {
|
||||
export type TaskError = { dir: string; message: string };
|
||||
export type LoadReport = { tasks: TaskInfo[]; errors: TaskError[] };
|
||||
|
||||
export type ModelEntry = {
|
||||
/** Ein Anbieter: Server mit Adapter, Adresse und optionalem Schlüssel. Die Modelle holt man sich beim Server. */
|
||||
export type ProviderEntry = {
|
||||
name: string;
|
||||
adapter: string;
|
||||
url: string;
|
||||
model: string;
|
||||
api_key_env: string;
|
||||
};
|
||||
export type ModelInfo = ModelEntry & { api_key_set: boolean; api_key_stored: boolean };
|
||||
export type ProviderInfo = ProviderEntry & { api_key_set: boolean; api_key_stored: boolean };
|
||||
/** Was die Oberfläche beim Speichern schickt. Der Schlüssel wird nie in die Konfiguration geschrieben. */
|
||||
export type ModelInput = ModelEntry & { previous_name: string | null; api_key: string | null; clear_key: boolean };
|
||||
export type ProviderInput = ProviderEntry & { previous_name: string | null; api_key: string | null; clear_key: boolean };
|
||||
/** Ein gewähltes Modell bei einem Anbieter. */
|
||||
export type Selection = { provider: string; model: string };
|
||||
/** Anzeigename in Läufen und Ranglisten. Muss `model_label` in `config.rs` entsprechen. */
|
||||
export function modelLabel(provider: string, model: string): string {
|
||||
return `${model} · ${provider}`;
|
||||
}
|
||||
export type ModelTest = { ok: boolean; duration_ms: number; message: string };
|
||||
|
||||
export type RuntimeStatus = { program: string; available: boolean; detail: string };
|
||||
@ -112,13 +118,13 @@ export const api = {
|
||||
runtime: () => invoke<RuntimeStatus>("runtime_status"),
|
||||
imageStatus: () => invoke<ImageStatus[]>("image_status"),
|
||||
buildImage: (image: string) => invoke<void>("build_image", { image }),
|
||||
models: () => invoke<ModelInfo[]>("list_models"),
|
||||
saveModels: (models: ModelInput[]) => invoke<ModelInfo[]>("save_models", { models }),
|
||||
providers: () => invoke<ProviderInfo[]>("list_providers"),
|
||||
saveProviders: (providers: ProviderInput[]) => invoke<ProviderInfo[]>("save_providers", { providers }),
|
||||
discoverModels: (adapter: string, url: string, apiKeyEnv: string, name: string | null, apiKey: string | null) =>
|
||||
invoke<string[]>("discover_models", { adapter, url, apiKeyEnv, name, apiKey }),
|
||||
testModel: (name: string) => invoke<ModelTest>("test_model", { name }),
|
||||
startBatch: (models: string[], taskIds: string[], repeats: number, note: string, batchId: number | null = null) =>
|
||||
invoke<BatchSummary>("start_batch", { models, taskIds, repeats, note, batchId }),
|
||||
testModel: (provider: string, model: string) => invoke<ModelTest>("test_model", { provider, model }),
|
||||
startBatch: (selections: Selection[], taskIds: string[], repeats: number, note: string, batchId: number | null = null) =>
|
||||
invoke<BatchSummary>("start_batch", { selections, taskIds, repeats, note, batchId }),
|
||||
exportExternal: (taskIds: string[], repeats: number) => invoke<ExportResult>("export_external", { taskIds, repeats }),
|
||||
importExternal: (dir: string, model: string, batchId: number) =>
|
||||
invoke<ImportSummary>("import_external", { dir, model, batchId }),
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { api, type LoadReport, type ModelInfo, type Paths, type RuntimeStatus } from "$lib/api";
|
||||
import { api, type LoadReport, type ProviderInfo, type Paths, type RuntimeStatus } from "$lib/api";
|
||||
import BenchPanel from "$lib/BenchPanel.svelte";
|
||||
import ReferencePanel from "$lib/ReferencePanel.svelte";
|
||||
import ResultsPanel from "$lib/ResultsPanel.svelte";
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
let loaded = $state(false);
|
||||
let loadError = $state("");
|
||||
let models = $state<ModelInfo[]>([]);
|
||||
let providers = $state<ProviderInfo[]>([]);
|
||||
let tasks = $state<LoadReport | null>(null);
|
||||
let paths = $state<Paths | null>(null);
|
||||
let runtime = $state<RuntimeStatus | null>(null);
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
[models, tasks, paths] = await Promise.all([api.models(), api.tasks(), api.paths()]);
|
||||
[providers, tasks, paths] = await Promise.all([api.providers(), api.tasks(), api.paths()]);
|
||||
runtime = await api.runtime();
|
||||
} catch (e) {
|
||||
loadError = String(e);
|
||||
@ -71,7 +71,7 @@
|
||||
{:else}
|
||||
<!-- Reiter bleiben gemountet, damit ein laufender Batch beim Wechsel nicht abreißt. -->
|
||||
<div hidden={tab !== "bench"}>
|
||||
<BenchPanel {models} {tasks} {paths} ongotosettings={() => (tab = "settings")} onfinished={showResults} />
|
||||
<BenchPanel {providers} {tasks} {paths} ongotosettings={() => (tab = "settings")} onfinished={showResults} />
|
||||
</div>
|
||||
<div hidden={tab !== "results"}>
|
||||
<ResultsPanel bind:selected={selectedBatch} />
|
||||
@ -80,7 +80,7 @@
|
||||
<ReferencePanel {tasks} onimported={showResults} />
|
||||
</div>
|
||||
<div hidden={tab !== "settings"}>
|
||||
<SettingsPanel {models} {paths} {runtime} onsaved={(m) => (models = m)} />
|
||||
<SettingsPanel {providers} {paths} {runtime} onsaved={(p) => (providers = p)} />
|
||||
</div>
|
||||
{/if}
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user