feat: add llama dashboard for managing launch config via web UI
Adds a small Next.js dashboard as a new Docker service () that replaces the need to manually edit and call over SSH every time you want to tweak llama launch parameters. Features: - Live status panel for all GPU-node containers (auto-refresh) - Models list with file sizes, click-to-select active model - Structured launch config form: * Model, ctx-size, parallel, batch-size, n-gpu-layers, threads * Context overflow (none / shift / evict) * Speculative decoding (spec-type, draft model, spec-draft-n-max) * Free-form extra args textarea for anything else - Named presets (save / load / delete) - Start / Restart / Stop / Remove llama actions - Live streaming logs viewer (docker logs -f) - GPU status (nvidia-smi via docker exec on llama) - Auto-writes LLAMA_MODEL and LLAMA_EXTRA_ARGS back to .env so the existing workflow keeps working, and persists full structured config to gpu/dashboard/config.json for reload on next visit Integration: - New service in compose.yaml (no profile, runs always) - Mounts /var/run/docker.sock + HOST_PROJECT_PATH - Tailscale serve exposes port 8090 -> dashboard:3000 - build.sh extended to build the dashboard image Tech: Next.js 16 standalone, React 19, TypeScript 5, Tailwind 4, shadcn-style components, Radix UI primitives.
This commit is contained in:
112
dashboard/src/app/api/config/route.ts
Normal file
112
dashboard/src/app/api/config/route.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import {
|
||||
loadConfig,
|
||||
saveConfig,
|
||||
DEFAULT_CONFIG,
|
||||
type DashboardConfig,
|
||||
type Preset,
|
||||
} from "@/lib/docker";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
export const runtime = "nodejs";
|
||||
|
||||
export async function GET() {
|
||||
const config = await loadConfig();
|
||||
return NextResponse.json({ config, defaults: DEFAULT_CONFIG });
|
||||
}
|
||||
|
||||
export async function PUT(req: NextRequest) {
|
||||
const body = (await req.json()) as Partial<DashboardConfig>;
|
||||
const current = await loadConfig();
|
||||
|
||||
// Merge: keep existing presets unless explicitly overwritten
|
||||
const next: DashboardConfig = {
|
||||
model: body.model ?? current.model,
|
||||
ctxSize: body.ctxSize ?? current.ctxSize,
|
||||
parallel: body.parallel ?? current.parallel,
|
||||
nGpuLayers: body.nGpuLayers ?? current.nGpuLayers,
|
||||
threads: body.threads ?? current.threads,
|
||||
draftModel: body.draftModel ?? current.draftModel,
|
||||
specType: body.specType ?? current.specType,
|
||||
specDraftNMax: body.specDraftNMax ?? current.specDraftNMax,
|
||||
batchSize: body.batchSize ?? current.batchSize,
|
||||
contextOverflow: body.contextOverflow ?? current.contextOverflow,
|
||||
extraArgs: body.extraArgs ?? current.extraArgs,
|
||||
presets: body.presets ?? current.presets,
|
||||
};
|
||||
|
||||
await saveConfig(next);
|
||||
return NextResponse.json({ config: next });
|
||||
}
|
||||
|
||||
// ----- Presets -------------------------------------------------------------
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
const body = (await req.json()) as {
|
||||
action: "save-preset" | "delete-preset" | "load-preset" | "reset";
|
||||
name?: string;
|
||||
id?: string;
|
||||
};
|
||||
const current = await loadConfig();
|
||||
|
||||
if (body.action === "save-preset") {
|
||||
if (!body.name) {
|
||||
return NextResponse.json(
|
||||
{ error: "name is required" },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
const preset: Preset = {
|
||||
id: `preset-${Date.now()}`,
|
||||
name: body.name,
|
||||
config: stripPresets(current),
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
const next: DashboardConfig = {
|
||||
...current,
|
||||
presets: [...current.presets.filter((p) => p.name !== body.name), preset],
|
||||
};
|
||||
await saveConfig(next);
|
||||
return NextResponse.json({ config: next });
|
||||
}
|
||||
|
||||
if (body.action === "delete-preset") {
|
||||
if (!body.id) {
|
||||
return NextResponse.json({ error: "id is required" }, { status: 400 });
|
||||
}
|
||||
const next: DashboardConfig = {
|
||||
...current,
|
||||
presets: current.presets.filter((p) => p.id !== body.id),
|
||||
};
|
||||
await saveConfig(next);
|
||||
return NextResponse.json({ config: next });
|
||||
}
|
||||
|
||||
if (body.action === "load-preset") {
|
||||
if (!body.id) {
|
||||
return NextResponse.json({ error: "id is required" }, { status: 400 });
|
||||
}
|
||||
const preset = current.presets.find((p) => p.id === body.id);
|
||||
if (!preset) {
|
||||
return NextResponse.json({ error: "preset not found" }, { status: 404 });
|
||||
}
|
||||
const next: DashboardConfig = {
|
||||
...preset.config,
|
||||
presets: current.presets,
|
||||
};
|
||||
await saveConfig(next);
|
||||
return NextResponse.json({ config: next });
|
||||
}
|
||||
|
||||
if (body.action === "reset") {
|
||||
await saveConfig({ ...DEFAULT_CONFIG, presets: current.presets });
|
||||
return NextResponse.json({ config: { ...DEFAULT_CONFIG, presets: current.presets } });
|
||||
}
|
||||
|
||||
return NextResponse.json({ error: "unknown action" }, { status: 400 });
|
||||
}
|
||||
|
||||
function stripPresets(cfg: DashboardConfig): Omit<DashboardConfig, "presets"> {
|
||||
const { presets: _presets, ...rest } = cfg;
|
||||
return rest;
|
||||
}
|
||||
Reference in New Issue
Block a user