@genai-fi/nanogpt 0.2.4 → 0.2.5
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/TeachableLLM.js +1 -0
- package/dist/data/docx.d.ts +1 -0
- package/dist/data/docx.js +15 -0
- package/dist/data/pdf.d.ts +1 -1
- package/dist/data/pdf.js +10 -8
- package/dist/data/textLoader.js +29 -24
- package/dist/{jszip.min-CAxN99oA.js → jszip.min-CjP2V1VV.js} +1 -1
- package/dist/utilities/load.js +5 -5
- package/dist/utilities/save.js +1 -1
- package/package.json +1 -1
package/dist/data/textLoader.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { p as s } from "../papaparse.min-C8l2Kvo1.js";
|
|
2
|
-
import { loadParquet as
|
|
2
|
+
import { loadParquet as u } from "./parquet.js";
|
|
3
3
|
import { loadPDF as m } from "./pdf.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { loadDOCX as f } from "./docx.js";
|
|
5
|
+
function l(e, t) {
|
|
6
|
+
const r = e.findIndex((n) => n.toLowerCase() === t.toLowerCase());
|
|
7
|
+
return r === -1 ? 0 : r;
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
+
function x(e) {
|
|
9
10
|
return e.every((t) => t.length < 64);
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
+
function w(e) {
|
|
12
13
|
return e.split(".").pop() || "";
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
-
switch (
|
|
15
|
+
function h(e) {
|
|
16
|
+
switch (w(e)) {
|
|
16
17
|
case "parquet":
|
|
17
18
|
return "application/parquet";
|
|
18
19
|
case "csv":
|
|
@@ -21,39 +22,43 @@ function w(e) {
|
|
|
21
22
|
return "text/plain";
|
|
22
23
|
case "pdf":
|
|
23
24
|
return "application/pdf";
|
|
25
|
+
case "docx":
|
|
26
|
+
return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
24
27
|
default:
|
|
25
28
|
return "unknown";
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
|
-
async function
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
return
|
|
32
|
-
if (
|
|
31
|
+
async function C(e, t) {
|
|
32
|
+
const r = e.type !== "" ? e.type : h(e.name);
|
|
33
|
+
if (r === "application/parquet")
|
|
34
|
+
return u(e, t?.maxSize, t?.column);
|
|
35
|
+
if (r === "application/pdf")
|
|
33
36
|
return m(e, t?.maxSize);
|
|
34
|
-
if (
|
|
37
|
+
if (r === "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|
|
38
|
+
return f(e);
|
|
39
|
+
if (r === "text/csv") {
|
|
35
40
|
const n = await e.text();
|
|
36
|
-
return new Promise((
|
|
41
|
+
return new Promise((c, o) => {
|
|
37
42
|
s.parse(n, {
|
|
38
43
|
header: !1,
|
|
39
44
|
skipEmptyLines: !0,
|
|
40
|
-
complete: (
|
|
41
|
-
if (
|
|
45
|
+
complete: (a) => {
|
|
46
|
+
if (a.errors.length > 0)
|
|
42
47
|
o(new Error("Error parsing file"));
|
|
43
48
|
else {
|
|
44
|
-
const
|
|
45
|
-
|
|
49
|
+
const p = l(a.data[0], t?.column || "text"), i = t?.hasHeader ?? x(a.data[0]) ? a.data.slice(1) : a.data;
|
|
50
|
+
c(i.map((d) => d[p]));
|
|
46
51
|
}
|
|
47
52
|
},
|
|
48
|
-
error: (
|
|
49
|
-
o(
|
|
53
|
+
error: (a) => {
|
|
54
|
+
o(a);
|
|
50
55
|
}
|
|
51
56
|
});
|
|
52
57
|
});
|
|
53
|
-
} else if (
|
|
58
|
+
} else if (r === "text/plain")
|
|
54
59
|
return [await e.text()];
|
|
55
|
-
throw new Error(`Unsupported file type: ${
|
|
60
|
+
throw new Error(`Unsupported file type: ${r}`);
|
|
56
61
|
}
|
|
57
62
|
export {
|
|
58
|
-
|
|
63
|
+
C as default
|
|
59
64
|
};
|
package/dist/utilities/load.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as u } from "../jszip.min-CjP2V1VV.js";
|
|
2
2
|
import { importWeights as F } from "./weights.js";
|
|
3
3
|
import k from "../tokeniser/CharTokeniser.js";
|
|
4
4
|
import j from "../NanoGPTModel.js";
|
|
5
|
-
import { dummyPassAsync as
|
|
6
|
-
async function
|
|
5
|
+
import { dummyPassAsync as A } from "./dummy.js";
|
|
6
|
+
async function E(o) {
|
|
7
7
|
const e = await fetch(o);
|
|
8
8
|
if (!e.ok)
|
|
9
9
|
throw new Error(`Failed to fetch ${o}: ${e.statusText}`);
|
|
10
10
|
return e.arrayBuffer();
|
|
11
11
|
}
|
|
12
12
|
async function T(o, e) {
|
|
13
|
-
const m = typeof e == "string" ? await
|
|
13
|
+
const m = typeof e == "string" ? await E(e) : e, n = await u.loadAsync(m), s = /* @__PURE__ */ new Map(), c = await n.file("manifest.json")?.async("string");
|
|
14
14
|
if (!c)
|
|
15
15
|
throw new Error("Manifest file not found in the zip archive");
|
|
16
16
|
const f = JSON.parse(c);
|
|
@@ -29,7 +29,7 @@ async function T(o, e) {
|
|
|
29
29
|
}
|
|
30
30
|
o.disposeVariables();
|
|
31
31
|
const a = new j(o, f.config);
|
|
32
|
-
await
|
|
32
|
+
await A(a), a.loadWeights(p);
|
|
33
33
|
const w = await n.file("log.json")?.async("string");
|
|
34
34
|
if (w)
|
|
35
35
|
try {
|
package/dist/utilities/save.js
CHANGED