brsh 3.10.4 → 3.10.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/CHANGELOG.md +14 -0
- package/dist/shell.es.js +28 -10
- package/dist/shell.es.js.map +1 -1
- package/dist/shell.min.js +2 -1
- package/dist/shell.min.js.map +1 -1
- package/dist/wbt.es.js +27 -25
- package/dist/wbt.es.js.map +1 -1
- package/dist/wbt.min.js +2 -2
- package/dist/wbt.min.js.map +1 -1
- package/lib/local/read.js +63 -16
- package/lib/wbt/packages/wllama.js +13 -14
- package/package.json +1 -1
- package/test/local-commands.test.js +86 -0
- package/test/wbt.test.js +17 -0
package/dist/wbt.es.js
CHANGED
|
@@ -4762,7 +4762,8 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
|
|
|
4762
4762
|
typeof this.onRender == "function" && this.onRender(i), this.active = !1;
|
|
4763
4763
|
}
|
|
4764
4764
|
clear() {
|
|
4765
|
-
|
|
4765
|
+
let e = this.active;
|
|
4766
|
+
this.stopTimer(), this.active = !1, e && this.enabled && typeof this.onRender == "function" && this.onRender("");
|
|
4766
4767
|
}
|
|
4767
4768
|
};
|
|
4768
4769
|
function h(e, t = null, n = null, r = null) {
|
|
@@ -5329,42 +5330,43 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
|
|
|
5329
5330
|
this._parsed.topK !== void 0 && (r.top_k = this._parsed.topK), this._parsed.topP !== void 0 && (r.top_p = this._parsed.topP);
|
|
5330
5331
|
let i = this._createTracker();
|
|
5331
5332
|
i.start("Running inference", { hint: "evaluating prompt & preparing KV cache" });
|
|
5333
|
+
let a = !1;
|
|
5332
5334
|
try {
|
|
5333
5335
|
if (typeof this._wllama.createChatCompletion == "function") {
|
|
5334
5336
|
let e = await this._wllama.createChatCompletion(r);
|
|
5335
5337
|
if (e && typeof e[Symbol.asyncIterator] == "function") {
|
|
5336
|
-
let n = ""
|
|
5337
|
-
for await (let
|
|
5338
|
-
let e =
|
|
5339
|
-
e && (
|
|
5338
|
+
let n = "";
|
|
5339
|
+
for await (let r of e) {
|
|
5340
|
+
let e = r?.choices?.[0]?.delta?.content ?? r?.choices?.[0]?.text ?? "";
|
|
5341
|
+
e && (a || (a = !0, i.clear(), this.interactive && (this._replStatus = "Streaming tokens...", this._renderRepl())), n += e, typeof t == "function" && t(e));
|
|
5340
5342
|
}
|
|
5341
|
-
return i.clear(), this.interactive
|
|
5343
|
+
return i.clear(), !this.interactive && !a && this._clearStatus(), n;
|
|
5342
5344
|
}
|
|
5343
5345
|
if (i.clear(), this.interactive || this._clearStatus(), this._parsed.jsonOutput) return JSON.stringify(e);
|
|
5344
5346
|
let n = y(e);
|
|
5345
5347
|
return typeof t == "function" && n && t(n), n;
|
|
5346
5348
|
}
|
|
5347
|
-
let
|
|
5349
|
+
let o = {
|
|
5348
5350
|
prompt: e[e.length - 1]?.content || "",
|
|
5349
5351
|
max_tokens: this._parsed.maxTokens,
|
|
5350
5352
|
temperature: this._parsed.temperature,
|
|
5351
5353
|
stream: n
|
|
5352
5354
|
};
|
|
5353
|
-
this._parsed.topK !== void 0 && (
|
|
5354
|
-
let
|
|
5355
|
-
if (
|
|
5356
|
-
let e = ""
|
|
5357
|
-
for await (let
|
|
5358
|
-
let
|
|
5359
|
-
|
|
5355
|
+
this._parsed.topK !== void 0 && (o.top_k = this._parsed.topK), this._parsed.topP !== void 0 && (o.top_p = this._parsed.topP);
|
|
5356
|
+
let s = await this._wllama.createCompletion(o);
|
|
5357
|
+
if (s && typeof s[Symbol.asyncIterator] == "function") {
|
|
5358
|
+
let e = "";
|
|
5359
|
+
for await (let n of s) {
|
|
5360
|
+
let r = n?.choices?.[0]?.text ?? n?.choices?.[0]?.delta?.content ?? "";
|
|
5361
|
+
r && (a || (a = !0, i.clear(), this.interactive && (this._replStatus = "Streaming tokens...", this._renderRepl())), e += r, typeof t == "function" && t(r));
|
|
5360
5362
|
}
|
|
5361
|
-
return i.clear(), this.interactive
|
|
5363
|
+
return i.clear(), !this.interactive && !a && this._clearStatus(), e;
|
|
5362
5364
|
}
|
|
5363
|
-
if (i.clear(), this.interactive || this._clearStatus(), this._parsed.jsonOutput) return JSON.stringify(
|
|
5364
|
-
let
|
|
5365
|
-
return typeof t == "function" &&
|
|
5365
|
+
if (i.clear(), this.interactive || this._clearStatus(), this._parsed.jsonOutput) return JSON.stringify(s);
|
|
5366
|
+
let c = y(s);
|
|
5367
|
+
return typeof t == "function" && c && t(c), c;
|
|
5366
5368
|
} finally {
|
|
5367
|
-
i.clear(), this.interactive
|
|
5369
|
+
i.clear(), !this.interactive && !a && this._clearStatus();
|
|
5368
5370
|
}
|
|
5369
5371
|
}
|
|
5370
5372
|
_formatModelInfo() {
|
|
@@ -5522,22 +5524,22 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
|
|
|
5522
5524
|
this._parsed.topK !== void 0 && (n.top_k = this._parsed.topK), this._parsed.topP !== void 0 && (n.top_p = this._parsed.topP);
|
|
5523
5525
|
let r = this._createTracker();
|
|
5524
5526
|
r.start("Running inference", { hint: "evaluating prompt & preparing KV cache" });
|
|
5527
|
+
let i = !1;
|
|
5525
5528
|
try {
|
|
5526
5529
|
let e = await this._wllama.createCompletion(n), t = "";
|
|
5527
5530
|
if (e && typeof e[Symbol.asyncIterator] == "function") {
|
|
5528
|
-
let n
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
e && (n || (n = !0, this._streamedStdout = !0, r.clear(), this._clearStatus()), t += e, this.stdout && typeof this.stdout.write == "function" && this.stdout.write(e), this.emit("token", e));
|
|
5531
|
+
for await (let n of e) {
|
|
5532
|
+
let e = n?.choices?.[0]?.text ?? n?.choices?.[0]?.delta?.content ?? "";
|
|
5533
|
+
e && (i || (i = !0, this._streamedStdout = !0, r.clear()), t += e, this.stdout && typeof this.stdout.write == "function" && this.stdout.write(e), this.emit("token", e));
|
|
5532
5534
|
}
|
|
5533
|
-
r.clear(), this._clearStatus(),
|
|
5535
|
+
r.clear(), i || this._clearStatus(), i && t.length > 0 && !t.endsWith("\n") && this.stdout && typeof this.stdout.write == "function" && this.stdout.write("\r\n");
|
|
5534
5536
|
} else r.clear(), this._clearStatus(), t = this._parsed.jsonOutput ? JSON.stringify(e) : y(e);
|
|
5535
5537
|
t.split(/\r?\n/).forEach((e) => {
|
|
5536
5538
|
this.stdOut = e;
|
|
5537
5539
|
});
|
|
5538
5540
|
return;
|
|
5539
5541
|
} finally {
|
|
5540
|
-
r.clear(), this._clearStatus();
|
|
5542
|
+
r.clear(), i || this._clearStatus();
|
|
5541
5543
|
}
|
|
5542
5544
|
}
|
|
5543
5545
|
let t = [];
|