Files
GPU-Node/dashboard/src/lib/utils.ts
Claude c4a91972b3 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.
2026-10-23 22:22:26 +00:00

42 lines
1.5 KiB
TypeScript

import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function formatBytes(bytes: number | null | undefined): string {
if (bytes == null || Number.isNaN(bytes)) return "—";
if (bytes === 0) return "0 B";
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
const i = Math.floor(Math.log(bytes) / Math.log(1024));
const value = bytes / Math.pow(1024, i);
return `${value.toFixed(value >= 100 ? 0 : value >= 10 ? 1 : 2)} ${units[i]}`;
}
export function formatDuration(seconds: number): string {
if (!seconds || seconds < 0) return "—";
const d = Math.floor(seconds / 86400);
const h = Math.floor((seconds % 86400) / 3600);
const m = Math.floor((seconds % 3600) / 60);
const s = Math.floor(seconds % 60);
const parts: string[] = [];
if (d > 0) parts.push(`${d}d`);
if (h > 0) parts.push(`${h}h`);
if (m > 0) parts.push(`${m}m`);
if (s > 0 || parts.length === 0) parts.push(`${s}s`);
return parts.join(" ");
}
export function timeAgo(iso: string | null | undefined): string {
if (!iso) return "—";
const date = new Date(iso);
if (Number.isNaN(date.getTime())) return "—";
const diff = Date.now() - date.getTime();
const sec = Math.floor(diff / 1000);
if (sec < 60) return `${sec}s ago`;
if (sec < 3600) return `${Math.floor(sec / 60)}m ago`;
if (sec < 86400) return `${Math.floor(sec / 3600)}h ago`;
return `${Math.floor(sec / 86400)}d ago`;
}