hmb HF Staff commited on
Commit
4fced55
·
1 Parent(s): e3245dd
Files changed (5) hide show
  1. package.json +1 -0
  2. pnpm-lock.yaml +92 -0
  3. src/App.svelte +6 -21
  4. src/app.css +0 -3
  5. svelte.config.js +18 -5
package.json CHANGED
@@ -10,6 +10,7 @@
10
  "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json"
11
  },
12
  "devDependencies": {
 
13
  "@sveltejs/vite-plugin-svelte": "^5.0.3",
14
  "@tsconfig/svelte": "^5.0.4",
15
  "svelte": "^5.28.1",
 
10
  "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json"
11
  },
12
  "devDependencies": {
13
+ "@sveltejs/adapter-static": "^3.0.9",
14
  "@sveltejs/vite-plugin-svelte": "^5.0.3",
15
  "@tsconfig/svelte": "^5.0.4",
16
  "svelte": "^5.28.1",
pnpm-lock.yaml CHANGED
@@ -15,6 +15,9 @@ importers:
15
  specifier: ^2.17.2
16
  version: 2.17.2
17
  devDependencies:
 
 
 
18
  '@sveltejs/vite-plugin-svelte':
19
  specifier: ^5.0.3
20
@@ -408,6 +411,9 @@ packages:
408
  '@open-draft/[email protected]':
409
  resolution: {integrity: sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==}
410
 
 
 
 
411
  '@protobufjs/[email protected]':
412
  resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==}
413
 
@@ -538,11 +544,32 @@ packages:
538
  cpu: [x64]
539
  os: [win32]
540
 
 
 
 
541
  '@sveltejs/[email protected]':
542
  resolution: {integrity: sha512-IwQk4yfwLdibDlrXVE04jTZYlLnwsTT2PIOQQGNLWfjavGifnk1JD1LcZjZaBTRcxZu2FfPfNLOE04DSu9lqtQ==}
543
  peerDependencies:
544
  acorn: ^8.9.0
545
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
  '@sveltejs/[email protected]':
547
  resolution: {integrity: sha512-J/Nmb2Q2y7mck2hyCX4ckVHcR5tu2J+MtBEQqpDrrgELZ2uvraQcK/ioCV61AqkdXFgriksOKIceDcQmqnGhVw==}
548
  engines: {node: ^18.0.0 || ^20.0.0 || >=22}
@@ -830,6 +857,10 @@ packages:
830
831
  resolution: {integrity: sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ==}
832
 
 
 
 
 
833
834
  resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==}
835
  engines: {node: '>= 0.6'}
@@ -1045,6 +1076,9 @@ packages:
1045
  resolution: {integrity: sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==}
1046
  engines: {node: '>=8'}
1047
 
 
 
 
1048
1049
  resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==}
1050
 
@@ -1312,6 +1346,10 @@ packages:
1312
  resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==}
1313
  engines: {node: '>=4'}
1314
 
 
 
 
 
1315
1316
  resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
1317
 
@@ -1515,6 +1553,9 @@ packages:
1515
  engines: {node: '>=10'}
1516
  hasBin: true
1517
 
 
 
 
1518
1519
  resolution: {integrity: sha512-KyLTWwgcR9Oe4d9HwCwNM2l7+J0dUQwn/yf7S0EnTtb0eVS4RxO0eUSvxPtzT4F3SY+C4K6fqdv/DO27sJ/v/w==}
1520
  engines: {node: '>=14.15.0'}
@@ -1532,6 +1573,10 @@ packages:
1532
1533
  resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==}
1534
 
 
 
 
 
1535
1536
  resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
1537
  engines: {node: '>=0.10.0'}
@@ -1612,6 +1657,10 @@ packages:
1612
  resolution: {integrity: sha512-WMi/OQ2axVTf/ykqCQgXiIct+mSQDFdH2fkwhPwgEwvJ1kSzZRiinb0zF2Xb8u4+OqPChmyI6MEu4EezNJz+FQ==}
1613
  hasBin: true
1614
 
 
 
 
 
1615
1616
  resolution: {integrity: sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==}
1617
  engines: {node: '>=6'}
@@ -2208,6 +2257,8 @@ snapshots:
2208
 
2209
  '@open-draft/[email protected]': {}
2210
 
 
 
2211
  '@protobufjs/[email protected]': {}
2212
 
2213
  '@protobufjs/[email protected]': {}
@@ -2291,10 +2342,35 @@ snapshots:
2291
  '@rollup/[email protected]':
2292
  optional: true
2293
 
 
 
2294
2295
  dependencies:
2296
  acorn: 8.15.0
2297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2298
2299
  dependencies:
2300
  '@sveltejs/vite-plugin-svelte': 5.1.1([email protected])([email protected](@types/[email protected]))
@@ -2595,6 +2671,8 @@ snapshots:
2595
 
2596
2597
 
 
 
2598
2599
 
2600
@@ -2825,6 +2903,8 @@ snapshots:
2825
 
2826
2827
 
 
 
2828
2829
  dependencies:
2830
  domelementtype: 2.3.0
@@ -3118,6 +3198,8 @@ snapshots:
3118
 
3119
3120
 
 
 
3121
3122
 
3123
@@ -3374,6 +3456,8 @@ snapshots:
3374
 
3375
3376
 
 
 
3377
3378
  dependencies:
3379
  color: 4.2.3
@@ -3401,6 +3485,12 @@ snapshots:
3401
  dependencies:
3402
  is-arrayish: 0.3.2
3403
 
 
 
 
 
 
 
3404
3405
 
3406
@@ -3513,6 +3603,8 @@ snapshots:
3513
  dependencies:
3514
  tldts-core: 6.1.86
3515
 
 
 
3516
3517
  dependencies:
3518
  psl: 1.15.0
 
15
  specifier: ^2.17.2
16
  version: 2.17.2
17
  devDependencies:
18
+ '@sveltejs/adapter-static':
19
+ specifier: ^3.0.9
20
21
  '@sveltejs/vite-plugin-svelte':
22
  specifier: ^5.0.3
23
 
411
  '@open-draft/[email protected]':
412
  resolution: {integrity: sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==}
413
 
414
+ '@polka/[email protected]':
415
+ resolution: {integrity: sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==}
416
+
417
  '@protobufjs/[email protected]':
418
  resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==}
419
 
 
544
  cpu: [x64]
545
  os: [win32]
546
 
547
+ '@standard-schema/[email protected]':
548
+ resolution: {integrity: sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==}
549
+
550
  '@sveltejs/[email protected]':
551
  resolution: {integrity: sha512-IwQk4yfwLdibDlrXVE04jTZYlLnwsTT2PIOQQGNLWfjavGifnk1JD1LcZjZaBTRcxZu2FfPfNLOE04DSu9lqtQ==}
552
  peerDependencies:
553
  acorn: ^8.9.0
554
 
555
+ '@sveltejs/[email protected]':
556
+ resolution: {integrity: sha512-aytHXcMi7lb9ljsWUzXYQ0p5X1z9oWud2olu/EpmH7aCu4m84h7QLvb5Wp+CFirKcwoNnYvYWhyP/L8Vh1ztdw==}
557
+ peerDependencies:
558
+ '@sveltejs/kit': ^2.0.0
559
+
560
+ '@sveltejs/[email protected]':
561
+ resolution: {integrity: sha512-MVzwZz1GFznEQbL3f0i2v9AIc3lZH01izQj6XfIrthmZAwOzyXJCgXbLRss8vk//HfYsE4w6Tz+ukbf3rScPNQ==}
562
+ engines: {node: '>=18.13'}
563
+ hasBin: true
564
+ peerDependencies:
565
+ '@opentelemetry/api': ^1.0.0
566
+ '@sveltejs/vite-plugin-svelte': ^3.0.0 || ^4.0.0-next.1 || ^5.0.0 || ^6.0.0-next.0
567
+ svelte: ^4.0.0 || ^5.0.0-next.0
568
+ vite: ^5.0.3 || ^6.0.0 || ^7.0.0-beta.0
569
+ peerDependenciesMeta:
570
+ '@opentelemetry/api':
571
+ optional: true
572
+
573
  '@sveltejs/[email protected]':
574
  resolution: {integrity: sha512-J/Nmb2Q2y7mck2hyCX4ckVHcR5tu2J+MtBEQqpDrrgELZ2uvraQcK/ioCV61AqkdXFgriksOKIceDcQmqnGhVw==}
575
  engines: {node: ^18.0.0 || ^20.0.0 || >=22}
 
857
858
  resolution: {integrity: sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ==}
859
 
860
861
+ resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==}
862
+ engines: {node: '>= 0.6'}
863
+
864
865
  resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==}
866
  engines: {node: '>= 0.6'}
 
1076
  resolution: {integrity: sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==}
1077
  engines: {node: '>=8'}
1078
 
1079
1080
+ resolution: {integrity: sha512-UDsjUbpQn9kvm68slnrs+mfxwFkIflOhkanmyabZ8zOYk8SMEIbJ3TK+88g70hSIeytu4y18f0z/hYHMTrXIWw==}
1081
+
1082
1083
  resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==}
1084
 
 
1346
  resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==}
1347
  engines: {node: '>=4'}
1348
 
1349
1350
+ resolution: {integrity: sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==}
1351
+ engines: {node: '>=10'}
1352
+
1353
1354
  resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
1355
 
 
1553
  engines: {node: '>=10'}
1554
  hasBin: true
1555
 
1556
1557
+ resolution: {integrity: sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==}
1558
+
1559
1560
  resolution: {integrity: sha512-KyLTWwgcR9Oe4d9HwCwNM2l7+J0dUQwn/yf7S0EnTtb0eVS4RxO0eUSvxPtzT4F3SY+C4K6fqdv/DO27sJ/v/w==}
1561
  engines: {node: '>=14.15.0'}
 
1573
1574
  resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==}
1575
 
1576
1577
+ resolution: {integrity: sha512-FoqMu0NCGBLCcAkS1qA+XJIQTR6/JHfQXl+uGteNCQ76T91DMUjPa9xfmeqMY3z80nLSg9yQmNjK0Px6RWsH/A==}
1578
+ engines: {node: '>=18'}
1579
+
1580
1581
  resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
1582
  engines: {node: '>=0.10.0'}
 
1657
  resolution: {integrity: sha512-WMi/OQ2axVTf/ykqCQgXiIct+mSQDFdH2fkwhPwgEwvJ1kSzZRiinb0zF2Xb8u4+OqPChmyI6MEu4EezNJz+FQ==}
1658
  hasBin: true
1659
 
1660
1661
+ resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==}
1662
+ engines: {node: '>=6'}
1663
+
1664
1665
  resolution: {integrity: sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==}
1666
  engines: {node: '>=6'}
 
2257
 
2258
  '@open-draft/[email protected]': {}
2259
 
2260
+ '@polka/[email protected]': {}
2261
+
2262
  '@protobufjs/[email protected]': {}
2263
 
2264
  '@protobufjs/[email protected]': {}
 
2342
  '@rollup/[email protected]':
2343
  optional: true
2344
 
2345
+ '@standard-schema/[email protected]': {}
2346
+
2347
2348
  dependencies:
2349
  acorn: 8.15.0
2350
 
2351
2352
+ dependencies:
2353
2354
+
2355
2356
+ dependencies:
2357
+ '@standard-schema/spec': 1.0.0
2358
+ '@sveltejs/acorn-typescript': 1.0.5([email protected])
2359
+ '@sveltejs/vite-plugin-svelte': 5.1.1([email protected])([email protected](@types/[email protected]))
2360
+ '@types/cookie': 0.6.0
2361
+ acorn: 8.15.0
2362
+ cookie: 0.6.0
2363
+ devalue: 5.3.2
2364
+ esm-env: 1.2.2
2365
+ kleur: 4.1.5
2366
+ magic-string: 0.30.18
2367
+ mrmime: 2.0.1
2368
+ sade: 1.8.1
2369
+ set-cookie-parser: 2.7.1
2370
+ sirv: 3.0.1
2371
+ svelte: 5.38.3
2372
+ vite: 6.3.5(@types/[email protected])
2373
+
2374
2375
  dependencies:
2376
  '@sveltejs/vite-plugin-svelte': 5.1.1([email protected])([email protected](@types/[email protected]))
 
2671
 
2672
2673
 
2674
2675
+
2676
2677
 
2678
 
2903
 
2904
2905
 
2906
2907
+
2908
2909
  dependencies:
2910
  domelementtype: 2.3.0
 
3198
 
3199
3200
 
3201
3202
+
3203
3204
 
3205
 
3456
 
3457
3458
 
3459
3460
+
3461
3462
  dependencies:
3463
  color: 4.2.3
 
3485
  dependencies:
3486
  is-arrayish: 0.3.2
3487
 
3488
3489
+ dependencies:
3490
+ '@polka/url': 1.0.0-next.29
3491
+ mrmime: 2.0.1
3492
+ totalist: 3.0.1
3493
+
3494
3495
 
3496
 
3603
  dependencies:
3604
  tldts-core: 6.1.86
3605
 
3606
3607
+
3608
3609
  dependencies:
3610
  psl: 1.15.0
src/App.svelte CHANGED
@@ -1,5 +1,6 @@
1
  <script lang="ts">
2
  import Dataframe from '@gradio/dataframe';
 
3
 
4
  let rawData = '';
5
  let cleanedData = '';
@@ -51,8 +52,6 @@
51
  updateRawFromInputValue();
52
  }
53
 
54
- // In-browser AI cleaning using transformers.js (DistilGPT2 as example)
55
- import { pipeline } from '@xenova/transformers';
56
  let generator: any = null;
57
  let loadingModel = false;
58
 
@@ -69,27 +68,13 @@
69
  loadingModel = false;
70
  // Prepare a prompt for the model
71
  const tableString = [inputValue.headers, ...inputValue.data].map(row => row.join(',')).join('\n');
72
- const prompt = `Clean this table and suggest steps. Table:\n${tableString}\nReturn JSON with keys steps (array of strings) and cleaned (array of arrays, first row is headers).`;
73
  const output = await generator(prompt, { max_new_tokens: 128 });
74
  let content = output?.[0]?.generated_text || '';
75
- let parsed;
76
- try {
77
- parsed = JSON.parse(content.match(/\{[\s\S]*\}/)?.[0] || '');
78
- } catch (e) {
79
- alert('AI did not return valid cleaning suggestions.');
80
- return;
81
- }
82
- if (parsed && parsed.cleaned && parsed.steps) {
83
- cleaningSteps = parsed.steps.map((step: string) => ({ step, accepted: true }));
84
- cleanedValue = {
85
- headers: parsed.cleaned[0],
86
- data: parsed.cleaned.slice(1),
87
- };
88
- cleanedData = cleanedValue.data.map(row => row.join(',')).join('\n');
89
- showSteps = true;
90
- } else {
91
- alert('AI did not return valid cleaning suggestions.');
92
- }
93
  } catch (err) {
94
  alert('Failed to load or run the model. Please check your internet connection and model support.');
95
  loadingModel = false;
 
1
  <script lang="ts">
2
  import Dataframe from '@gradio/dataframe';
3
+ import { pipeline } from '@xenova/transformers';
4
 
5
  let rawData = '';
6
  let cleanedData = '';
 
52
  updateRawFromInputValue();
53
  }
54
 
 
 
55
  let generator: any = null;
56
  let loadingModel = false;
57
 
 
68
  loadingModel = false;
69
  // Prepare a prompt for the model
70
  const tableString = [inputValue.headers, ...inputValue.data].map(row => row.join(',')).join('\n');
71
+ const prompt = `Clean this table and suggest steps. Table:\n${tableString}\nDescribe the cleaning steps and show a cleaned version.`;
72
  const output = await generator(prompt, { max_new_tokens: 128 });
73
  let content = output?.[0]?.generated_text || '';
74
+ cleaningSteps = [{ step: content, accepted: true }];
75
+ cleanedValue = { headers: inputValue.headers, data: inputValue.data };
76
+ cleanedData = content;
77
+ showSteps = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  } catch (err) {
79
  alert('Failed to load or run the model. Please check your internet connection and model support.');
80
  loadingModel = false;
src/app.css CHANGED
@@ -2,11 +2,8 @@
2
  font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
3
  line-height: 1.5;
4
  font-weight: 400;
5
-
6
  color-scheme: light dark;
7
  color: rgba(255, 255, 255, 0.87);
8
- background-color: #242424;
9
-
10
  font-synthesis: none;
11
  text-rendering: optimizeLegibility;
12
  -webkit-font-smoothing: antialiased;
 
2
  font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
3
  line-height: 1.5;
4
  font-weight: 400;
 
5
  color-scheme: light dark;
6
  color: rgba(255, 255, 255, 0.87);
 
 
7
  font-synthesis: none;
8
  text-rendering: optimizeLegibility;
9
  -webkit-font-smoothing: antialiased;
svelte.config.js CHANGED
@@ -1,7 +1,20 @@
1
- import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
 
2
 
3
- export default {
4
- // Consult https://svelte.dev/docs#compile-time-svelte-preprocess
5
- // for more information about preprocessors
6
  preprocess: vitePreprocess(),
7
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import adapter from "@sveltejs/adapter-static";
2
+ import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
3
 
4
+ /** @type {import('@sveltejs/kit').Config} */
5
+ const config = {
 
6
  preprocess: vitePreprocess(),
7
+ kit: {
8
+ adapter: adapter({
9
+ pages: "dist",
10
+ assets: "dist",
11
+ precompress: true,
12
+ strict: true,
13
+ }),
14
+ prerender: {
15
+ entries: ["*"],
16
+ },
17
+ },
18
+ };
19
+
20
+ export default config;