@genai-fi/nanogpt 1.2.1 → 1.2.2

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.
@@ -88,7 +88,7 @@ var f = class {
88
88
  for (let n = 0; n < e.length; n++) {
89
89
  let o = e[n], c = i[n], l = d(c, t.topK ? Math.min(t.topK, r) : Math.max(1, r));
90
90
  for (let e of l) {
91
- let n = this.actualTokeniser.decode([e.token]), r = this.shouldTerminate(t.allowSpecial ?? !1, e.token), i = o.tokens.length + 1 >= Math.max(2, s), c = t.endOnWhiteSpace === !0 && i && /\s/.test(n), l = c && o.tokens.length > 0 && /^\s/.test(n);
91
+ let n = this.actualTokeniser.decode([e.token]), r = this.shouldTerminate(t.allowSpecial ?? !1, e.token), i = o.tokens.length + 1 > s, c = t.endOnWhiteSpace === !0 && i && /\s/.test(n), l = c && o.tokens.length > 0 && /^\s/.test(n);
92
92
  a.push({
93
93
  parent: o,
94
94
  token: e.token,
@@ -152,7 +152,10 @@ var y = class extends e {
152
152
  content: "",
153
153
  _timestamp: Date.now()
154
154
  }), n = !0, this.resetCache(!e?.noCache)) : (this.lastToken < 0 || t) && this.resetCache(!e?.noCache);
155
- let r = this.lastToken >= 0 && this.cache ? i([this.lastToken], [1, 1], "int32") : await m(this.actualTokeniser, this.model.config.blockSize, t ? n ? this.outputConversation.slice(0, -1) : this.outputConversation : void 0, e), a = e?.maxLength ?? 1e3;
155
+ let r = this.lastToken >= 0 && this.cache ? i([this.lastToken], [1, 1], "int32") : await m(this.actualTokeniser, this.model.config.blockSize, t ? n ? this.outputConversation.slice(0, -1) : this.outputConversation : void 0, n ? e : {
156
+ ...e,
157
+ continuation: !0
158
+ }), a = e?.maxLength ?? 1e3;
156
159
  for (let t = 0; t < a && this.active; t++) {
157
160
  let n = await this._generateToken(r, this.cache ? this.cache : void 0, {
158
161
  ...e,
@@ -89,6 +89,9 @@ var t = [
89
89
  case "system":
90
90
  r.push([a[2]]), e = !0;
91
91
  break;
92
+ case "text":
93
+ r[r.length - 1][0] !== this.bosToken && r.push([this.bosToken]);
94
+ break;
92
95
  }
93
96
  switch (r.push(s), t.role) {
94
97
  case "user":
@@ -100,11 +103,14 @@ var t = [
100
103
  case "system":
101
104
  r.push([o[2]]);
102
105
  break;
106
+ case "text":
107
+ r.push([this.eosToken]);
108
+ break;
103
109
  }
104
110
  n && i && e ? (i.push([!1]), i.push(s.map(() => !1)), i.push([!1])) : n && i && (i.push([!1]), i.push(s.map(() => !0)), i.push([!0]));
105
111
  }
106
112
  let s = r.flat();
107
- return t ? (s.push(a[1]), n && i && i.push([!1])) : (s.push(this.eosToken), n && i && i.push([!0])), n && i ? {
113
+ return t ? (s.push(a[1]), n && i && i.push([!1])) : (s[s.length - 1] !== this.eosToken && s.push(this.eosToken), n && i && i.push([!0])), n && i ? {
108
114
  tokens: s,
109
115
  mask: i.flat()
110
116
  } : s;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genai-fi/nanogpt",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",