blanchon nsarrazin HF staff commited on
Commit
8ce8b63
1 Parent(s): da20881

Improve error message when the .env MODELS is not well formatted (#451)

Browse files

* feat: Improve error handling and parsing of MODELS environment variable

* Add more verbose parsing error

* Lint

* improve message

* lint

* refactor error handling and default values in models

* improve

* format

---------

Co-authored-by: Nathan Sarrazin <[email protected]>

Files changed (3) hide show
  1. package-lock.json +101 -356
  2. package.json +2 -0
  3. src/lib/server/models.ts +14 -1
package-lock.json CHANGED
@@ -36,6 +36,7 @@
36
  "@sveltejs/kit": "^1.15.10",
37
  "@tailwindcss/typography": "^0.5.9",
38
  "@types/jsdom": "^21.1.1",
 
39
  "@types/marked": "^4.0.8",
40
  "@types/parquetjs": "^0.10.3",
41
  "@typescript-eslint/eslint-plugin": "^5.45.0",
@@ -43,6 +44,7 @@
43
  "eslint": "^8.28.0",
44
  "eslint-config-prettier": "^8.5.0",
45
  "eslint-plugin-svelte": "^2.27.3",
 
46
  "marked-katex-extension": "^3.0.6",
47
  "prettier": "^2.8.0",
48
  "prettier-plugin-svelte": "^2.8.1",
@@ -78,246 +80,6 @@
78
  "url": "https://github.com/sponsors/antfu"
79
  }
80
  },
81
- "node_modules/@esbuild/android-arm": {
82
- "version": "0.17.16",
83
- "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.16.tgz",
84
- "integrity": "sha512-baLqRpLe4JnKrUXLJChoTN0iXZH7El/mu58GE3WIA6/H834k0XWvLRmGLG8y8arTRS9hJJibPnF0tiGhmWeZgw==",
85
- "cpu": [
86
- "arm"
87
- ],
88
- "dev": true,
89
- "optional": true,
90
- "os": [
91
- "android"
92
- ],
93
- "engines": {
94
- "node": ">=12"
95
- }
96
- },
97
- "node_modules/@esbuild/android-arm64": {
98
- "version": "0.17.16",
99
- "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.16.tgz",
100
- "integrity": "sha512-QX48qmsEZW+gcHgTmAj+x21mwTz8MlYQBnzF6861cNdQGvj2jzzFjqH0EBabrIa/WVZ2CHolwMoqxVryqKt8+Q==",
101
- "cpu": [
102
- "arm64"
103
- ],
104
- "dev": true,
105
- "optional": true,
106
- "os": [
107
- "android"
108
- ],
109
- "engines": {
110
- "node": ">=12"
111
- }
112
- },
113
- "node_modules/@esbuild/android-x64": {
114
- "version": "0.17.16",
115
- "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.16.tgz",
116
- "integrity": "sha512-G4wfHhrrz99XJgHnzFvB4UwwPxAWZaZBOFXh+JH1Duf1I4vIVfuYY9uVLpx4eiV2D/Jix8LJY+TAdZ3i40tDow==",
117
- "cpu": [
118
- "x64"
119
- ],
120
- "dev": true,
121
- "optional": true,
122
- "os": [
123
- "android"
124
- ],
125
- "engines": {
126
- "node": ">=12"
127
- }
128
- },
129
- "node_modules/@esbuild/darwin-arm64": {
130
- "version": "0.17.16",
131
- "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.16.tgz",
132
- "integrity": "sha512-/Ofw8UXZxuzTLsNFmz1+lmarQI6ztMZ9XktvXedTbt3SNWDn0+ODTwxExLYQ/Hod91EZB4vZPQJLoqLF0jvEzA==",
133
- "cpu": [
134
- "arm64"
135
- ],
136
- "dev": true,
137
- "optional": true,
138
- "os": [
139
- "darwin"
140
- ],
141
- "engines": {
142
- "node": ">=12"
143
- }
144
- },
145
- "node_modules/@esbuild/darwin-x64": {
146
- "version": "0.17.16",
147
- "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.16.tgz",
148
- "integrity": "sha512-SzBQtCV3Pdc9kyizh36Ol+dNVhkDyIrGb/JXZqFq8WL37LIyrXU0gUpADcNV311sCOhvY+f2ivMhb5Tuv8nMOQ==",
149
- "cpu": [
150
- "x64"
151
- ],
152
- "dev": true,
153
- "optional": true,
154
- "os": [
155
- "darwin"
156
- ],
157
- "engines": {
158
- "node": ">=12"
159
- }
160
- },
161
- "node_modules/@esbuild/freebsd-arm64": {
162
- "version": "0.17.16",
163
- "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.16.tgz",
164
- "integrity": "sha512-ZqftdfS1UlLiH1DnS2u3It7l4Bc3AskKeu+paJSfk7RNOMrOxmeFDhLTMQqMxycP1C3oj8vgkAT6xfAuq7ZPRA==",
165
- "cpu": [
166
- "arm64"
167
- ],
168
- "dev": true,
169
- "optional": true,
170
- "os": [
171
- "freebsd"
172
- ],
173
- "engines": {
174
- "node": ">=12"
175
- }
176
- },
177
- "node_modules/@esbuild/freebsd-x64": {
178
- "version": "0.17.16",
179
- "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.16.tgz",
180
- "integrity": "sha512-rHV6zNWW1tjgsu0dKQTX9L0ByiJHHLvQKrWtnz8r0YYJI27FU3Xu48gpK2IBj1uCSYhJ+pEk6Y0Um7U3rIvV8g==",
181
- "cpu": [
182
- "x64"
183
- ],
184
- "dev": true,
185
- "optional": true,
186
- "os": [
187
- "freebsd"
188
- ],
189
- "engines": {
190
- "node": ">=12"
191
- }
192
- },
193
- "node_modules/@esbuild/linux-arm": {
194
- "version": "0.17.16",
195
- "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.16.tgz",
196
- "integrity": "sha512-n4O8oVxbn7nl4+m+ISb0a68/lcJClIbaGAoXwqeubj/D1/oMMuaAXmJVfFlRjJLu/ZvHkxoiFJnmbfp4n8cdSw==",
197
- "cpu": [
198
- "arm"
199
- ],
200
- "dev": true,
201
- "optional": true,
202
- "os": [
203
- "linux"
204
- ],
205
- "engines": {
206
- "node": ">=12"
207
- }
208
- },
209
- "node_modules/@esbuild/linux-arm64": {
210
- "version": "0.17.16",
211
- "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.16.tgz",
212
- "integrity": "sha512-8yoZhGkU6aHu38WpaM4HrRLTFc7/VVD9Q2SvPcmIQIipQt2I/GMTZNdEHXoypbbGao5kggLcxg0iBKjo0SQYKA==",
213
- "cpu": [
214
- "arm64"
215
- ],
216
- "dev": true,
217
- "optional": true,
218
- "os": [
219
- "linux"
220
- ],
221
- "engines": {
222
- "node": ">=12"
223
- }
224
- },
225
- "node_modules/@esbuild/linux-ia32": {
226
- "version": "0.17.16",
227
- "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.16.tgz",
228
- "integrity": "sha512-9ZBjlkdaVYxPNO8a7OmzDbOH9FMQ1a58j7Xb21UfRU29KcEEU3VTHk+Cvrft/BNv0gpWJMiiZ/f4w0TqSP0gLA==",
229
- "cpu": [
230
- "ia32"
231
- ],
232
- "dev": true,
233
- "optional": true,
234
- "os": [
235
- "linux"
236
- ],
237
- "engines": {
238
- "node": ">=12"
239
- }
240
- },
241
- "node_modules/@esbuild/linux-loong64": {
242
- "version": "0.17.16",
243
- "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.16.tgz",
244
- "integrity": "sha512-TIZTRojVBBzdgChY3UOG7BlPhqJz08AL7jdgeeu+kiObWMFzGnQD7BgBBkWRwOtKR1i2TNlO7YK6m4zxVjjPRQ==",
245
- "cpu": [
246
- "loong64"
247
- ],
248
- "dev": true,
249
- "optional": true,
250
- "os": [
251
- "linux"
252
- ],
253
- "engines": {
254
- "node": ">=12"
255
- }
256
- },
257
- "node_modules/@esbuild/linux-mips64el": {
258
- "version": "0.17.16",
259
- "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.16.tgz",
260
- "integrity": "sha512-UPeRuFKCCJYpBbIdczKyHLAIU31GEm0dZl1eMrdYeXDH+SJZh/i+2cAmD3A1Wip9pIc5Sc6Kc5cFUrPXtR0XHA==",
261
- "cpu": [
262
- "mips64el"
263
- ],
264
- "dev": true,
265
- "optional": true,
266
- "os": [
267
- "linux"
268
- ],
269
- "engines": {
270
- "node": ">=12"
271
- }
272
- },
273
- "node_modules/@esbuild/linux-ppc64": {
274
- "version": "0.17.16",
275
- "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.16.tgz",
276
- "integrity": "sha512-io6yShgIEgVUhExJejJ21xvO5QtrbiSeI7vYUnr7l+v/O9t6IowyhdiYnyivX2X5ysOVHAuyHW+Wyi7DNhdw6Q==",
277
- "cpu": [
278
- "ppc64"
279
- ],
280
- "dev": true,
281
- "optional": true,
282
- "os": [
283
- "linux"
284
- ],
285
- "engines": {
286
- "node": ">=12"
287
- }
288
- },
289
- "node_modules/@esbuild/linux-riscv64": {
290
- "version": "0.17.16",
291
- "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.16.tgz",
292
- "integrity": "sha512-WhlGeAHNbSdG/I2gqX2RK2gfgSNwyJuCiFHMc8s3GNEMMHUI109+VMBfhVqRb0ZGzEeRiibi8dItR3ws3Lk+cA==",
293
- "cpu": [
294
- "riscv64"
295
- ],
296
- "dev": true,
297
- "optional": true,
298
- "os": [
299
- "linux"
300
- ],
301
- "engines": {
302
- "node": ">=12"
303
- }
304
- },
305
- "node_modules/@esbuild/linux-s390x": {
306
- "version": "0.17.16",
307
- "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.16.tgz",
308
- "integrity": "sha512-gHRReYsJtViir63bXKoFaQ4pgTyah4ruiMRQ6im9YZuv+gp3UFJkNTY4sFA73YDynmXZA6hi45en4BGhNOJUsw==",
309
- "cpu": [
310
- "s390x"
311
- ],
312
- "dev": true,
313
- "optional": true,
314
- "os": [
315
- "linux"
316
- ],
317
- "engines": {
318
- "node": ">=12"
319
- }
320
- },
321
  "node_modules/@esbuild/linux-x64": {
322
  "version": "0.17.16",
323
  "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.16.tgz",
@@ -334,102 +96,6 @@
334
  "node": ">=12"
335
  }
336
  },
337
- "node_modules/@esbuild/netbsd-x64": {
338
- "version": "0.17.16",
339
- "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.16.tgz",
340
- "integrity": "sha512-n8zK1YRDGLRZfVcswcDMDM0j2xKYLNXqei217a4GyBxHIuPMGrrVuJ+Ijfpr0Kufcm7C1k/qaIrGy6eG7wvgmA==",
341
- "cpu": [
342
- "x64"
343
- ],
344
- "dev": true,
345
- "optional": true,
346
- "os": [
347
- "netbsd"
348
- ],
349
- "engines": {
350
- "node": ">=12"
351
- }
352
- },
353
- "node_modules/@esbuild/openbsd-x64": {
354
- "version": "0.17.16",
355
- "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.16.tgz",
356
- "integrity": "sha512-lEEfkfsUbo0xC47eSTBqsItXDSzwzwhKUSsVaVjVji07t8+6KA5INp2rN890dHZeueXJAI8q0tEIfbwVRYf6Ew==",
357
- "cpu": [
358
- "x64"
359
- ],
360
- "dev": true,
361
- "optional": true,
362
- "os": [
363
- "openbsd"
364
- ],
365
- "engines": {
366
- "node": ">=12"
367
- }
368
- },
369
- "node_modules/@esbuild/sunos-x64": {
370
- "version": "0.17.16",
371
- "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.16.tgz",
372
- "integrity": "sha512-jlRjsuvG1fgGwnE8Afs7xYDnGz0dBgTNZfgCK6TlvPH3Z13/P5pi6I57vyLE8qZYLrGVtwcm9UbUx1/mZ8Ukag==",
373
- "cpu": [
374
- "x64"
375
- ],
376
- "dev": true,
377
- "optional": true,
378
- "os": [
379
- "sunos"
380
- ],
381
- "engines": {
382
- "node": ">=12"
383
- }
384
- },
385
- "node_modules/@esbuild/win32-arm64": {
386
- "version": "0.17.16",
387
- "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.16.tgz",
388
- "integrity": "sha512-TzoU2qwVe2boOHl/3KNBUv2PNUc38U0TNnzqOAcgPiD/EZxT2s736xfC2dYQbszAwo4MKzzwBV0iHjhfjxMimg==",
389
- "cpu": [
390
- "arm64"
391
- ],
392
- "dev": true,
393
- "optional": true,
394
- "os": [
395
- "win32"
396
- ],
397
- "engines": {
398
- "node": ">=12"
399
- }
400
- },
401
- "node_modules/@esbuild/win32-ia32": {
402
- "version": "0.17.16",
403
- "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.16.tgz",
404
- "integrity": "sha512-B8b7W+oo2yb/3xmwk9Vc99hC9bNolvqjaTZYEfMQhzdpBsjTvZBlXQ/teUE55Ww6sg//wlcDjOaqldOKyigWdA==",
405
- "cpu": [
406
- "ia32"
407
- ],
408
- "dev": true,
409
- "optional": true,
410
- "os": [
411
- "win32"
412
- ],
413
- "engines": {
414
- "node": ">=12"
415
- }
416
- },
417
- "node_modules/@esbuild/win32-x64": {
418
- "version": "0.17.16",
419
- "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.16.tgz",
420
- "integrity": "sha512-xJ7OH/nanouJO9pf03YsL9NAFQBHd8AqfrQd7Pf5laGyyTt/gToul6QYOA/i5i/q8y9iaM5DQFNTgpi995VkOg==",
421
- "cpu": [
422
- "x64"
423
- ],
424
- "dev": true,
425
- "optional": true,
426
- "os": [
427
- "win32"
428
- ],
429
- "engines": {
430
- "node": ">=12"
431
- }
432
- },
433
  "node_modules/@eslint-community/eslint-utils": {
434
  "version": "4.4.0",
435
  "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
@@ -1012,6 +678,12 @@
1012
  "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
1013
  "dev": true
1014
  },
 
 
 
 
 
 
1015
  "node_modules/@types/katex": {
1016
  "version": "0.16.3",
1017
  "resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.3.tgz",
@@ -1675,9 +1347,9 @@
1675
  }
1676
  },
1677
  "node_modules/bson": {
1678
- "version": "5.4.0",
1679
- "resolved": "https://registry.npmjs.org/bson/-/bson-5.4.0.tgz",
1680
- "integrity": "sha512-WRZ5SQI5GfUuKnPTNmAYPiKIof3ORXAF4IRU5UcgmivNIon01rWQlw5RUH954dpu8yGL8T59YShVddIPaU/gFA==",
1681
  "engines": {
1682
  "node": ">=14.20.1"
1683
  }
@@ -2769,19 +2441,6 @@
2769
  "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
2770
  "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
2771
  },
2772
- "node_modules/fsevents": {
2773
- "version": "2.3.2",
2774
- "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
2775
- "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
2776
- "hasInstallScript": true,
2777
- "optional": true,
2778
- "os": [
2779
- "darwin"
2780
- ],
2781
- "engines": {
2782
- "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
2783
- }
2784
- },
2785
  "node_modules/function-bind": {
2786
  "version": "1.1.1",
2787
  "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
@@ -2939,6 +2598,15 @@
2939
  "node": ">= 0.4.0"
2940
  }
2941
  },
 
 
 
 
 
 
 
 
 
2942
  "node_modules/has-flag": {
2943
  "version": "4.0.0",
2944
  "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -3344,6 +3012,31 @@
3344
  "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==",
3345
  "dev": true
3346
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3347
  "node_modules/katex": {
3348
  "version": "0.16.8",
3349
  "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.8.tgz",
@@ -3691,11 +3384,11 @@
3691
  }
3692
  },
3693
  "node_modules/mongodb": {
3694
- "version": "5.8.0",
3695
- "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.8.0.tgz",
3696
- "integrity": "sha512-xx4CXmxcj3bNe7iGBlhntVrUqrNARYhUZteXaz4epEESv4oXD/FONAovcyoCaEffdYlw25Yz284OxMfpnPLlgQ==",
3697
  "dependencies": {
3698
- "bson": "^5.4.0",
3699
  "mongodb-connection-string-url": "^2.6.0",
3700
  "socks": "^2.7.1"
3701
  },
@@ -3849,6 +3542,52 @@
3849
  "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.10.tgz",
3850
  "integrity": "sha512-5GFldHPXVG/YZmFzJvKK2zDSzPKhEp0+ZR5SVaoSag9fsL5YgHbUHDfnG5494ISANDcK4KwPXAx2xqVEydmd7w=="
3851
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3852
  "node_modules/normalize-path": {
3853
  "version": "3.0.0",
3854
  "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
@@ -5749,6 +5488,12 @@
5749
  "node": ">=0.8.0"
5750
  }
5751
  },
 
 
 
 
 
 
5752
  "node_modules/undici": {
5753
  "version": "5.22.0",
5754
  "resolved": "https://registry.npmjs.org/undici/-/undici-5.22.0.tgz",
 
36
  "@sveltejs/kit": "^1.15.10",
37
  "@tailwindcss/typography": "^0.5.9",
38
  "@types/jsdom": "^21.1.1",
39
+ "@types/jsonlint": "^1.6.1",
40
  "@types/marked": "^4.0.8",
41
  "@types/parquetjs": "^0.10.3",
42
  "@typescript-eslint/eslint-plugin": "^5.45.0",
 
44
  "eslint": "^8.28.0",
45
  "eslint-config-prettier": "^8.5.0",
46
  "eslint-plugin-svelte": "^2.27.3",
47
+ "jsonlint": "^1.6.3",
48
  "marked-katex-extension": "^3.0.6",
49
  "prettier": "^2.8.0",
50
  "prettier-plugin-svelte": "^2.8.1",
 
80
  "url": "https://github.com/sponsors/antfu"
81
  }
82
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  "node_modules/@esbuild/linux-x64": {
84
  "version": "0.17.16",
85
  "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.16.tgz",
 
96
  "node": ">=12"
97
  }
98
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  "node_modules/@eslint-community/eslint-utils": {
100
  "version": "4.4.0",
101
  "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
 
678
  "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
679
  "dev": true
680
  },
681
+ "node_modules/@types/jsonlint": {
682
+ "version": "1.6.1",
683
+ "resolved": "https://registry.npmjs.org/@types/jsonlint/-/jsonlint-1.6.1.tgz",
684
+ "integrity": "sha512-hL1yjV2gJx+CB6jUS0+/c8A1XkKCg4GWK+fX8UnlyIjORNg+jm65Q0fLSEjn5BjVt/hj1lXlBytVhQr8wmtkrA==",
685
+ "dev": true
686
+ },
687
  "node_modules/@types/katex": {
688
  "version": "0.16.3",
689
  "resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.3.tgz",
 
1347
  }
1348
  },
1349
  "node_modules/bson": {
1350
+ "version": "5.5.0",
1351
+ "resolved": "https://registry.npmjs.org/bson/-/bson-5.5.0.tgz",
1352
+ "integrity": "sha512-B+QB4YmDx9RStKv8LLSl/aVIEV3nYJc3cJNNTK2Cd1TL+7P+cNpw9mAPeCgc5K+j01Dv6sxUzcITXDx7ZU3F0w==",
1353
  "engines": {
1354
  "node": ">=14.20.1"
1355
  }
 
2441
  "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
2442
  "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
2443
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
2444
  "node_modules/function-bind": {
2445
  "version": "1.1.1",
2446
  "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
 
2598
  "node": ">= 0.4.0"
2599
  }
2600
  },
2601
+ "node_modules/has-color": {
2602
+ "version": "0.1.7",
2603
+ "resolved": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz",
2604
+ "integrity": "sha512-kaNz5OTAYYmt646Hkqw50/qyxP2vFnTVu5AQ1Zmk22Kk5+4Qx6BpO8+u7IKsML5fOsFk0ZT0AcCJNYwcvaLBvw==",
2605
+ "dev": true,
2606
+ "engines": {
2607
+ "node": ">=0.10.0"
2608
+ }
2609
+ },
2610
  "node_modules/has-flag": {
2611
  "version": "4.0.0",
2612
  "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
 
3012
  "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==",
3013
  "dev": true
3014
  },
3015
+ "node_modules/jsonlint": {
3016
+ "version": "1.6.3",
3017
+ "resolved": "https://registry.npmjs.org/jsonlint/-/jsonlint-1.6.3.tgz",
3018
+ "integrity": "sha512-jMVTMzP+7gU/IyC6hvKyWpUU8tmTkK5b3BPNuMI9U8Sit+YAWLlZwB6Y6YrdCxfg2kNz05p3XY3Bmm4m26Nv3A==",
3019
+ "dev": true,
3020
+ "dependencies": {
3021
+ "JSV": "^4.0.x",
3022
+ "nomnom": "^1.5.x"
3023
+ },
3024
+ "bin": {
3025
+ "jsonlint": "lib/cli.js"
3026
+ },
3027
+ "engines": {
3028
+ "node": ">= 0.6"
3029
+ }
3030
+ },
3031
+ "node_modules/JSV": {
3032
+ "version": "4.0.2",
3033
+ "resolved": "https://registry.npmjs.org/JSV/-/JSV-4.0.2.tgz",
3034
+ "integrity": "sha512-ZJ6wx9xaKJ3yFUhq5/sk82PJMuUyLk277I8mQeyDgCTjGdjWJIvPfaU5LIXaMuaN2UO1X3kZH4+lgphublZUHw==",
3035
+ "dev": true,
3036
+ "engines": {
3037
+ "node": "*"
3038
+ }
3039
+ },
3040
  "node_modules/katex": {
3041
  "version": "0.16.8",
3042
  "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.8.tgz",
 
3384
  }
3385
  },
3386
  "node_modules/mongodb": {
3387
+ "version": "5.9.0",
3388
+ "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.9.0.tgz",
3389
+ "integrity": "sha512-g+GCMHN1CoRUA+wb1Agv0TI4YTSiWr42B5ulkiAfLLHitGK1R+PkSAf3Lr5rPZwi/3F04LiaZEW0Kxro9Fi2TA==",
3390
  "dependencies": {
3391
+ "bson": "^5.5.0",
3392
  "mongodb-connection-string-url": "^2.6.0",
3393
  "socks": "^2.7.1"
3394
  },
 
3542
  "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.10.tgz",
3543
  "integrity": "sha512-5GFldHPXVG/YZmFzJvKK2zDSzPKhEp0+ZR5SVaoSag9fsL5YgHbUHDfnG5494ISANDcK4KwPXAx2xqVEydmd7w=="
3544
  },
3545
+ "node_modules/nomnom": {
3546
+ "version": "1.8.1",
3547
+ "resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.8.1.tgz",
3548
+ "integrity": "sha512-5s0JxqhDx9/rksG2BTMVN1enjWSvPidpoSgViZU4ZXULyTe+7jxcCRLB6f42Z0l1xYJpleCBtSyY6Lwg3uu5CQ==",
3549
+ "deprecated": "Package no longer supported. Contact [email protected] for more info.",
3550
+ "dev": true,
3551
+ "dependencies": {
3552
+ "chalk": "~0.4.0",
3553
+ "underscore": "~1.6.0"
3554
+ }
3555
+ },
3556
+ "node_modules/nomnom/node_modules/ansi-styles": {
3557
+ "version": "1.0.0",
3558
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.0.0.tgz",
3559
+ "integrity": "sha512-3iF4FIKdxaVYT3JqQuY3Wat/T2t7TRbbQ94Fu50ZUCbLy4TFbTzr90NOHQodQkNqmeEGCw8WbeP78WNi6SKYUA==",
3560
+ "dev": true,
3561
+ "engines": {
3562
+ "node": ">=0.8.0"
3563
+ }
3564
+ },
3565
+ "node_modules/nomnom/node_modules/chalk": {
3566
+ "version": "0.4.0",
3567
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.4.0.tgz",
3568
+ "integrity": "sha512-sQfYDlfv2DGVtjdoQqxS0cEZDroyG8h6TamA6rvxwlrU5BaSLDx9xhatBYl2pxZ7gmpNaPFVwBtdGdu5rQ+tYQ==",
3569
+ "dev": true,
3570
+ "dependencies": {
3571
+ "ansi-styles": "~1.0.0",
3572
+ "has-color": "~0.1.0",
3573
+ "strip-ansi": "~0.1.0"
3574
+ },
3575
+ "engines": {
3576
+ "node": ">=0.8.0"
3577
+ }
3578
+ },
3579
+ "node_modules/nomnom/node_modules/strip-ansi": {
3580
+ "version": "0.1.1",
3581
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.1.1.tgz",
3582
+ "integrity": "sha512-behete+3uqxecWlDAm5lmskaSaISA+ThQ4oNNBDTBJt0x2ppR6IPqfZNuj6BLaLJ/Sji4TPZlcRyOis8wXQTLg==",
3583
+ "dev": true,
3584
+ "bin": {
3585
+ "strip-ansi": "cli.js"
3586
+ },
3587
+ "engines": {
3588
+ "node": ">=0.8.0"
3589
+ }
3590
+ },
3591
  "node_modules/normalize-path": {
3592
  "version": "3.0.0",
3593
  "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
 
5488
  "node": ">=0.8.0"
5489
  }
5490
  },
5491
+ "node_modules/underscore": {
5492
+ "version": "1.6.0",
5493
+ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz",
5494
+ "integrity": "sha512-z4o1fvKUojIWh9XuaVLUDdf86RQiq13AC1dmHbTpoyuu+bquHms76v16CjycCbec87J7z0k//SiQVk0sMdFmpQ==",
5495
+ "dev": true
5496
+ },
5497
  "node_modules/undici": {
5498
  "version": "5.22.0",
5499
  "resolved": "https://registry.npmjs.org/undici/-/undici-5.22.0.tgz",
package.json CHANGED
@@ -20,6 +20,7 @@
20
  "@sveltejs/kit": "^1.15.10",
21
  "@tailwindcss/typography": "^0.5.9",
22
  "@types/jsdom": "^21.1.1",
 
23
  "@types/marked": "^4.0.8",
24
  "@types/parquetjs": "^0.10.3",
25
  "@typescript-eslint/eslint-plugin": "^5.45.0",
@@ -27,6 +28,7 @@
27
  "eslint": "^8.28.0",
28
  "eslint-config-prettier": "^8.5.0",
29
  "eslint-plugin-svelte": "^2.27.3",
 
30
  "marked-katex-extension": "^3.0.6",
31
  "prettier": "^2.8.0",
32
  "prettier-plugin-svelte": "^2.8.1",
 
20
  "@sveltejs/kit": "^1.15.10",
21
  "@tailwindcss/typography": "^0.5.9",
22
  "@types/jsdom": "^21.1.1",
23
+ "@types/jsonlint": "^1.6.1",
24
  "@types/marked": "^4.0.8",
25
  "@types/parquetjs": "^0.10.3",
26
  "@typescript-eslint/eslint-plugin": "^5.45.0",
 
28
  "eslint": "^8.28.0",
29
  "eslint-config-prettier": "^8.5.0",
30
  "eslint-plugin-svelte": "^2.27.3",
31
+ "jsonlint": "^1.6.3",
32
  "marked-katex-extension": "^3.0.6",
33
  "prettier": "^2.8.0",
34
  "prettier-plugin-svelte": "^2.8.1",
src/lib/server/models.ts CHANGED
@@ -2,6 +2,8 @@ import { HF_ACCESS_TOKEN, MODELS, OLD_MODELS } from "$env/static/private";
2
  import type { ChatTemplateInput, WebSearchQueryTemplateInput } from "$lib/types/Template";
3
  import { compileTemplate } from "$lib/utils/template";
4
  import { z } from "zod";
 
 
5
 
6
  type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
7
 
@@ -37,6 +39,17 @@ const combinedEndpoint = endpoint.transform((data) => {
37
  }
38
  });
39
 
 
 
 
 
 
 
 
 
 
 
 
40
  const modelsRaw = z
41
  .array(
42
  z.object({
@@ -96,7 +109,7 @@ const modelsRaw = z
96
  .optional(),
97
  })
98
  )
99
- .parse(JSON.parse(MODELS));
100
 
101
  export const models = await Promise.all(
102
  modelsRaw.map(async (m) => ({
 
2
  import type { ChatTemplateInput, WebSearchQueryTemplateInput } from "$lib/types/Template";
3
  import { compileTemplate } from "$lib/utils/template";
4
  import { z } from "zod";
5
+ import { error } from "@sveltejs/kit";
6
+ import { parse } from "jsonlint";
7
 
8
  type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
9
 
 
39
  }
40
  });
41
 
42
+ let parsedModels;
43
+ try {
44
+ parsedModels = parse(MODELS);
45
+ } catch (e) {
46
+ const { stack, message } = e as Error;
47
+ console.error(stack);
48
+ const safe_error_message = message.split("\n")[0].slice(0, -1);
49
+ throw error(500, {
50
+ message: "Failed to parse `MODELS` config:<br>" + safe_error_message,
51
+ });
52
+ }
53
  const modelsRaw = z
54
  .array(
55
  z.object({
 
109
  .optional(),
110
  })
111
  )
112
+ .parse(parsedModels);
113
 
114
  export const models = await Promise.all(
115
  modelsRaw.map(async (m) => ({