@aryacode/dsh-local-llm 0.8.4 → 0.8.6
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/lib/index.d.ts +22 -4
- package/lib/index.js +42 -13
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1610,10 +1610,13 @@ declare const LIBRARY_PROVIDER = "local-library";
|
|
|
1610
1610
|
/**
|
|
1611
1611
|
* The per-request output default this adapter publishes for one model.
|
|
1612
1612
|
*
|
|
1613
|
-
*
|
|
1614
|
-
*
|
|
1615
|
-
*
|
|
1616
|
-
*
|
|
1613
|
+
* It scales with the window the engine actually serves: a quarter of it, floored
|
|
1614
|
+
* at 1,024 tokens and bounded by the engine's own allowance when one is known.
|
|
1615
|
+
* A fixed 8K used to cap every model here, which silently truncated long answers
|
|
1616
|
+
* and made a 100K- or 256K-token engine behave like an 8K one.
|
|
1617
|
+
*
|
|
1618
|
+
* @param context - the model's served context window in tokens.
|
|
1619
|
+
* @param ceiling - the engine's maximum response allowance, when it declares one.
|
|
1617
1620
|
*/
|
|
1618
1621
|
declare function outputDefault(context: number, ceiling?: number): number;
|
|
1619
1622
|
/** Where the Strata engine's own OpenAI-compatible surface answers, and how to authorize it. */
|
|
@@ -1731,11 +1734,20 @@ declare class NInferController {
|
|
|
1731
1734
|
distribution: string;
|
|
1732
1735
|
binary: string;
|
|
1733
1736
|
libraryPath: string;
|
|
1737
|
+
terminateOnStop?: boolean;
|
|
1734
1738
|
};
|
|
1735
1739
|
});
|
|
1736
1740
|
/** Resolve saved tuning or validated deployment defaults. */
|
|
1737
1741
|
settings(): NInferSettings;
|
|
1738
1742
|
private callWsl;
|
|
1743
|
+
/**
|
|
1744
|
+
* Shut the distro down after the engine stops, so the WSL VM gives its memory back.
|
|
1745
|
+
*
|
|
1746
|
+
* `wsl --terminate` is the only lever that returns the distro's RAM: stopping
|
|
1747
|
+
* the binary leaves systemd and the utility VM resident. A distro that is
|
|
1748
|
+
* already stopped makes the call a no-op, so a failure here is not an error.
|
|
1749
|
+
*/
|
|
1750
|
+
private terminateDistro;
|
|
1739
1751
|
/** A container this Host may reclaim; a missing Docker or an unrelated one is no takeover. */
|
|
1740
1752
|
private external;
|
|
1741
1753
|
private wslStatus;
|
|
@@ -1792,6 +1804,12 @@ declare class NInferController {
|
|
|
1792
1804
|
ok: boolean;
|
|
1793
1805
|
detail: string;
|
|
1794
1806
|
}>;
|
|
1807
|
+
/**
|
|
1808
|
+
* Stop the engine, and by default hand the WSL distro's memory back.
|
|
1809
|
+
*
|
|
1810
|
+
* @param terminate - terminate the WSL distro after the engine stops; a start
|
|
1811
|
+
* or restart passes `false` because it is about to use that distro again.
|
|
1812
|
+
*/
|
|
1795
1813
|
private stop;
|
|
1796
1814
|
/** Stop the external container that is provably this installation's engine. */
|
|
1797
1815
|
private takeOver;
|
package/lib/index.js
CHANGED
|
@@ -2605,13 +2605,16 @@ const LIBRARY_PROVIDER = "local-library";
|
|
|
2605
2605
|
/**
|
|
2606
2606
|
* The per-request output default this adapter publishes for one model.
|
|
2607
2607
|
*
|
|
2608
|
-
*
|
|
2609
|
-
*
|
|
2610
|
-
*
|
|
2611
|
-
*
|
|
2608
|
+
* It scales with the window the engine actually serves: a quarter of it, floored
|
|
2609
|
+
* at 1,024 tokens and bounded by the engine's own allowance when one is known.
|
|
2610
|
+
* A fixed 8K used to cap every model here, which silently truncated long answers
|
|
2611
|
+
* and made a 100K- or 256K-token engine behave like an 8K one.
|
|
2612
|
+
*
|
|
2613
|
+
* @param context - the model's served context window in tokens.
|
|
2614
|
+
* @param ceiling - the engine's maximum response allowance, when it declares one.
|
|
2612
2615
|
*/
|
|
2613
|
-
function outputDefault(context, ceiling =
|
|
2614
|
-
return Math.max(1024, Math.min(ceiling,
|
|
2616
|
+
function outputDefault(context, ceiling = Number.POSITIVE_INFINITY) {
|
|
2617
|
+
return Math.max(1024, Math.min(ceiling, Math.floor(context / 4)));
|
|
2615
2618
|
}
|
|
2616
2619
|
/** Thinking levels a chat-template engine can be asked for through its template kwargs. */
|
|
2617
2620
|
const strataReasoning = {
|
|
@@ -3100,6 +3103,23 @@ var NInferController = class {
|
|
|
3100
3103
|
}));
|
|
3101
3104
|
});
|
|
3102
3105
|
}
|
|
3106
|
+
/**
|
|
3107
|
+
* Shut the distro down after the engine stops, so the WSL VM gives its memory back.
|
|
3108
|
+
*
|
|
3109
|
+
* `wsl --terminate` is the only lever that returns the distro's RAM: stopping
|
|
3110
|
+
* the binary leaves systemd and the utility VM resident. A distro that is
|
|
3111
|
+
* already stopped makes the call a no-op, so a failure here is not an error.
|
|
3112
|
+
*/
|
|
3113
|
+
async terminateDistro() {
|
|
3114
|
+
const distribution = this.config.wsl?.distribution;
|
|
3115
|
+
if (distribution === void 0) return;
|
|
3116
|
+
try {
|
|
3117
|
+
await execute$1("wsl.exe", ["--terminate", distribution], {
|
|
3118
|
+
windowsHide: true,
|
|
3119
|
+
timeout: 3e4
|
|
3120
|
+
});
|
|
3121
|
+
} catch (error) {}
|
|
3122
|
+
}
|
|
3103
3123
|
/** A container this Host may reclaim; a missing Docker or an unrelated one is no takeover. */
|
|
3104
3124
|
async external() {
|
|
3105
3125
|
try {
|
|
@@ -3265,9 +3285,16 @@ var NInferController = class {
|
|
|
3265
3285
|
this.changing = false;
|
|
3266
3286
|
}
|
|
3267
3287
|
}
|
|
3268
|
-
|
|
3288
|
+
/**
|
|
3289
|
+
* Stop the engine, and by default hand the WSL distro's memory back.
|
|
3290
|
+
*
|
|
3291
|
+
* @param terminate - terminate the WSL distro after the engine stops; a start
|
|
3292
|
+
* or restart passes `false` because it is about to use that distro again.
|
|
3293
|
+
*/
|
|
3294
|
+
async stop(terminate = true) {
|
|
3269
3295
|
if (this.config.wsl) {
|
|
3270
3296
|
await this.callWsl("stop");
|
|
3297
|
+
if (terminate && this.config.wsl.terminateOnStop !== false) await this.terminateDistro();
|
|
3271
3298
|
return;
|
|
3272
3299
|
}
|
|
3273
3300
|
const container = await this.container();
|
|
@@ -3313,17 +3340,19 @@ var NInferController = class {
|
|
|
3313
3340
|
await this.takeOver();
|
|
3314
3341
|
takenOver = "Stopped the external NInfer container. ";
|
|
3315
3342
|
}
|
|
3316
|
-
if (action === "stop"
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3343
|
+
if (action === "stop") {
|
|
3344
|
+
await this.stop();
|
|
3345
|
+
return {
|
|
3346
|
+
ok: true,
|
|
3347
|
+
detail: takenOver + "NInfer stopped."
|
|
3348
|
+
};
|
|
3349
|
+
}
|
|
3321
3350
|
if (action === "start" && ["running", "starting"].includes(status.phase)) return {
|
|
3322
3351
|
ok: true,
|
|
3323
3352
|
detail: "NInfer is already started."
|
|
3324
3353
|
};
|
|
3325
3354
|
if (!this.complete()) throw Error("Wait for the model checksum verification.");
|
|
3326
|
-
await this.stop();
|
|
3355
|
+
await this.stop(false);
|
|
3327
3356
|
if (this.config.wsl) {
|
|
3328
3357
|
const started = await this.callWsl("start");
|
|
3329
3358
|
return {
|