nlos 1.4.0 → 1.5.0
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/bin/nlos.js +60 -7
- package/package.json +1 -1
package/bin/nlos.js
CHANGED
|
@@ -112,6 +112,40 @@ function showTokens() {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
// Minimal kernel for small models (~500 tokens)
|
|
116
|
+
const MINIMAL_KERNEL = `# YOU ARE NL-OS
|
|
117
|
+
|
|
118
|
+
You are NL-OS, a Natural Language Operating System. You help users think and work.
|
|
119
|
+
|
|
120
|
+
## YOUR FIRST RESPONSE
|
|
121
|
+
|
|
122
|
+
Say exactly: "NL-OS ready."
|
|
123
|
+
|
|
124
|
+
## COMMANDS
|
|
125
|
+
|
|
126
|
+
When user message starts with ">", it is a command. Execute it:
|
|
127
|
+
|
|
128
|
+
>hype = Give 1-2 sentences of encouragement about their work
|
|
129
|
+
>note TEXT = Say "Noted." (do not do anything with TEXT)
|
|
130
|
+
>help = Say "Commands: >hype >note >help >deep >assume"
|
|
131
|
+
>deep = Say "Deep mode on." Then think step-by-step
|
|
132
|
+
>assume NAME = Say "Now acting as NAME." Then roleplay as NAME
|
|
133
|
+
|
|
134
|
+
## RULES
|
|
135
|
+
|
|
136
|
+
1. ">" means command - execute it immediately
|
|
137
|
+
2. Be helpful, concise, no emojis
|
|
138
|
+
3. If unsure, ask for clarification
|
|
139
|
+
|
|
140
|
+
## EXAMPLE
|
|
141
|
+
|
|
142
|
+
User: >hype
|
|
143
|
+
Assistant: You're making real progress. Keep that momentum going.
|
|
144
|
+
|
|
145
|
+
User: hello
|
|
146
|
+
Assistant: Hello! How can I help you today?
|
|
147
|
+
`;
|
|
148
|
+
|
|
115
149
|
// Command preamble - explicit rules that help ALL models parse commands correctly
|
|
116
150
|
const COMMAND_PREAMBLE = `# YOU ARE NL-OS (Natural Language Operating System)
|
|
117
151
|
|
|
@@ -287,6 +321,7 @@ function chat(options = {}) {
|
|
|
287
321
|
const {
|
|
288
322
|
model = 'qwen2.5:3b',
|
|
289
323
|
full = false,
|
|
324
|
+
minimal = false,
|
|
290
325
|
profile = null,
|
|
291
326
|
} = options;
|
|
292
327
|
|
|
@@ -304,18 +339,24 @@ function chat(options = {}) {
|
|
|
304
339
|
|
|
305
340
|
log('blue', `Starting NL-OS chat session...`);
|
|
306
341
|
log('cyan', `Model: ${selectedModel}`);
|
|
307
|
-
log('cyan', `Tier: ${full ? 'FULL' : 'MANDATORY'}`);
|
|
342
|
+
log('cyan', `Tier: ${minimal ? 'MINIMAL' : full ? 'FULL' : 'MANDATORY'}`);
|
|
308
343
|
console.log();
|
|
309
344
|
|
|
310
345
|
// Generate the kernel payload
|
|
311
346
|
log('yellow', 'Building kernel payload...');
|
|
312
|
-
const payload = generatePayload(full ? 'full' : 'mandatory', 'markdown');
|
|
313
347
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
348
|
+
let payload;
|
|
349
|
+
let tokenEstimate;
|
|
350
|
+
|
|
351
|
+
if (minimal) {
|
|
352
|
+
// Use minimal kernel for small models
|
|
353
|
+
payload = MINIMAL_KERNEL;
|
|
354
|
+
tokenEstimate = '~500';
|
|
355
|
+
} else {
|
|
356
|
+
payload = generatePayload(full ? 'full' : 'mandatory', 'markdown');
|
|
357
|
+
tokenEstimate = full ? '~15,500' : '~10,600';
|
|
358
|
+
}
|
|
317
359
|
|
|
318
|
-
const tokenEstimate = full ? '~15,500' : '~10,600';
|
|
319
360
|
log('green', `Kernel payload ready (${tokenEstimate} tokens)`);
|
|
320
361
|
console.log();
|
|
321
362
|
|
|
@@ -337,6 +378,14 @@ function chat(options = {}) {
|
|
|
337
378
|
const modelfilePath = path.join(PACKAGE_ROOT, 'portable', '.Modelfile.nlos');
|
|
338
379
|
const nlosModelName = 'nlos-kernel:latest';
|
|
339
380
|
|
|
381
|
+
// Delete old model to ensure fresh kernel
|
|
382
|
+
try {
|
|
383
|
+
execSync(`ollama rm ${nlosModelName}`, { stdio: 'pipe' });
|
|
384
|
+
log('cyan', 'Removed old kernel model');
|
|
385
|
+
} catch {
|
|
386
|
+
// Model didn't exist, that's fine
|
|
387
|
+
}
|
|
388
|
+
|
|
340
389
|
const modelfileContent = `FROM ${selectedModel}
|
|
341
390
|
SYSTEM """${payload}"""
|
|
342
391
|
`;
|
|
@@ -443,9 +492,10 @@ ${colors.yellow}Commands:${colors.reset}
|
|
|
443
492
|
tokens Show token estimates
|
|
444
493
|
help Show this help message
|
|
445
494
|
|
|
446
|
-
${colors.yellow}Boot Options:${colors.reset}
|
|
495
|
+
${colors.yellow}Chat/Boot Options:${colors.reset}
|
|
447
496
|
--model <name> Model to use (default: qwen2.5:3b)
|
|
448
497
|
--profile <name> Use profile: speed, balanced, quality, memory_constrained
|
|
498
|
+
--minimal Use minimal ~500 token kernel (best for small models)
|
|
449
499
|
--full Load full kernel (includes personalities)
|
|
450
500
|
--dry-run Preview system prompt without launching
|
|
451
501
|
--runtime <name> Runtime: ollama, llama-cpp, lm-studio (default: ollama)
|
|
@@ -458,6 +508,7 @@ ${colors.yellow}Payload Options:${colors.reset}
|
|
|
458
508
|
|
|
459
509
|
${colors.yellow}Examples:${colors.reset}
|
|
460
510
|
nlos chat # Start interactive chat (recommended)
|
|
511
|
+
nlos chat --minimal # Use minimal kernel for small models (3B)
|
|
461
512
|
nlos chat --model llama3.1:8b # Chat with specific model
|
|
462
513
|
nlos chat --profile quality --full # Quality mode with full kernel
|
|
463
514
|
nlos boot # Verify kernel loads (one-shot)
|
|
@@ -494,6 +545,8 @@ function parseArgs(args) {
|
|
|
494
545
|
options.runtime = args[++i];
|
|
495
546
|
} else if (arg === '--full') {
|
|
496
547
|
options.full = true;
|
|
548
|
+
} else if (arg === '--minimal') {
|
|
549
|
+
options.minimal = true;
|
|
497
550
|
} else if (arg === '--dry-run') {
|
|
498
551
|
options.dryRun = true;
|
|
499
552
|
} else if (arg === '--all') {
|