offgrid-ai 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli.mjs +7 -4
- package/src/logs.mjs +7 -0
- package/src/profile-setup.mjs +25 -1
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -637,12 +637,15 @@ async function runProfile(profile, options = {}) {
|
|
|
637
637
|
// Show memory estimate for local models
|
|
638
638
|
if (!isManaged && profile.modelPath && existsSync(profile.modelPath)) {
|
|
639
639
|
try {
|
|
640
|
-
const est = estimateMemory(profile.modelPath, profile.mmprojPath,
|
|
641
|
-
|
|
640
|
+
const est = estimateMemory(profile.modelPath, profile.mmprojPath, profile.drafterPath, profile.flags);
|
|
641
|
+
const rows = [
|
|
642
642
|
["Estimated total", pc.bold(`~${formatBytes(est.totalBytes)}`)],
|
|
643
643
|
["Model file", formatBytes(est.modelBytes)],
|
|
644
|
-
|
|
645
|
-
|
|
644
|
+
];
|
|
645
|
+
if (est.draftBytes) rows.push(["Drafter", formatBytes(est.draftBytes)]);
|
|
646
|
+
if (est.mmprojBytes) rows.push(["Vision projector", formatBytes(est.mmprojBytes)]);
|
|
647
|
+
rows.push(["Conversation memory", est.kvBytes ? `~${formatBytes(est.kvBytes)}` : "unknown"]);
|
|
648
|
+
console.log(renderSection("Memory estimate", renderRows(rows)));
|
|
646
649
|
} catch { /* estimate failed, skip */ }
|
|
647
650
|
}
|
|
648
651
|
|
package/src/logs.mjs
CHANGED
|
@@ -32,6 +32,13 @@ export function tailFriendly(rawLogPath, friendlyLogPath) {
|
|
|
32
32
|
function friendlyLine(line) {
|
|
33
33
|
const lower = line.toLowerCase();
|
|
34
34
|
const trimmed = line.trim();
|
|
35
|
+
// Known-harmless errors during MTP memory estimation — llama.cpp tries to measure
|
|
36
|
+
// the draft model's memory usage before allocating the shared KV cache, which
|
|
37
|
+
// fails because the assistant architecture needs the trunk context. This is
|
|
38
|
+
// expected and the server proceeds to load the draft model correctly afterward.
|
|
39
|
+
if (lower.includes("ctx_other") || lower.includes("failed to measure draft model memory")) {
|
|
40
|
+
return pc.dim(`[mtp] ${trimmed}`);
|
|
41
|
+
}
|
|
35
42
|
if (lower.includes("error") || lower.includes("failed")) return pc.red(`[error] ${trimmed}`);
|
|
36
43
|
if (lower.includes("listening") || lower.includes("http server")) return pc.green(`[server] ${trimmed}`);
|
|
37
44
|
if (lower.includes("llm_load") || lower.includes("load_model") || lower.includes("loading model")) return pc.cyan(`[load] ${trimmed}`);
|
package/src/profile-setup.mjs
CHANGED
|
@@ -4,6 +4,9 @@ import { estimateMemory } from "./estimate.mjs";
|
|
|
4
4
|
import { findLlamaServer } from "./config.mjs";
|
|
5
5
|
import { baseUrlForFlags, LLAMA_CPP_PORT, LLAMA_CPP_MTP_PORT } from "./backends.mjs";
|
|
6
6
|
import { pc, formatBytes, renderRows, renderSection } from "./ui.mjs";
|
|
7
|
+
import { detectCapabilities } from "./autodetect.mjs";
|
|
8
|
+
import { matchDrafter } from "./scan.mjs";
|
|
9
|
+
import { scanGgufModels } from "./scan.mjs";
|
|
7
10
|
|
|
8
11
|
const execFileAsync = promisify(execFile);
|
|
9
12
|
|
|
@@ -29,7 +32,28 @@ const THINKING_DEFAULTS = {
|
|
|
29
32
|
|
|
30
33
|
export async function configureLocalProfile(prompt, profile) {
|
|
31
34
|
let configured = profile;
|
|
32
|
-
|
|
35
|
+
// Re-detect capabilities from the model file and check for drafters
|
|
36
|
+
// so that re-setup can pick up MTP availability, vision changes, etc.
|
|
37
|
+
const freshCaps = detectCapabilities(profile.modelPath, profile.mmprojPath);
|
|
38
|
+
let drafterPath = profile.drafterPath ?? null;
|
|
39
|
+
if (!drafterPath) {
|
|
40
|
+
const { drafters } = await scanGgufModels();
|
|
41
|
+
const drafter = matchDrafter(profile.modelPath, drafters);
|
|
42
|
+
if (drafter) drafterPath = drafter.path;
|
|
43
|
+
}
|
|
44
|
+
const hasMtp = freshCaps.mtp || Boolean(drafterPath);
|
|
45
|
+
const caps = { ...freshCaps, mtp: hasMtp };
|
|
46
|
+
// If MTP is newly available, switch backend and add drafter path
|
|
47
|
+
if (hasMtp && configured.backend !== "llama-cpp-mtp") {
|
|
48
|
+
configured = { ...configured, backend: "llama-cpp-mtp", providerId: "llama-cpp-mtp", drafterPath, capabilities: { ...configured.capabilities, mtp: true } };
|
|
49
|
+
}
|
|
50
|
+
if (drafterPath && !configured.drafterPath) {
|
|
51
|
+
configured = { ...configured, drafterPath };
|
|
52
|
+
}
|
|
53
|
+
// If vision was previously disabled but mmproj is back, re-enable
|
|
54
|
+
if (configured.disabledMmprojPath && configured.mmprojPath === null && freshCaps.vision) {
|
|
55
|
+
configured = { ...configured, mmprojPath: configured.disabledMmprojPath, disabledMmprojPath: undefined, capabilities: { ...configured.capabilities, vision: true, visionDisabledReason: undefined } };
|
|
56
|
+
}
|
|
33
57
|
|
|
34
58
|
console.log("");
|
|
35
59
|
console.log(renderSection("Model setup", renderRows([
|