- deployments + deployment_logs tables; desired/actual state reconciled by the worker (create/start/stop/remove via the socket proxy, /health wait, log follower, stats, memory guard, adopt/remove containers on restart). - Pure command builder for llama-server and vllm serve (mmproj, MTP draft, KV cache types, dtype, KV cache size) with tests; file candidates per engine with tests. - New main menu entry Deployments: list, new/edit form (runtime -> model and files -> launch options, live command preview), detail page with stats, log, endpoint and a streaming chat smoke test. Not yet tested end-to-end against real containers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
2.0 KiB
TypeScript
42 lines
2.0 KiB
TypeScript
// Which downloaded files a runtime can serve. Pure; shared by the server and the deployment form.
|
|
|
|
import type { RuntimeEngine } from "@/lib/db/schema";
|
|
import { groupSplitFiles } from "@/lib/file-groups";
|
|
import { fileRole } from "@/lib/file-roles";
|
|
|
|
export type LocalFile = { path: string; size: number };
|
|
export type CandidateFile = { path: string; size: number; parts: number };
|
|
export type DraftFile = CandidateFile & { type: "draft-mtp" | "draft-simple" };
|
|
|
|
export type ModelCandidates = {
|
|
/** llama.cpp: loadable GGUF weights (split files as their first part), plus optional extras. */
|
|
gguf: CandidateFile[];
|
|
mmproj: CandidateFile[];
|
|
drafts: DraftFile[];
|
|
/** vLLM: the repo folder has a config.json and safetensors weights. */
|
|
vllm: { size: number } | null;
|
|
};
|
|
|
|
const isGguf = (p: string) => p.toLowerCase().endsWith(".gguf");
|
|
|
|
/** `files`: the model's files that are on disk (present or verified). */
|
|
export function modelCandidates(files: LocalFile[]): ModelCandidates {
|
|
const entries = (pred: (p: string) => boolean) =>
|
|
groupSplitFiles(files.filter((f) => pred(f.path))).map((g) => ({ path: g.parts[0].path, size: g.size, parts: g.totalParts }));
|
|
|
|
const gguf = entries((p) => isGguf(p) && fileRole(p) === "model");
|
|
const mmproj = entries((p) => isGguf(p) && fileRole(p) === "vision");
|
|
const drafts: DraftFile[] = [
|
|
...entries((p) => isGguf(p) && fileRole(p) === "mtp").map((f) => ({ ...f, type: "draft-mtp" as const })),
|
|
...entries((p) => isGguf(p) && fileRole(p) === "draft").map((f) => ({ ...f, type: "draft-simple" as const })),
|
|
];
|
|
const hasConfig = files.some((f) => f.path === "config.json");
|
|
const safetensors = files.filter((f) => f.path.endsWith(".safetensors") && fileRole(f.path) === "model");
|
|
const vllm = hasConfig && safetensors.length > 0 ? { size: files.reduce((s, f) => s + f.size, 0) } : null;
|
|
return { gguf, mmproj, drafts, vllm };
|
|
}
|
|
|
|
export function servableBy(c: ModelCandidates, engine: RuntimeEngine): boolean {
|
|
return engine === "llama.cpp" ? c.gguf.length > 0 : c.vllm !== null;
|
|
}
|