many fixes

This commit is contained in:
2026-05-23 18:18:58 +08:00
parent 282085c384
commit f63125e945
19 changed files with 858 additions and 41 deletions
+40 -8
View File
@@ -894,19 +894,46 @@ async function sendMessage() {
async function checkRuntime() {
try {
await jsonFetch("/health");
const status = await jsonFetch("/v1/status?probe=true");
const services = status.services || {};
const llama = services.llama || {};
const vector = services.vector_memory || {};
const roles = Object.keys(status.models?.roles || {}).sort();
setStatus("#api-status", "online", "ok");
setStatus("#model-status", serviceStatusText(llama), serviceTone(llama));
setStatus("#vector-status", serviceStatusText(vector), serviceTone(vector));
setStatus("#embedding-status", compactEmbeddingSource(vector.embedding_source), vector.configured ? "ok" : "warn");
setStatus("#roles-status", roles.length ? String(roles.length) : "none", roles.length ? "ok" : "warn");
} catch {
setStatus("#api-status", "offline", "bad");
setStatus("#model-status", "unknown", "bad");
setStatus("#vector-status", "unknown", "bad");
setStatus("#embedding-status", "unknown", "bad");
setStatus("#roles-status", "unknown", "bad");
}
}
try {
const roles = await jsonFetch("/v1/models/ping");
const ok = Object.values(roles).every((item) => item.ok);
setStatus("#model-status", ok ? "online" : "degraded", ok ? "ok" : "warn");
} catch {
setStatus("#model-status", "offline", "bad");
function serviceStatusText(service) {
if (!service || service.probed === false) return "not probed";
if (service.ok === true) {
return service.latency_ms !== undefined ? `ok ${Math.round(service.latency_ms)}ms` : "ok";
}
if (service.ok === false) return "failed";
return service.configured === false ? "disabled" : "unknown";
}
function serviceTone(service) {
if (!service || service.ok === false) return "bad";
if (service.ok === true) return "ok";
return service.configured === false ? "warn" : "neutral";
}
function compactEmbeddingSource(source) {
if (!source) return "unknown";
if (source.startsWith("local:")) return source.slice(6).split("/").filter(Boolean).pop() || "local";
if (source.startsWith("remote:")) return "remote";
return source;
}
function bindChat() {
@@ -928,6 +955,9 @@ function bindChat() {
document.querySelector("#reload-chat")?.addEventListener("click", () => {
if (state.currentConversationId) selectConversation(state.currentConversationId).catch(console.error);
});
document.querySelector("#refresh-runtime")?.addEventListener("click", () => {
checkRuntime().catch(console.error);
});
document.querySelector("#activity-open")?.addEventListener("click", () => {
openActivity("events");
});
@@ -1114,7 +1144,9 @@ async function renderMemoryPageResults(query) {
if (!results.length) {
const empty = document.createElement("p");
empty.className = "compact-empty";
empty.textContent = "No memories found.";
empty.textContent = query.trim()
? "No matching memories."
: "No memories yet. Add one here or let DuckLM store useful task results automatically.";
container.append(empty);
return;
}
+18 -3
View File
@@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>DuckLM WebChat</title>
<link rel="stylesheet" href="/static/style.css">
<link rel="stylesheet" href="/static/style.css?v=20260523-runtime-status">
</head>
<body>
<div class="app-shell">
@@ -53,7 +53,10 @@
</section>
<section class="status-panel" aria-labelledby="status-title">
<h2 id="status-title">Runtime</h2>
<div class="panel-heading">
<h2 id="status-title">Runtime</h2>
<button id="refresh-runtime" type="button" title="Refresh runtime status">R</button>
</div>
<dl>
<div>
<dt>API</dt>
@@ -63,6 +66,18 @@
<dt>Model</dt>
<dd id="model-status">checking</dd>
</div>
<div>
<dt>Vector</dt>
<dd id="vector-status">checking</dd>
</div>
<div>
<dt>Embed</dt>
<dd id="embedding-status">checking</dd>
</div>
<div>
<dt>Roles</dt>
<dd id="roles-status">checking</dd>
</div>
<div>
<dt>Last task</dt>
<dd id="task-status">none</dd>
@@ -146,6 +161,6 @@
</section>
</aside>
</div>
<script src="/static/app.js"></script>
<script src="/static/app.js?v=20260523-runtime-status"></script>
</body>
</html>
+2 -2
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>DuckLM Memory</title>
<link rel="stylesheet" href="/static/style.css">
<link rel="stylesheet" href="/static/style.css?v=20260523-runtime-status">
</head>
<body>
<main class="simple-page">
@@ -28,6 +28,6 @@
<div id="memory-results" class="memory-list"></div>
</section>
</main>
<script src="/static/app.js"></script>
<script src="/static/app.js?v=20260523-runtime-status"></script>
</body>
</html>