Compare commits
5 Commits
fix/chat-i
...
fix/versio
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b96d773065 | ||
|
|
71f90aa569 | ||
| 187fefc30b | |||
|
|
cb92e32bdf | ||
| 3d2bec055b |
@@ -7,7 +7,17 @@ export const runtime = "nodejs";
|
|||||||
/**
|
/**
|
||||||
* POST /api/comfy/models/add
|
* POST /api/comfy/models/add
|
||||||
* Body: { url: string, type: string }
|
* Body: { url: string, type: string }
|
||||||
* Queues a model download via model-worker.
|
*
|
||||||
|
* Queues a ComfyUI model download via model-worker. CivitAI URLs are
|
||||||
|
* automatically transformed (model page → API download URL) and the saved
|
||||||
|
* CivitAI token is appended.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* { ok, output, error?, originalUrl?, transformedUrl?, urlNote? }
|
||||||
|
*
|
||||||
|
* The originalUrl/transformedUrl/urlNote fields are only present when we
|
||||||
|
* actually modified the URL (e.g. user pasted a civitai.com/models/12345
|
||||||
|
* page URL and we converted it to /api/download/models/12345?token=...).
|
||||||
*/
|
*/
|
||||||
export async function POST(req: NextRequest) {
|
export async function POST(req: NextRequest) {
|
||||||
const body = (await req.json()) as { url?: string; type?: string };
|
const body = (await req.json()) as { url?: string; type?: string };
|
||||||
@@ -19,7 +29,14 @@ export async function POST(req: NextRequest) {
|
|||||||
}
|
}
|
||||||
const result = await addComfyModel(body.url, body.type);
|
const result = await addComfyModel(body.url, body.type);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ ok: result.ok, output: result.output, error: result.error },
|
{
|
||||||
|
ok: result.ok,
|
||||||
|
output: result.output,
|
||||||
|
error: result.error,
|
||||||
|
originalUrl: result.originalUrl,
|
||||||
|
transformedUrl: result.transformedUrl,
|
||||||
|
urlNote: result.urlNote,
|
||||||
|
},
|
||||||
{ status: result.ok ? 200 : 500 }
|
{ status: result.ok ? 200 : 500 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ function mergeConfig(
|
|||||||
nGpuLayers: patch.nGpuLayers ?? base.nGpuLayers,
|
nGpuLayers: patch.nGpuLayers ?? base.nGpuLayers,
|
||||||
threads: patch.threads ?? base.threads,
|
threads: patch.threads ?? base.threads,
|
||||||
draftModel: patch.draftModel ?? base.draftModel,
|
draftModel: patch.draftModel ?? base.draftModel,
|
||||||
|
mmprojPath: patch.mmprojPath ?? base.mmprojPath,
|
||||||
specType: patch.specType ?? base.specType,
|
specType: patch.specType ?? base.specType,
|
||||||
specDraftNMax: patch.specDraftNMax ?? base.specDraftNMax,
|
specDraftNMax: patch.specDraftNMax ?? base.specDraftNMax,
|
||||||
batchSize: patch.batchSize ?? base.batchSize,
|
batchSize: patch.batchSize ?? base.batchSize,
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ export async function GET() {
|
|||||||
ok: envError === null,
|
ok: envError === null,
|
||||||
error: envError,
|
error: envError,
|
||||||
},
|
},
|
||||||
|
version: "0.5.0",
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
50
dashboard/src/app/api/props/route.ts
Normal file
50
dashboard/src/app/api/props/route.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
export const runtime = "nodejs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /api/props
|
||||||
|
*
|
||||||
|
* Proxies llama.cpp's /props endpoint. Returns:
|
||||||
|
* - default_generation_settings: { n_predict, temperature, top_k, top_p,
|
||||||
|
* min_p, repeat_penalty, ... } — the sampling defaults the server
|
||||||
|
* started with
|
||||||
|
* - total_slots: number of parallel slots
|
||||||
|
* - model_path: path to the loaded model
|
||||||
|
* - chat_template: chat template string (if --jinja)
|
||||||
|
* - n_context: total context size (ctx_size * parallel)
|
||||||
|
* - n_vocab, n_embd, n_params: model metadata
|
||||||
|
* - has_multimodal: bool (mmproj loaded)
|
||||||
|
* - timings: cumulative across all slots since server start
|
||||||
|
*
|
||||||
|
* Unlike /slots (per-slot state), /props gives server-wide info that's
|
||||||
|
* useful even when no chat is running.
|
||||||
|
*/
|
||||||
|
export async function GET() {
|
||||||
|
try {
|
||||||
|
const res = await fetch("http://llama:8080/props", {
|
||||||
|
cache: "no-store",
|
||||||
|
signal: AbortSignal.timeout(5000),
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
ok: false,
|
||||||
|
error: `llama returned ${res.status}`,
|
||||||
|
},
|
||||||
|
{ status: res.status }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const data = await res.json();
|
||||||
|
return NextResponse.json({ ok: true, props: data });
|
||||||
|
} catch (err) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
ok: false,
|
||||||
|
error: (err as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 503 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,13 +53,19 @@ import {
|
|||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { cn, formatBytes, timeAgo } from "@/lib/utils";
|
import { cn, formatBytes, timeAgo } from "@/lib/utils";
|
||||||
|
import { DASHBOARD_VERSION } from "@/lib/version";
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Types
|
// Types
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
type ModelKind = "base" | "mmproj" | "mtp" | "draft";
|
||||||
|
|
||||||
interface ModelFile {
|
interface ModelFile {
|
||||||
name: string;
|
name: string;
|
||||||
|
relativePath: string;
|
||||||
|
subdir: string;
|
||||||
|
kind: ModelKind;
|
||||||
sizeBytes: number;
|
sizeBytes: number;
|
||||||
sizeHuman: string;
|
sizeHuman: string;
|
||||||
modifiedAt: string;
|
modifiedAt: string;
|
||||||
@@ -91,6 +97,8 @@ interface DashboardConfig {
|
|||||||
nGpuLayers: number;
|
nGpuLayers: number;
|
||||||
threads: number;
|
threads: number;
|
||||||
draftModel: string;
|
draftModel: string;
|
||||||
|
/** Optional mmproj file (multimodal vision projector) */
|
||||||
|
mmprojPath: string;
|
||||||
specType: "none" | "draft-mtp" | "draft-llama";
|
specType: "none" | "draft-mtp" | "draft-llama";
|
||||||
specDraftNMax: number;
|
specDraftNMax: number;
|
||||||
batchSize: number;
|
batchSize: number;
|
||||||
@@ -179,6 +187,7 @@ const DEFAULT_CONFIG: DashboardConfig = {
|
|||||||
nGpuLayers: -1,
|
nGpuLayers: -1,
|
||||||
threads: -1,
|
threads: -1,
|
||||||
draftModel: "",
|
draftModel: "",
|
||||||
|
mmprojPath: "",
|
||||||
specType: "none",
|
specType: "none",
|
||||||
specDraftNMax: 4,
|
specDraftNMax: 4,
|
||||||
batchSize: 512,
|
batchSize: 512,
|
||||||
@@ -288,6 +297,9 @@ export default function DashboardPage() {
|
|||||||
civitaiToken: "",
|
civitaiToken: "",
|
||||||
});
|
});
|
||||||
const [urlPreview, setUrlPreview] = React.useState<UrlPreview | null>(null);
|
const [urlPreview, setUrlPreview] = React.useState<UrlPreview | null>(null);
|
||||||
|
// Separate preview state for the Comfy tab's URL field (same logic as urlPreview,
|
||||||
|
// just tracks a different input)
|
||||||
|
const [comfyUrlPreview, setComfyUrlPreview] = React.useState<UrlPreview | null>(null);
|
||||||
|
|
||||||
// Chat state — kept at top level so switching tabs doesn't reset the
|
// Chat state — kept at top level so switching tabs doesn't reset the
|
||||||
// conversation. ChatTab is mounted/unmounted when the user clicks the tab.
|
// conversation. ChatTab is mounted/unmounted when the user clicks the tab.
|
||||||
@@ -435,7 +447,7 @@ export default function DashboardPage() {
|
|||||||
refreshModels();
|
refreshModels();
|
||||||
refreshComfyTypes();
|
refreshComfyTypes();
|
||||||
refreshComfyModels();
|
refreshComfyModels();
|
||||||
const id = setInterval(refreshComfyQueue, 5000);
|
const id = setInterval(refreshComfyQueue, 2000);
|
||||||
return () => clearInterval(id);
|
return () => clearInterval(id);
|
||||||
}, [
|
}, [
|
||||||
refreshConfig,
|
refreshConfig,
|
||||||
@@ -896,6 +908,45 @@ export default function DashboardPage() {
|
|||||||
};
|
};
|
||||||
}, [downloadUrl, previewUrl]);
|
}, [downloadUrl, previewUrl]);
|
||||||
|
|
||||||
|
// Same debounced preview, but for the Comfy tab's URL field
|
||||||
|
const comfyPreviewDebounceRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (comfyPreviewDebounceRef.current)
|
||||||
|
clearTimeout(comfyPreviewDebounceRef.current);
|
||||||
|
comfyPreviewDebounceRef.current = setTimeout(() => {
|
||||||
|
void (async () => {
|
||||||
|
if (!comfyAddUrl.trim()) {
|
||||||
|
setComfyUrlPreview(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const res = await fetch("/api/settings", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ action: "preview-url", url: comfyAddUrl }),
|
||||||
|
});
|
||||||
|
if (!res.ok) return;
|
||||||
|
const data = await res.json();
|
||||||
|
if (data.ok) {
|
||||||
|
setComfyUrlPreview({
|
||||||
|
original: data.original,
|
||||||
|
transformed: data.transformed,
|
||||||
|
note: data.note,
|
||||||
|
isCivitai: data.isCivitai,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}, 400);
|
||||||
|
return () => {
|
||||||
|
if (comfyPreviewDebounceRef.current)
|
||||||
|
clearTimeout(comfyPreviewDebounceRef.current);
|
||||||
|
};
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [comfyAddUrl]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
refreshSettings();
|
refreshSettings();
|
||||||
}, [refreshSettings]);
|
}, [refreshSettings]);
|
||||||
@@ -1206,10 +1257,22 @@ export default function DashboardPage() {
|
|||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
setComfyAddUrl("");
|
setComfyAddUrl("");
|
||||||
await refreshComfyQueue();
|
await refreshComfyQueue();
|
||||||
return {
|
// Build a helpful message — if the URL was transformed (CivitAI
|
||||||
ok: data.ok,
|
// model page → API download URL with token), include the note so the
|
||||||
message: data.ok ? `Queued: ${comfyAddType}` : data.error || "Failed",
|
// user can see what happened.
|
||||||
};
|
let message: string;
|
||||||
|
if (data.ok) {
|
||||||
|
message = `Queued: ${comfyAddType}`;
|
||||||
|
if (data.urlNote) {
|
||||||
|
message += `\n${data.urlNote}`;
|
||||||
|
}
|
||||||
|
if (data.transformedUrl) {
|
||||||
|
message += `\n→ ${data.transformedUrl}`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
message = data.error || "Failed";
|
||||||
|
}
|
||||||
|
return { ok: data.ok, message };
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1426,6 +1489,8 @@ export default function DashboardPage() {
|
|||||||
busy={busy}
|
busy={busy}
|
||||||
uploadProgress={uploadProgress}
|
uploadProgress={uploadProgress}
|
||||||
onSelectModel={(m) => update("model", m)}
|
onSelectModel={(m) => update("model", m)}
|
||||||
|
onUseMmproj={(m) => update("mmprojPath", m)}
|
||||||
|
onUseDraft={(m) => update("draftModel", m)}
|
||||||
onUpload={handleUpload}
|
onUpload={handleUpload}
|
||||||
onDelete={handleDeleteModel}
|
onDelete={handleDeleteModel}
|
||||||
downloadJobs={downloadJobs}
|
downloadJobs={downloadJobs}
|
||||||
@@ -1457,6 +1522,9 @@ export default function DashboardPage() {
|
|||||||
setAddType={setComfyAddType}
|
setAddType={setComfyAddType}
|
||||||
onRemove={handleComfyRemoveModel}
|
onRemove={handleComfyRemoveModel}
|
||||||
busy={busy}
|
busy={busy}
|
||||||
|
civitaiToken={settings.civitaiToken}
|
||||||
|
onSaveCivitaiToken={handleSaveCivitaiToken}
|
||||||
|
urlPreview={comfyUrlPreview}
|
||||||
/>
|
/>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
@@ -1493,8 +1561,11 @@ export default function DashboardPage() {
|
|||||||
|
|
||||||
<footer className="border-t border-border bg-card/30 mt-auto">
|
<footer className="border-t border-border bg-card/30 mt-auto">
|
||||||
<div className="mx-auto max-w-7xl px-4 sm:px-6 py-3 flex items-center justify-between text-xs text-muted-foreground">
|
<div className="mx-auto max-w-7xl px-4 sm:px-6 py-3 flex items-center justify-between text-xs text-muted-foreground">
|
||||||
<div>
|
<div className="flex items-center gap-2">
|
||||||
GPU-Node Dashboard ·{" "}
|
<span className="font-mono font-medium text-foreground">
|
||||||
|
v{DASHBOARD_VERSION}
|
||||||
|
</span>
|
||||||
|
<span>·</span>
|
||||||
<a
|
<a
|
||||||
href="https://github.com/ggml-org/llama.cpp"
|
href="https://github.com/ggml-org/llama.cpp"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
@@ -2254,6 +2325,8 @@ function ModelsTab({
|
|||||||
busy,
|
busy,
|
||||||
uploadProgress,
|
uploadProgress,
|
||||||
onSelectModel,
|
onSelectModel,
|
||||||
|
onUseMmproj,
|
||||||
|
onUseDraft,
|
||||||
onUpload,
|
onUpload,
|
||||||
onDelete,
|
onDelete,
|
||||||
downloadJobs,
|
downloadJobs,
|
||||||
@@ -2270,6 +2343,8 @@ function ModelsTab({
|
|||||||
busy: string | null;
|
busy: string | null;
|
||||||
uploadProgress: { name: string; percent: number } | null;
|
uploadProgress: { name: string; percent: number } | null;
|
||||||
onSelectModel: (m: string) => void;
|
onSelectModel: (m: string) => void;
|
||||||
|
onUseMmproj: (m: string) => void;
|
||||||
|
onUseDraft: (m: string) => void;
|
||||||
onUpload: (file: File) => void;
|
onUpload: (file: File) => void;
|
||||||
onDelete: (name: string) => void;
|
onDelete: (name: string) => void;
|
||||||
downloadJobs: DownloadJob[];
|
downloadJobs: DownloadJob[];
|
||||||
@@ -2534,59 +2609,102 @@ function ModelsTab({
|
|||||||
<thead className="sticky top-0 bg-card">
|
<thead className="sticky top-0 bg-card">
|
||||||
<tr className="text-left text-xs text-muted-foreground border-b">
|
<tr className="text-left text-xs text-muted-foreground border-b">
|
||||||
<th className="py-2 px-2 font-medium">Name</th>
|
<th className="py-2 px-2 font-medium">Name</th>
|
||||||
|
<th className="py-2 px-2 font-medium w-20">Kind</th>
|
||||||
<th className="py-2 px-2 font-medium w-32 text-right">Size</th>
|
<th className="py-2 px-2 font-medium w-32 text-right">Size</th>
|
||||||
<th className="py-2 px-2 font-medium w-32 text-right">Modified</th>
|
<th className="py-2 px-2 font-medium w-32 text-right">Modified</th>
|
||||||
<th className="py-2 px-2 font-medium w-32 text-right">Actions</th>
|
<th className="py-2 px-2 font-medium w-44 text-right">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{models.map((m) => (
|
{models.map((m) => {
|
||||||
<tr
|
const isActiveBase = config.model === m.relativePath;
|
||||||
key={m.name}
|
const isActiveMmproj = config.mmprojPath === m.relativePath;
|
||||||
className="border-b border-border/40 hover:bg-muted/30"
|
const isActiveDraft = config.draftModel === m.name;
|
||||||
>
|
const isActive = isActiveBase || isActiveMmproj || isActiveDraft;
|
||||||
<td className="py-2 px-2">
|
const kindBadge = {
|
||||||
<div className="flex items-center gap-2">
|
base: <Badge variant="outline" className="text-[10px]">base</Badge>,
|
||||||
<FileText className="h-3.5 w-3.5 text-muted-foreground shrink-0" />
|
mmproj: <Badge variant="default" className="text-[10px]">mmproj</Badge>,
|
||||||
<span className="font-mono text-xs truncate">{m.name}</span>
|
mtp: <Badge variant="secondary" className="text-[10px]">mtp</Badge>,
|
||||||
{config.model === m.name && (
|
draft: <Badge variant="secondary" className="text-[10px]">draft</Badge>,
|
||||||
<Badge variant="success" className="text-[10px]">
|
}[m.kind];
|
||||||
active
|
return (
|
||||||
</Badge>
|
<tr
|
||||||
)}
|
key={m.relativePath}
|
||||||
</div>
|
className="border-b border-border/40 hover:bg-muted/30"
|
||||||
</td>
|
>
|
||||||
<td className="py-2 px-2 text-right font-mono text-xs">
|
<td className="py-2 px-2">
|
||||||
{m.sizeHuman}
|
<div className="flex items-center gap-2">
|
||||||
</td>
|
<FileText className="h-3.5 w-3.5 text-muted-foreground shrink-0" />
|
||||||
<td className="py-2 px-2 text-right text-xs text-muted-foreground">
|
{m.subdir && (
|
||||||
{timeAgo(m.modifiedAt)}
|
<span className="font-mono text-[10px] text-muted-foreground">
|
||||||
</td>
|
{m.subdir}/
|
||||||
<td className="py-2 px-2 text-right">
|
</span>
|
||||||
<div className="flex items-center justify-end gap-1">
|
)}
|
||||||
<Button
|
<span className="font-mono text-xs truncate">{m.name}</span>
|
||||||
size="sm"
|
{isActive && (
|
||||||
variant="ghost"
|
<Badge variant="success" className="text-[10px]">
|
||||||
className="h-7"
|
{isActiveBase ? "active" : isActiveMmproj ? "mmproj" : "draft"}
|
||||||
disabled={config.model === m.name || busy !== null}
|
</Badge>
|
||||||
onClick={() => onSelectModel(m.name)}
|
)}
|
||||||
>
|
</div>
|
||||||
Use
|
</td>
|
||||||
<ChevronRight className="h-3 w-3" />
|
<td className="py-2 px-2">{kindBadge}</td>
|
||||||
</Button>
|
<td className="py-2 px-2 text-right font-mono text-xs">
|
||||||
<Button
|
{m.sizeHuman}
|
||||||
size="sm"
|
</td>
|
||||||
variant="ghost"
|
<td className="py-2 px-2 text-right text-xs text-muted-foreground">
|
||||||
className="h-7 hover:text-destructive"
|
{timeAgo(m.modifiedAt)}
|
||||||
disabled={busy !== null}
|
</td>
|
||||||
onClick={() => onDelete(m.name)}
|
<td className="py-2 px-2 text-right">
|
||||||
>
|
<div className="flex items-center justify-end gap-1 flex-wrap">
|
||||||
<Trash2 className="h-3.5 w-3.5" />
|
{m.kind === "base" && (
|
||||||
</Button>
|
<Button
|
||||||
</div>
|
size="sm"
|
||||||
</td>
|
variant="ghost"
|
||||||
</tr>
|
className="h-7"
|
||||||
))}
|
disabled={isActiveBase || busy !== null}
|
||||||
|
onClick={() => onSelectModel(m.relativePath)}
|
||||||
|
>
|
||||||
|
Use
|
||||||
|
<ChevronRight className="h-3 w-3" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{m.kind === "mmproj" && (
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="ghost"
|
||||||
|
className="h-7"
|
||||||
|
disabled={isActiveMmproj || busy !== null}
|
||||||
|
onClick={() => onUseMmproj(m.relativePath)}
|
||||||
|
>
|
||||||
|
{isActiveMmproj ? "✓ mmproj" : "Set mmproj"}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{(m.kind === "mtp" || m.kind === "draft") && (
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="ghost"
|
||||||
|
className="h-7"
|
||||||
|
disabled={isActiveDraft || busy !== null}
|
||||||
|
onClick={() => onUseDraft(m.name)}
|
||||||
|
>
|
||||||
|
{isActiveDraft ? "✓ draft" : "Set draft"}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="ghost"
|
||||||
|
className="h-7 hover:text-destructive"
|
||||||
|
disabled={busy !== null}
|
||||||
|
onClick={() => onDelete(m.relativePath)}
|
||||||
|
>
|
||||||
|
<Trash2 className="h-3.5 w-3.5" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -2747,6 +2865,9 @@ function ComfyTab({
|
|||||||
setAddType,
|
setAddType,
|
||||||
onRemove,
|
onRemove,
|
||||||
busy,
|
busy,
|
||||||
|
civitaiToken,
|
||||||
|
onSaveCivitaiToken,
|
||||||
|
urlPreview,
|
||||||
}: {
|
}: {
|
||||||
models: ComfyModelEntry[];
|
models: ComfyModelEntry[];
|
||||||
queue: ComfyQueueEntry[];
|
queue: ComfyQueueEntry[];
|
||||||
@@ -2763,7 +2884,17 @@ function ComfyTab({
|
|||||||
setAddType: (v: string) => void;
|
setAddType: (v: string) => void;
|
||||||
onRemove: (filename: string, type?: string) => void;
|
onRemove: (filename: string, type?: string) => void;
|
||||||
busy: string | null;
|
busy: string | null;
|
||||||
|
civitaiToken: string;
|
||||||
|
onSaveCivitaiToken: (token: string) => void;
|
||||||
|
urlPreview: UrlPreview | null;
|
||||||
}) {
|
}) {
|
||||||
|
const [showCivitaiSettings, setShowCivitaiSettings] = React.useState(false);
|
||||||
|
const [civitaiTokenDraft, setCivitaiTokenDraft] = React.useState(civitaiToken);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
setCivitaiTokenDraft(civitaiToken);
|
||||||
|
}, [civitaiToken]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{/* Download queue */}
|
{/* Download queue */}
|
||||||
@@ -2848,22 +2979,94 @@ function ComfyTab({
|
|||||||
|
|
||||||
{/* Add model */}
|
{/* Add model */}
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader className="flex flex-row items-start justify-between gap-2">
|
||||||
<CardTitle className="text-base flex items-center gap-2">
|
<div>
|
||||||
<Plus className="h-4 w-4" />
|
<CardTitle className="text-base flex items-center gap-2">
|
||||||
Queue Download
|
<Plus className="h-4 w-4" />
|
||||||
</CardTitle>
|
Queue Download
|
||||||
<CardDescription>
|
</CardTitle>
|
||||||
Mirrors <code className="font-mono text-xs">gpuctl comfy models add <URL> <type></code>
|
<CardDescription>
|
||||||
</CardDescription>
|
Mirrors <code className="font-mono text-xs">gpuctl comfy models add <URL> <type></code>.
|
||||||
|
{" "}CivitAI URLs auto-converted (model page → API download),
|
||||||
|
token appended.
|
||||||
|
</CardDescription>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => setShowCivitaiSettings((v) => !v)}
|
||||||
|
>
|
||||||
|
<KeyIcon className="h-3.5 w-3.5" />
|
||||||
|
CivitAI token
|
||||||
|
{civitaiToken ? (
|
||||||
|
<Badge variant="success" className="ml-1 text-[10px]">
|
||||||
|
set
|
||||||
|
</Badge>
|
||||||
|
) : (
|
||||||
|
<Badge variant="secondary" className="ml-1 text-[10px]">
|
||||||
|
empty
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent className="space-y-3">
|
||||||
|
{showCivitaiSettings && (
|
||||||
|
<div className="rounded-md border bg-card p-3 space-y-2">
|
||||||
|
<Label htmlFor="comfy-civitai-token">CivitAI API token</Label>
|
||||||
|
<Input
|
||||||
|
id="comfy-civitai-token"
|
||||||
|
type="password"
|
||||||
|
value={civitaiTokenDraft}
|
||||||
|
onChange={(e) => setCivitaiTokenDraft(e.target.value)}
|
||||||
|
placeholder="Get it from https://civitai.com/user/account → API Keys"
|
||||||
|
className="font-mono text-xs"
|
||||||
|
/>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
onClick={() => onSaveCivitaiToken(civitaiTokenDraft)}
|
||||||
|
disabled={busy === "save-settings"}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() => {
|
||||||
|
setCivitaiTokenDraft("");
|
||||||
|
onSaveCivitaiToken("");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Clear
|
||||||
|
</Button>
|
||||||
|
<a
|
||||||
|
href="https://civitai.com/user/account"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="ml-auto text-xs text-muted-foreground hover:underline"
|
||||||
|
>
|
||||||
|
Get token ↗
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<p className="text-[10px] text-muted-foreground">
|
||||||
|
Shared with the llama-models downloader. Stored in{" "}
|
||||||
|
<code className="font-mono">gpu/dashboard/settings.json</code>.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="grid gap-2 sm:grid-cols-[1fr_180px_auto]">
|
<div className="grid gap-2 sm:grid-cols-[1fr_180px_auto]">
|
||||||
<Input
|
<Input
|
||||||
placeholder="https://huggingface.co/.../model.safetensors"
|
placeholder="https://civitai.com/models/12345 or HF/GitHub URL"
|
||||||
value={addUrl}
|
value={addUrl}
|
||||||
onChange={(e) => setAddUrl(e.target.value)}
|
onChange={(e) => setAddUrl(e.target.value)}
|
||||||
className="font-mono text-xs"
|
className="font-mono text-xs"
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter" && !e.shiftKey) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (addUrl.trim() && busy === null) onAdd();
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<Select value={addType} onValueChange={setAddType}>
|
<Select value={addType} onValueChange={setAddType}>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
@@ -2883,11 +3086,29 @@ function ComfyTab({
|
|||||||
)}
|
)}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<Button onClick={onAdd} disabled={busy !== null}>
|
<Button onClick={onAdd} disabled={busy !== null || !addUrl.trim()}>
|
||||||
<Plus className="h-3.5 w-3.5" />
|
<Plus className="h-3.5 w-3.5" />
|
||||||
Queue
|
Queue
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* URL preview — shows what we'll actually send to the worker */}
|
||||||
|
{urlPreview && urlPreview.original !== urlPreview.transformed && (
|
||||||
|
<div className="rounded-md border bg-card p-2.5 text-xs space-y-1">
|
||||||
|
<div className="flex items-center gap-1.5">
|
||||||
|
<Badge
|
||||||
|
variant={urlPreview.isCivitai ? "default" : "secondary"}
|
||||||
|
className="text-[10px]"
|
||||||
|
>
|
||||||
|
{urlPreview.isCivitai ? "CivitAI" : "transformed"}
|
||||||
|
</Badge>
|
||||||
|
<span className="text-muted-foreground">{urlPreview.note}</span>
|
||||||
|
</div>
|
||||||
|
<pre className="font-mono text-[10px] text-foreground whitespace-pre-wrap break-all">
|
||||||
|
{urlPreview.transformed}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
@@ -2903,6 +3124,8 @@ function ComfyTab({
|
|||||||
<code className="font-mono text-xs">/project/gpu/comfy/models</code>
|
<code className="font-mono text-xs">/project/gpu/comfy/models</code>
|
||||||
{" · "}
|
{" · "}
|
||||||
{models.length} file(s)
|
{models.length} file(s)
|
||||||
|
{" · "}
|
||||||
|
{formatBytes(models.reduce((s, m) => s + (m.sizeBytes || 0), 0))} total
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@@ -3553,9 +3776,11 @@ interface SlotInfo {
|
|||||||
|
|
||||||
function PerfTab({ llamaRunning }: { llamaRunning: boolean }) {
|
function PerfTab({ llamaRunning }: { llamaRunning: boolean }) {
|
||||||
const [slots, setSlots] = React.useState<SlotInfo[]>([]);
|
const [slots, setSlots] = React.useState<SlotInfo[]>([]);
|
||||||
|
const [props, setProps] = React.useState<Record<string, unknown> | null>(null);
|
||||||
const [metricsRaw, setMetricsRaw] = React.useState<string>("");
|
const [metricsRaw, setMetricsRaw] = React.useState<string>("");
|
||||||
const [active, setActive] = React.useState(false);
|
const [active, setActive] = React.useState(false);
|
||||||
const [view, setView] = React.useState<"slots" | "metrics">("slots");
|
const [view, setView] = React.useState<"overview" | "slots" | "metrics">("overview");
|
||||||
|
const [errors, setErrors] = React.useState<string>("");
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!active || !llamaRunning) return;
|
if (!active || !llamaRunning) return;
|
||||||
@@ -3563,8 +3788,23 @@ function PerfTab({ llamaRunning }: { llamaRunning: boolean }) {
|
|||||||
|
|
||||||
async function poll() {
|
async function poll() {
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
|
setErrors("");
|
||||||
try {
|
try {
|
||||||
if (view === "slots") {
|
if (view === "overview") {
|
||||||
|
// Fetch props + slots in parallel for the overview
|
||||||
|
const [propsRes, slotsRes] = await Promise.all([
|
||||||
|
fetch("/api/props", { cache: "no-store" }).catch(() => null),
|
||||||
|
fetch("/api/slots", { cache: "no-store" }).catch(() => null),
|
||||||
|
]);
|
||||||
|
if (propsRes && propsRes.ok) {
|
||||||
|
const pd = await propsRes.json();
|
||||||
|
if (!cancelled && pd.ok) setProps(pd.props);
|
||||||
|
}
|
||||||
|
if (slotsRes && slotsRes.ok) {
|
||||||
|
const sd = await slotsRes.json();
|
||||||
|
if (!cancelled) setSlots(sd.slots || []);
|
||||||
|
}
|
||||||
|
} else if (view === "slots") {
|
||||||
const res = await fetch("/api/slots", { cache: "no-store" });
|
const res = await fetch("/api/slots", { cache: "no-store" });
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
@@ -3575,10 +3815,13 @@ function PerfTab({ llamaRunning }: { llamaRunning: boolean }) {
|
|||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
if (!cancelled) setMetricsRaw(text);
|
if (!cancelled) setMetricsRaw(text);
|
||||||
|
} else {
|
||||||
|
const text = await res.text().catch(() => "");
|
||||||
|
if (!cancelled) setMetricsRaw(`[${res.status}] ${text.slice(0, 300)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (err) {
|
||||||
/* ignore — will retry */
|
if (!cancelled) setErrors((err as Error).message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3603,11 +3846,12 @@ function PerfTab({ llamaRunning }: { llamaRunning: boolean }) {
|
|||||||
</CardDescription>
|
</CardDescription>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Select value={view} onValueChange={(v) => setView(v as "slots" | "metrics")}>
|
<Select value={view} onValueChange={(v) => setView(v as "overview" | "slots" | "metrics")}>
|
||||||
<SelectTrigger className="w-32">
|
<SelectTrigger className="w-36">
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
|
<SelectItem value="overview">Overview</SelectItem>
|
||||||
<SelectItem value="slots">Slots</SelectItem>
|
<SelectItem value="slots">Slots</SelectItem>
|
||||||
<SelectItem value="metrics">Prometheus</SelectItem>
|
<SelectItem value="metrics">Prometheus</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
@@ -3641,23 +3885,181 @@ function PerfTab({ llamaRunning }: { llamaRunning: boolean }) {
|
|||||||
Start it to see live performance metrics.
|
Start it to see live performance metrics.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
) : !active ? (
|
||||||
|
<div className="text-center py-12 text-muted-foreground">
|
||||||
|
<Play className="h-8 w-8 mx-auto mb-2 opacity-50" />
|
||||||
|
<p className="text-sm">Click Live to start polling</p>
|
||||||
|
<p className="text-xs mt-1">Polls every 1.5s while active</p>
|
||||||
|
</div>
|
||||||
|
) : errors ? (
|
||||||
|
<div className="rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm">
|
||||||
|
<span className="font-mono text-xs text-destructive">{errors}</span>
|
||||||
|
</div>
|
||||||
) : view === "slots" ? (
|
) : view === "slots" ? (
|
||||||
<SlotsView slots={slots} />
|
<SlotsView slots={slots} />
|
||||||
) : (
|
) : view === "metrics" ? (
|
||||||
<pre className="text-xs font-mono whitespace-pre-wrap bg-zinc-950 dark:bg-black text-zinc-300 rounded-md border p-3 max-h-[32rem] overflow-y-auto scrollbar-thin">
|
<pre className="text-xs font-mono whitespace-pre-wrap bg-zinc-950 dark:bg-black text-zinc-300 rounded-md border p-3 max-h-[32rem] overflow-y-auto scrollbar-thin">
|
||||||
{metricsRaw || "[no metrics — was llama started with --metrics?]"}
|
{metricsRaw || "[no metrics — was llama started with --metrics?]"}
|
||||||
</pre>
|
</pre>
|
||||||
|
) : (
|
||||||
|
<OverviewView props={props} slots={slots} />
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function OverviewView({
|
||||||
|
props,
|
||||||
|
slots,
|
||||||
|
}: {
|
||||||
|
props: Record<string, unknown> | null;
|
||||||
|
slots: SlotInfo[];
|
||||||
|
}) {
|
||||||
|
if (!props) {
|
||||||
|
return (
|
||||||
|
<p className="text-sm text-muted-foreground text-center py-8">
|
||||||
|
Loading…
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const gen = props.default_generation_settings as
|
||||||
|
| {
|
||||||
|
n_predict?: number;
|
||||||
|
temperature?: number;
|
||||||
|
top_k?: number;
|
||||||
|
top_p?: number;
|
||||||
|
min_p?: number;
|
||||||
|
repeat_penalty?: number;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
// Cumulative timings across all slots (sum of per-slot)
|
||||||
|
const totalPredictedN = slots.reduce(
|
||||||
|
(s, x) => s + (x.timings?.predicted_n || 0),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
const totalPromptN = slots.reduce(
|
||||||
|
(s, x) => s + (x.timings?.prompt_n || 0),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
// Average TPS across active slots
|
||||||
|
const activeSlots = slots.filter((s) => s.timings?.predicted_per_second);
|
||||||
|
const avgTps =
|
||||||
|
activeSlots.length > 0
|
||||||
|
? activeSlots.reduce((s, x) => s + (x.timings?.predicted_per_second || 0), 0) /
|
||||||
|
activeSlots.length
|
||||||
|
: null;
|
||||||
|
const hasMultimodal = Boolean(props.has_multimodal);
|
||||||
|
const totalSlots = (props.total_slots as number) || slots.length;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* Key metrics */}
|
||||||
|
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
|
||||||
|
<MetricCell
|
||||||
|
label="Avg TPS"
|
||||||
|
value={avgTps != null ? `${avgTps.toFixed(1)}` : "—"}
|
||||||
|
hint="tok/s generated"
|
||||||
|
/>
|
||||||
|
<MetricCell
|
||||||
|
label="Total slots"
|
||||||
|
value={`${totalSlots}`}
|
||||||
|
hint={`${activeSlots.length} active`}
|
||||||
|
/>
|
||||||
|
<MetricCell
|
||||||
|
label="Ctx usage"
|
||||||
|
value={
|
||||||
|
slots.length > 0
|
||||||
|
? `${slots.reduce((s, x) => s + x.n_past, 0)} / ${slots.reduce(
|
||||||
|
(s, x) => s + x.n_ctx,
|
||||||
|
0
|
||||||
|
)}`
|
||||||
|
: "—"
|
||||||
|
}
|
||||||
|
hint="tokens across all slots"
|
||||||
|
/>
|
||||||
|
<MetricCell
|
||||||
|
label="Multimodal"
|
||||||
|
value={hasMultimodal ? "yes" : "no"}
|
||||||
|
hint={hasMultimodal ? "mmproj loaded" : "text-only"}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Cumulative stats */}
|
||||||
|
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3 text-xs">
|
||||||
|
<MetricCell
|
||||||
|
label="Predicted"
|
||||||
|
value={totalPredictedN > 0 ? `${totalPredictedN}` : "—"}
|
||||||
|
hint="tokens generated"
|
||||||
|
/>
|
||||||
|
<MetricCell
|
||||||
|
label="Prompt"
|
||||||
|
value={totalPromptN > 0 ? `${totalPromptN}` : "—"}
|
||||||
|
hint="tokens processed"
|
||||||
|
/>
|
||||||
|
<MetricCell
|
||||||
|
label="Model"
|
||||||
|
value={
|
||||||
|
typeof props.model_path === "string"
|
||||||
|
? (props.model_path as string).split("/").pop() || "?"
|
||||||
|
: "?"
|
||||||
|
}
|
||||||
|
hint={typeof props.model_path === "string" ? props.model_path : ""}
|
||||||
|
/>
|
||||||
|
<MetricCell
|
||||||
|
label="Total ctx"
|
||||||
|
value={typeof props.n_context === "number" ? `${props.n_context}` : "—"}
|
||||||
|
hint="n_ctx × parallel"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Active slots breakdown */}
|
||||||
|
{slots.length > 0 && (
|
||||||
|
<div>
|
||||||
|
<div className="text-xs text-muted-foreground mb-2 font-medium uppercase tracking-wide">
|
||||||
|
Slots
|
||||||
|
</div>
|
||||||
|
<SlotsView slots={slots} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Generation defaults */}
|
||||||
|
{gen && (
|
||||||
|
<div>
|
||||||
|
<div className="text-xs text-muted-foreground mb-2 font-medium uppercase tracking-wide">
|
||||||
|
Default sampling
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2 text-xs font-mono">
|
||||||
|
<span>
|
||||||
|
<span className="text-muted-foreground">temp:</span> {gen.temperature ?? "?"}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<span className="text-muted-foreground">top_k:</span> {gen.top_k ?? "?"}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<span className="text-muted-foreground">top_p:</span> {gen.top_p ?? "?"}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<span className="text-muted-foreground">min_p:</span> {gen.min_p ?? "?"}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<span className="text-muted-foreground">rep:</span> {gen.repeat_penalty ?? "?"}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<span className="text-muted-foreground">n_pred:</span> {gen.n_predict ?? "?"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function SlotsView({ slots }: { slots: SlotInfo[] }) {
|
function SlotsView({ slots }: { slots: SlotInfo[] }) {
|
||||||
if (slots.length === 0) {
|
if (slots.length === 0) {
|
||||||
return (
|
return (
|
||||||
<p className="text-sm text-muted-foreground text-center py-8">
|
<p className="text-sm text-muted-foreground text-center py-8">
|
||||||
No active slots. Start a chat to see metrics.
|
No slots. (Llama might be loading the model still.)
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3963,6 +4365,7 @@ function buildPreviewArgs(cfg: DashboardConfig): string {
|
|||||||
if (cfg.nPredict >= 0) parts.push(`--n-predict ${cfg.nPredict}`);
|
if (cfg.nPredict >= 0) parts.push(`--n-predict ${cfg.nPredict}`);
|
||||||
parts.push(`--reasoning-format ${cfg.reasoningFormat}`);
|
parts.push(`--reasoning-format ${cfg.reasoningFormat}`);
|
||||||
if (cfg.jinja) parts.push("--jinja");
|
if (cfg.jinja) parts.push("--jinja");
|
||||||
|
if (cfg.mmprojPath) parts.push(`--mmproj /models/${cfg.mmprojPath}`);
|
||||||
if (cfg.extraArgs.trim()) parts.push(cfg.extraArgs.trim());
|
if (cfg.extraArgs.trim()) parts.push(cfg.extraArgs.trim());
|
||||||
return parts.join(" ");
|
return parts.join(" ");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,8 +180,18 @@ export interface ContainerInfo {
|
|||||||
statusText: string;
|
statusText: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ModelKind = "base" | "mmproj" | "mtp" | "draft";
|
||||||
|
|
||||||
export interface ModelFile {
|
export interface ModelFile {
|
||||||
|
/** Display name (just the filename, e.g. "Qwen3-VL-Q8_0.gguf") */
|
||||||
name: string;
|
name: string;
|
||||||
|
/** Full path relative to LLAMA_MODELS_DIR (e.g. "Qwen3-VL/Qwen3-VL-Q8_0.gguf"
|
||||||
|
* if the file is in a subdirectory, or just "model.gguf" if at the root) */
|
||||||
|
relativePath: string;
|
||||||
|
/** Subdirectory name (e.g. "Qwen3-VL") or empty string if at root */
|
||||||
|
subdir: string;
|
||||||
|
/** Auto-detected category: base model / mmproj / mtp / draft */
|
||||||
|
kind: ModelKind;
|
||||||
sizeBytes: number;
|
sizeBytes: number;
|
||||||
sizeHuman: string;
|
sizeHuman: string;
|
||||||
modifiedAt: string;
|
modifiedAt: string;
|
||||||
@@ -200,6 +210,8 @@ export interface DashboardConfig {
|
|||||||
threads: number;
|
threads: number;
|
||||||
/** Optional draft model file */
|
/** Optional draft model file */
|
||||||
draftModel: string;
|
draftModel: string;
|
||||||
|
/** Optional mmproj file (multimodal vision projector, e.g. mmproj-F16.gguf) */
|
||||||
|
mmprojPath: string;
|
||||||
/** Speculative decoding type */
|
/** Speculative decoding type */
|
||||||
specType: "none" | "draft-mtp" | "draft-llama";
|
specType: "none" | "draft-mtp" | "draft-llama";
|
||||||
/** Max draft tokens */
|
/** Max draft tokens */
|
||||||
@@ -288,6 +300,7 @@ export const DEFAULT_CONFIG: DashboardConfig = {
|
|||||||
nGpuLayers: -1,
|
nGpuLayers: -1,
|
||||||
threads: -1,
|
threads: -1,
|
||||||
draftModel: "",
|
draftModel: "",
|
||||||
|
mmprojPath: "",
|
||||||
specType: "none",
|
specType: "none",
|
||||||
specDraftNMax: 4,
|
specDraftNMax: 4,
|
||||||
batchSize: 512,
|
batchSize: 512,
|
||||||
@@ -551,6 +564,16 @@ export function parseLlamaExtraArgs(
|
|||||||
case "--jinja":
|
case "--jinja":
|
||||||
cfg.jinja = true;
|
cfg.jinja = true;
|
||||||
break;
|
break;
|
||||||
|
case "--mmproj":
|
||||||
|
// Multimodal vision projector path
|
||||||
|
// Strip /models/ prefix if present (we store just the relative path)
|
||||||
|
if (isValue(next)) {
|
||||||
|
let p = next;
|
||||||
|
if (p.startsWith("/models/")) p = p.slice("/models/".length);
|
||||||
|
cfg.mmprojPath = p;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "--model-draft":
|
case "--model-draft":
|
||||||
cfg.draftModel = path.basename(next || "");
|
cfg.draftModel = path.basename(next || "");
|
||||||
i++;
|
i++;
|
||||||
@@ -657,6 +680,11 @@ export function buildLlamaExtraArgs(cfg: DashboardConfig): string {
|
|||||||
parts.push(`--reasoning-format ${cfg.reasoningFormat}`);
|
parts.push(`--reasoning-format ${cfg.reasoningFormat}`);
|
||||||
// Jinja chat templates (required for reasoning format to work properly)
|
// Jinja chat templates (required for reasoning format to work properly)
|
||||||
if (cfg.jinja) parts.push("--jinja");
|
if (cfg.jinja) parts.push("--jinja");
|
||||||
|
// Multimodal vision projector (mmproj) — for vision-language models
|
||||||
|
// like Qwen3-VL, Llama 3.2 Vision, etc.
|
||||||
|
if (cfg.mmprojPath) {
|
||||||
|
parts.push(`--mmproj /models/${cfg.mmprojPath}`);
|
||||||
|
}
|
||||||
if (cfg.extraArgs.trim()) parts.push(cfg.extraArgs.trim());
|
if (cfg.extraArgs.trim()) parts.push(cfg.extraArgs.trim());
|
||||||
return parts.join(" ");
|
return parts.join(" ");
|
||||||
}
|
}
|
||||||
@@ -706,24 +734,78 @@ export async function writeEnvLlamaConfig(
|
|||||||
// Models
|
// Models
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-detect model kind based on filename.
|
||||||
|
* - 'mmproj' — multimodal vision projector (filename contains 'mmproj')
|
||||||
|
* - 'mtp' — speculative decoding draft model (filename contains 'mtp')
|
||||||
|
* - 'draft' — draft model for speculative decoding (filename contains 'draft')
|
||||||
|
* - 'base' — regular model
|
||||||
|
*/
|
||||||
|
export function detectModelKind(filename: string): ModelKind {
|
||||||
|
const lower = filename.toLowerCase();
|
||||||
|
if (lower.includes("mmproj")) return "mmproj";
|
||||||
|
if (lower.includes("mtp")) return "mtp";
|
||||||
|
if (lower.includes("draft")) return "draft";
|
||||||
|
return "base";
|
||||||
|
}
|
||||||
|
|
||||||
export async function listModels(): Promise<ModelFile[]> {
|
export async function listModels(): Promise<ModelFile[]> {
|
||||||
try {
|
try {
|
||||||
const entries = await fs.readdir(LLAMA_MODELS_DIR, { withFileTypes: true });
|
|
||||||
const models: ModelFile[] = [];
|
const models: ModelFile[] = [];
|
||||||
for (const entry of entries) {
|
// Walk the top-level entries. If a subdirectory is found, recurse one
|
||||||
if (!entry.isFile()) continue;
|
// level deep (we don't go deeper — HuggingFace-style repos are flat).
|
||||||
|
const topEntries = await fs.readdir(LLAMA_MODELS_DIR, { withFileTypes: true });
|
||||||
|
for (const entry of topEntries) {
|
||||||
if (entry.name.startsWith(".")) continue;
|
if (entry.name.startsWith(".")) continue;
|
||||||
if (!entry.name.toLowerCase().endsWith(".gguf")) continue;
|
if (entry.isFile()) {
|
||||||
const full = path.join(LLAMA_MODELS_DIR, entry.name);
|
if (!entry.name.toLowerCase().endsWith(".gguf")) continue;
|
||||||
const stat = await fs.stat(full);
|
const full = path.join(LLAMA_MODELS_DIR, entry.name);
|
||||||
models.push({
|
const stat = await fs.stat(full);
|
||||||
name: entry.name,
|
models.push({
|
||||||
sizeBytes: stat.size,
|
name: entry.name,
|
||||||
sizeHuman: humanSize(stat.size),
|
relativePath: entry.name,
|
||||||
modifiedAt: stat.mtime.toISOString(),
|
subdir: "",
|
||||||
});
|
kind: detectModelKind(entry.name),
|
||||||
|
sizeBytes: stat.size,
|
||||||
|
sizeHuman: humanSize(stat.size),
|
||||||
|
modifiedAt: stat.mtime.toISOString(),
|
||||||
|
});
|
||||||
|
} else if (entry.isDirectory()) {
|
||||||
|
// Subdirectory — list .gguf files inside
|
||||||
|
const subdir = entry.name;
|
||||||
|
const subdirPath = path.join(LLAMA_MODELS_DIR, subdir);
|
||||||
|
let subEntries: import("node:fs").Dirent[];
|
||||||
|
try {
|
||||||
|
subEntries = await fs.readdir(subdirPath, { withFileTypes: true });
|
||||||
|
} catch {
|
||||||
|
continue; // permission error etc — skip
|
||||||
|
}
|
||||||
|
for (const subEntry of subEntries) {
|
||||||
|
const subName = String(subEntry.name);
|
||||||
|
if (!subEntry.isFile()) continue;
|
||||||
|
if (subName.startsWith(".")) continue;
|
||||||
|
if (!subName.toLowerCase().endsWith(".gguf")) continue;
|
||||||
|
const full = path.join(subdirPath, subName);
|
||||||
|
const stat = await fs.stat(full);
|
||||||
|
models.push({
|
||||||
|
name: subName,
|
||||||
|
relativePath: `${subdir}/${subName}`,
|
||||||
|
subdir,
|
||||||
|
kind: detectModelKind(subName),
|
||||||
|
sizeBytes: stat.size,
|
||||||
|
sizeHuman: humanSize(stat.size),
|
||||||
|
modifiedAt: stat.mtime.toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
models.sort((a, b) => b.sizeBytes - a.sizeBytes);
|
// Sort: by subdir (group files in same repo together), then by size desc
|
||||||
|
models.sort((a, b) => {
|
||||||
|
if (a.subdir !== b.subdir) {
|
||||||
|
return a.subdir.localeCompare(b.subdir);
|
||||||
|
}
|
||||||
|
return b.sizeBytes - a.sizeBytes;
|
||||||
|
});
|
||||||
return models;
|
return models;
|
||||||
} catch {
|
} catch {
|
||||||
return [];
|
return [];
|
||||||
@@ -1499,11 +1581,33 @@ export async function getComfyQueue(): Promise<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function addComfyModel(
|
export async function addComfyModel(
|
||||||
url: string,
|
rawUrl: string,
|
||||||
type: string
|
type: string
|
||||||
): Promise<{ ok: boolean; output: string; error?: string }> {
|
): Promise<{
|
||||||
|
ok: boolean;
|
||||||
|
output: string;
|
||||||
|
error?: string;
|
||||||
|
originalUrl?: string;
|
||||||
|
transformedUrl?: string;
|
||||||
|
urlNote?: string;
|
||||||
|
}> {
|
||||||
|
// Apply CivitAI URL transformation (model page → API download URL, append token).
|
||||||
|
// We lazy-load the imports here so docker.ts doesn't pull in downloads.ts at
|
||||||
|
// module-load time (avoids circular import concerns).
|
||||||
|
const { prepareCivitaiUrl, loadSettings } = await import("./downloads");
|
||||||
|
const settings = await loadSettings();
|
||||||
|
const { url, note } = prepareCivitaiUrl(rawUrl, settings.civitaiToken || "");
|
||||||
|
|
||||||
const res = await modelWorkerExec("add", url, type);
|
const res = await modelWorkerExec("add", url, type);
|
||||||
return { ok: res.ok, output: res.output, error: res.error };
|
return {
|
||||||
|
ok: res.ok,
|
||||||
|
output: res.output,
|
||||||
|
error: res.error,
|
||||||
|
// Only include transformation metadata if we actually changed something
|
||||||
|
originalUrl: rawUrl !== url ? rawUrl : undefined,
|
||||||
|
transformedUrl: rawUrl !== url ? url : undefined,
|
||||||
|
urlNote: note || undefined,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function removeComfyModel(
|
export async function removeComfyModel(
|
||||||
@@ -1660,13 +1764,24 @@ export async function saveUploadedModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteModel(
|
export async function deleteModel(
|
||||||
filename: string
|
relativePath: string
|
||||||
): Promise<{ ok: boolean; error?: string }> {
|
): Promise<{ ok: boolean; error?: string }> {
|
||||||
const safe = path.basename(filename).replace(/[^\w.\-]/g, "_");
|
// relativePath can be "model.gguf" or "Qwen3-VL/Qwen3-VL-Q8_0.gguf"
|
||||||
|
// Sanitize each path segment to prevent path traversal
|
||||||
|
const segments = relativePath.split("/").map((s) =>
|
||||||
|
s.replace(/[^\w.\-]/g, "_")
|
||||||
|
);
|
||||||
|
const safe = segments.join("/");
|
||||||
if (!safe.toLowerCase().endsWith(".gguf")) {
|
if (!safe.toLowerCase().endsWith(".gguf")) {
|
||||||
return { ok: false, error: "Only .gguf files are allowed" };
|
return { ok: false, error: "Only .gguf files are allowed" };
|
||||||
}
|
}
|
||||||
const full = path.join(LLAMA_MODELS_DIR, safe);
|
const full = path.join(LLAMA_MODELS_DIR, safe);
|
||||||
|
// Ensure the resulting path is still under LLAMA_MODELS_DIR
|
||||||
|
const resolvedFull = path.resolve(full);
|
||||||
|
const resolvedBase = path.resolve(LLAMA_MODELS_DIR);
|
||||||
|
if (!resolvedFull.startsWith(resolvedBase + path.sep) && resolvedFull !== resolvedBase) {
|
||||||
|
return { ok: false, error: "Path traversal detected" };
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await fs.unlink(full);
|
await fs.unlink(full);
|
||||||
return { ok: true };
|
return { ok: true };
|
||||||
|
|||||||
@@ -213,15 +213,35 @@ export async function startModelDownload(
|
|||||||
throw new Error(`only http(s) URLs are supported, got: ${parsed.protocol}`);
|
throw new Error(`only http(s) URLs are supported, got: ${parsed.protocol}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine filename
|
// Determine filename and optional subdirectory
|
||||||
let filename: string;
|
let filename: string;
|
||||||
|
let subdir: string = "";
|
||||||
if (filenameOverride) {
|
if (filenameOverride) {
|
||||||
filename = filenameOverride;
|
filename = filenameOverride;
|
||||||
} else {
|
} else {
|
||||||
// Use last URL path segment, strip query string
|
// Use last URL path segment, strip query string
|
||||||
const pathname = parsed.pathname;
|
const pathname = parsed.pathname;
|
||||||
const last = pathname.split("/").filter(Boolean).pop() || "model.gguf";
|
const segments = pathname.split("/").filter(Boolean);
|
||||||
|
const last = segments.pop() || "model.gguf";
|
||||||
filename = last;
|
filename = last;
|
||||||
|
// For HuggingFace URLs: /<user>/<repo>/resolve/main/<file>
|
||||||
|
// → subdir = "<repo>" (just the repo name, not user___repo)
|
||||||
|
// For GitHub releases: /<user>/<repo>/releases/download/<tag>/<file>
|
||||||
|
// → subdir = "<repo>"
|
||||||
|
const host = parsed.hostname.toLowerCase();
|
||||||
|
if (host === "huggingface.co" || host === "hf.co") {
|
||||||
|
// HF URL: /user/repo/resolve/branch/file
|
||||||
|
if (segments.length >= 2) {
|
||||||
|
const repo = segments[1];
|
||||||
|
subdir = repo.replace(/[^\w.\-]/g, "_");
|
||||||
|
}
|
||||||
|
} else if (host === "github.com" && segments.includes("releases")) {
|
||||||
|
// GitHub: /user/repo/releases/download/tag/file
|
||||||
|
if (segments.length >= 2) {
|
||||||
|
const repo = segments[1];
|
||||||
|
subdir = repo.replace(/[^\w.\-]/g, "_");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanitize: only allow .gguf extension, no path traversal
|
// Sanitize: only allow .gguf extension, no path traversal
|
||||||
@@ -231,9 +251,15 @@ export async function startModelDownload(
|
|||||||
// Many HuggingFace URLs use ?download=true; ignore query.
|
// Many HuggingFace URLs use ?download=true; ignore query.
|
||||||
filename = `${filename}.gguf`;
|
filename = `${filename}.gguf`;
|
||||||
}
|
}
|
||||||
|
if (subdir) {
|
||||||
|
subdir = subdir.replace(/[^\w.\-]/g, "_");
|
||||||
|
}
|
||||||
|
|
||||||
// Check we don't overwrite an existing file (race-safe via atomic rename)
|
// If subdir is set, create it and download there
|
||||||
const dest = path.join(LLAMA_MODELS_DIR, filename);
|
const destDir = subdir
|
||||||
|
? path.join(LLAMA_MODELS_DIR, subdir)
|
||||||
|
: LLAMA_MODELS_DIR;
|
||||||
|
const dest = path.join(destDir, filename);
|
||||||
const tmpDest = `${dest}.part`;
|
const tmpDest = `${dest}.part`;
|
||||||
|
|
||||||
const id = `dl-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
const id = `dl-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
||||||
@@ -242,7 +268,7 @@ export async function startModelDownload(
|
|||||||
url,
|
url,
|
||||||
originalUrl: rawUrl !== url ? rawUrl : undefined,
|
originalUrl: rawUrl !== url ? rawUrl : undefined,
|
||||||
urlNote: urlNote || undefined,
|
urlNote: urlNote || undefined,
|
||||||
filename,
|
filename: subdir ? `${subdir}/${filename}` : filename,
|
||||||
status: "queued",
|
status: "queued",
|
||||||
bytesDownloaded: 0,
|
bytesDownloaded: 0,
|
||||||
bytesTotal: null,
|
bytesTotal: null,
|
||||||
|
|||||||
15
dashboard/src/lib/version.ts
Normal file
15
dashboard/src/lib/version.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* Dashboard version — bump this on every PR merge.
|
||||||
|
*
|
||||||
|
* Displayed in the footer and available via /api/debug so the user can
|
||||||
|
* verify the update actually took effect.
|
||||||
|
*/
|
||||||
|
export const DASHBOARD_VERSION = "0.5.0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build timestamp — set at build time by Next.js.
|
||||||
|
* Falls back to "dev" when running in dev mode.
|
||||||
|
*/
|
||||||
|
export const BUILD_ID =
|
||||||
|
process.env.NEXT_PUBLIC_BUILD_ID ||
|
||||||
|
(process.env.NODE_ENV === "production" ? "prod" : "dev");
|
||||||
@@ -163,6 +163,19 @@ wake_mode() {
|
|||||||
webdav \
|
webdav \
|
||||||
dashboard
|
dashboard
|
||||||
|
|
||||||
|
# Belt-and-suspenders: ensure dashboard is up even if the --profile wake
|
||||||
|
# flag above didn't include it (compose v2 with --profile + explicit names
|
||||||
|
# should work, but older versions may skip services without a matching
|
||||||
|
# profile).
|
||||||
|
DASHBOARD_CTR=$(get_service_container "dashboard" 2>/dev/null) || DASHBOARD_CTR=""
|
||||||
|
if [ -z "$DASHBOARD_CTR" ] || ! container_is_running "$DASHBOARD_CTR"; then
|
||||||
|
echo "Dashboard not running after wake — starting it explicitly..."
|
||||||
|
HOST_PROJECT_PATH="$HOST_PROJECT_PATH" \
|
||||||
|
docker compose \
|
||||||
|
-f "$COMPOSE_FILE" \
|
||||||
|
up -d dashboard
|
||||||
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Containers:"
|
echo "Containers:"
|
||||||
show_status
|
show_status
|
||||||
|
|||||||
Reference in New Issue
Block a user