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;
}