feat: cookbook (Feature 4)
This commit is contained in:
@@ -2,27 +2,10 @@
|
||||
|
||||
import { api } from "../core/api.js";
|
||||
import { $, badge, esc, toast } from "../core/ui.js";
|
||||
import { track } from "./jobs.js";
|
||||
|
||||
function refreshSoon() { document.dispatchEvent(new Event("mc:refresh")); }
|
||||
|
||||
function mount() {
|
||||
$("#m-download").innerHTML = `
|
||||
<div class="card-h"><h3>Modell holen</h3></div>
|
||||
<label>HuggingFace-Repo</label>
|
||||
<input id="dl-repo" placeholder="unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF">
|
||||
<label>Datei (GGUF)</label>
|
||||
<input id="dl-file" placeholder="Q4_K_M/Qwen3-Coder-30B-A3B-Instruct-Q4_K_M.gguf">
|
||||
<button class="primary" id="dl-btn">Modell herunterladen</button>
|
||||
<div id="register-box" style="display:none;margin-top:16px;border-top:1px solid var(--line);padding-top:14px">
|
||||
<div class="card-h"><h3>Einpflegen</h3></div>
|
||||
<div class="row">
|
||||
<div><label>Alias</label><input id="rg-alias"></div>
|
||||
<div><label>Kontext</label><input id="rg-ctx" value="8192"></div>
|
||||
</div>
|
||||
<input id="rg-path" class="mono-sm" readonly>
|
||||
<button class="primary" id="rg-btn">In Config eintragen</button>
|
||||
</div>`;
|
||||
|
||||
$("#m-chat").innerHTML = `
|
||||
<div class="card-h"><h3>Schnelltest</h3></div>
|
||||
@@ -41,8 +24,6 @@ function mount() {
|
||||
</table>
|
||||
<div id="models-empty" class="empty" style="display:none">Noch keine Modelle konfiguriert — zieh dir oben eins rein. 👇</div>`;
|
||||
|
||||
$("#dl-btn").addEventListener("click", pull);
|
||||
$("#rg-btn").addEventListener("click", register);
|
||||
$("#chat-btn").addEventListener("click", sendChat);
|
||||
}
|
||||
|
||||
@@ -95,32 +76,6 @@ function onStatus(s) {
|
||||
);
|
||||
}
|
||||
|
||||
async function pull() {
|
||||
const repo = $("#dl-repo").value.trim(), file = $("#dl-file").value.trim();
|
||||
if (!repo || !file) return toast("Repo und Datei angeben.", true);
|
||||
try {
|
||||
const r = await api("/api/download", { method: "POST", body: JSON.stringify({ repo, file }) });
|
||||
toast("Download gestartet.");
|
||||
const stem = file.split("/").pop().replace(/\.gguf$/i, "");
|
||||
$("#rg-alias").value = stem;
|
||||
$("#rg-path").value = r.expected_path;
|
||||
$("#register-box").style.display = "block";
|
||||
track(r.job_id);
|
||||
} catch (e) { toast(e.message, true); }
|
||||
}
|
||||
|
||||
async function register() {
|
||||
const alias = $("#rg-alias").value.trim();
|
||||
const model_path = $("#rg-path").value;
|
||||
const ctx = parseInt($("#rg-ctx").value) || 8192;
|
||||
if (!alias) return toast("Alias angeben.", true);
|
||||
try {
|
||||
await api("/api/register", { method: "POST", body: JSON.stringify({ alias, model_path, ctx }) });
|
||||
toast("Eingepflegt — llama-swap lädt neu.");
|
||||
refreshSoon();
|
||||
} catch (e) { toast(e.message, true); }
|
||||
}
|
||||
|
||||
async function unloadOne(m) {
|
||||
try {
|
||||
await api("/api/unload?model=" + encodeURIComponent(m), { method: "POST" });
|
||||
|
||||
Reference in New Issue
Block a user