@genai-fi/nanogpt 1.0.1 → 1.0.3
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/dist/api/responses.js +3 -3
- package/dist/api/training.js +24 -24
- package/dist/data/pdf.js +11 -11
- package/dist/data/textLoader.js +4 -4
- package/dist/loader/loadZipMeta.js +1 -1
- package/dist/models/config.js +1 -1
- package/dist/{pdf-CdmW8ikl.js → pdf-Bzuk68Vy.js} +11047 -8714
- package/dist/training/prepareData.d.ts +1 -1
- package/dist/training/prepareData.js +21 -21
- package/dist/training/tasks/tokenStream.d.ts +1 -1
- package/dist/training/tasks/tokenStream.js +12 -12
- package/package.json +3 -3
package/dist/api/responses.js
CHANGED
|
@@ -103,7 +103,7 @@ var r = class {
|
|
|
103
103
|
callback: t
|
|
104
104
|
};
|
|
105
105
|
if (this._responses.set(r, a), this._busyCount > 0 && !e.background) {
|
|
106
|
-
if (this._jobQueue.length > 10) throw Error("
|
|
106
|
+
if (this._jobQueue.length > 10) throw Error("queue_too_long");
|
|
107
107
|
return new Promise((n, i) => {
|
|
108
108
|
this._jobQueue.push({
|
|
109
109
|
id: r,
|
|
@@ -121,7 +121,7 @@ var r = class {
|
|
|
121
121
|
if (n) {
|
|
122
122
|
let r = n.generator.getConversation();
|
|
123
123
|
if (t !== void 0 && t >= 0 && t < r.length && r.splice(t), n.done = !1, n.timestamp = Date.now(), this._busyCount > 0 && !n.options.background) {
|
|
124
|
-
if (this._jobQueue.length > 10) throw Error("
|
|
124
|
+
if (this._jobQueue.length > 10) throw Error("queue_too_long");
|
|
125
125
|
return new Promise((t, r) => {
|
|
126
126
|
this._jobQueue.push({
|
|
127
127
|
id: e,
|
|
@@ -134,7 +134,7 @@ var r = class {
|
|
|
134
134
|
}
|
|
135
135
|
return this._runForRecord(e, n.options, n.callback);
|
|
136
136
|
}
|
|
137
|
-
throw Error(
|
|
137
|
+
throw Error("response_not_found");
|
|
138
138
|
}
|
|
139
139
|
getResponse(e) {
|
|
140
140
|
let t = this._responses.get(e);
|
package/dist/api/training.js
CHANGED
|
@@ -115,17 +115,17 @@ var o = class {
|
|
|
115
115
|
this.setState(e, "error", t);
|
|
116
116
|
}));
|
|
117
117
|
}
|
|
118
|
-
async job(e,
|
|
119
|
-
if (this.assertValidOptions(e), this.assertValidDataInput(
|
|
120
|
-
let
|
|
121
|
-
for (let t of
|
|
118
|
+
async job(e, o = [], s, c) {
|
|
119
|
+
if (this.assertValidOptions(e), this.assertValidDataInput(o), this.assertValidDatasets(s), c && c instanceof t && c.tokeniserId !== this._tokeniser.id) throw Error("tokeniser_mismatch");
|
|
120
|
+
let l = Array.from(this._jobs.keys());
|
|
121
|
+
for (let t of l) {
|
|
122
122
|
let n = this._jobs.get(t);
|
|
123
123
|
if (n && n.id !== e.previous_job_id) {
|
|
124
124
|
if (n.options.method.type === e.method.type && n.state !== "running") n.trainer.dispose(), this._jobs.delete(n.id);
|
|
125
125
|
else if (n.options.method.type === e.method.type && n.state === "running") throw Error("training_in_progress");
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
let
|
|
128
|
+
let u = e.previous_job_id ? this.getJob(e.previous_job_id) : {
|
|
129
129
|
id: n(),
|
|
130
130
|
state: "pending",
|
|
131
131
|
trainer: r(this._model, this._tokeniser, e),
|
|
@@ -134,40 +134,40 @@ var o = class {
|
|
|
134
134
|
remaining: 0,
|
|
135
135
|
options: e,
|
|
136
136
|
totalTokens: 0,
|
|
137
|
-
datasets:
|
|
137
|
+
datasets: s,
|
|
138
138
|
breakOnLog: !1
|
|
139
139
|
};
|
|
140
|
-
if (!
|
|
141
|
-
if (this._jobs.set(
|
|
142
|
-
if (
|
|
140
|
+
if (!u) throw Error("invalid_previous_job_id");
|
|
141
|
+
if (this._jobs.set(u.id, u), this.setState(u, "pending"), o instanceof t) {
|
|
142
|
+
if (u.datasetId && o.datasetId !== u.datasetId) {
|
|
143
143
|
let e = /* @__PURE__ */ Error("dataset_mismatch");
|
|
144
|
-
throw this.setState(
|
|
144
|
+
throw this.setState(u, "error", e), e;
|
|
145
145
|
}
|
|
146
|
-
if (
|
|
146
|
+
if (o.tokeniserId !== this._tokeniser.id) {
|
|
147
147
|
let e = /* @__PURE__ */ Error("tokeniser_mismatch");
|
|
148
|
-
throw this.setState(
|
|
148
|
+
throw this.setState(u, "error", e), e;
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
u.datasetId = o.datasetId;
|
|
151
151
|
}
|
|
152
|
-
if (!
|
|
153
|
-
let t = await i(e, this._model, this._tokeniser,
|
|
154
|
-
|
|
152
|
+
if (!u.trainDataset) try {
|
|
153
|
+
let t = await i(e, this._model, this._tokeniser, o, u.datasetId ?? a(s), c, s);
|
|
154
|
+
u.trainDataset = t.trainDataset, u.validationDataset = t.validationDataset, u.totalTokens = t.totalTokens;
|
|
155
155
|
} catch (e) {
|
|
156
|
-
throw this.setState(
|
|
156
|
+
throw this.setState(u, "error", /* @__PURE__ */ Error("prepare_data_failed")), u.trainer.dispose(), this._jobs.delete(u.id), e;
|
|
157
157
|
}
|
|
158
158
|
if (e.previous_job_id) {
|
|
159
|
-
this.assertValidOptions(e),
|
|
159
|
+
this.assertValidOptions(e), u.options = e;
|
|
160
160
|
try {
|
|
161
|
-
|
|
161
|
+
u.trainer.configure(e);
|
|
162
162
|
} catch (e) {
|
|
163
|
-
throw this.setState(
|
|
163
|
+
throw this.setState(u, "error", /* @__PURE__ */ Error("trainer_configuration_failed")), u.trainer.dispose(), this._jobs.delete(u.id), e;
|
|
164
164
|
}
|
|
165
165
|
} else try {
|
|
166
|
-
|
|
166
|
+
u.trainer.configure(e);
|
|
167
167
|
} catch (e) {
|
|
168
|
-
throw this.setState(
|
|
168
|
+
throw this.setState(u, "error", /* @__PURE__ */ Error("trainer_configuration_failed")), u.trainer.dispose(), this._jobs.delete(u.id), e;
|
|
169
169
|
}
|
|
170
|
-
return this.launchJob(
|
|
170
|
+
return this.launchJob(u), u;
|
|
171
171
|
}
|
|
172
172
|
getJob(e) {
|
|
173
173
|
return this.assertValidJobId(e), this._jobs.get(e) ?? null;
|
|
@@ -195,7 +195,7 @@ var o = class {
|
|
|
195
195
|
}
|
|
196
196
|
dispose() {
|
|
197
197
|
for (let e of this._jobs.values()) {
|
|
198
|
-
if (e.state === "running") throw Error(
|
|
198
|
+
if (e.state === "running") throw Error("job_still_running");
|
|
199
199
|
e.trainer.dispose();
|
|
200
200
|
}
|
|
201
201
|
this._jobs.clear(), this.ee.removeAllListeners();
|