@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.
@@ -1,18 +1,19 @@
1
1
  import { p as s } from "../papaparse.min-C8l2Kvo1.js";
2
- import { loadParquet as d } from "./parquet.js";
2
+ import { loadParquet as u } from "./parquet.js";
3
3
  import { loadPDF as m } from "./pdf.js";
4
- function x(e, t) {
5
- const a = e.findIndex((n) => n.toLowerCase() === t.toLowerCase());
6
- return a === -1 ? 0 : a;
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 f(e) {
9
+ function x(e) {
9
10
  return e.every((t) => t.length < 64);
10
11
  }
11
- function l(e) {
12
+ function w(e) {
12
13
  return e.split(".").pop() || "";
13
14
  }
14
- function w(e) {
15
- switch (l(e)) {
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 q(e, t) {
29
- const a = e.type !== "" ? e.type : w(e.name);
30
- if (a === "application/parquet")
31
- return d(e, t?.maxSize, t?.column);
32
- if (a === "application/pdf")
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 (a === "text/csv") {
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((p, o) => {
41
+ return new Promise((c, o) => {
37
42
  s.parse(n, {
38
43
  header: !1,
39
44
  skipEmptyLines: !0,
40
- complete: (r) => {
41
- if (r.errors.length > 0)
45
+ complete: (a) => {
46
+ if (a.errors.length > 0)
42
47
  o(new Error("Error parsing file"));
43
48
  else {
44
- const c = x(r.data[0], t?.column || "text"), i = t?.hasHeader ?? f(r.data[0]) ? r.data.slice(1) : r.data;
45
- p(i.map((u) => u[c]));
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: (r) => {
49
- o(r);
53
+ error: (a) => {
54
+ o(a);
50
55
  }
51
56
  });
52
57
  });
53
- } else if (a === "text/plain")
58
+ } else if (r === "text/plain")
54
59
  return [await e.text()];
55
- throw new Error(`Unsupported file type: ${a}`);
60
+ throw new Error(`Unsupported file type: ${r}`);
56
61
  }
57
62
  export {
58
- q as default
63
+ C as default
59
64
  };
@@ -2310,5 +2310,5 @@ function Rt() {
2310
2310
  var Tt = Rt();
2311
2311
  const Pt = /* @__PURE__ */ Ot(Tt);
2312
2312
  export {
2313
- Pt as z
2313
+ Pt as j
2314
2314
  };
@@ -1,16 +1,16 @@
1
- import { z as u } from "../jszip.min-CAxN99oA.js";
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 z } from "./dummy.js";
6
- async function A(o) {
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 A(e) : e, n = await u.loadAsync(m), s = /* @__PURE__ */ new Map(), c = await n.file("manifest.json")?.async("string");
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 z(a), a.loadWeights(p);
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 {
@@ -1,4 +1,4 @@
1
- import { z as g } from "../jszip.min-CAxN99oA.js";
1
+ import { j as g } from "../jszip.min-CjP2V1VV.js";
2
2
  import { exportWeights as l } from "./weights.js";
3
3
  const b = "1.0.0";
4
4
  async function p(t, s, i) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genai-fi/nanogpt",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",