nsarrazin commited on
Commit
4906f37
·
unverified ·
1 Parent(s): baba36c

New `InferenceClient` endpoint type (#1813)

Browse files

* work on hf inference endpoint

* working tools

* fix: debug tool

* feat: working tools with new endpoint type

* feat: move config to HfInference

* wip

* fix: hf inference endpoint

* refactor: rename endpoint

* fix: rendering

* feat: working tools on every supported model

* fix: multimodal

* refactor: rename endpoint type

* refactor: base URL

* fix: prevent simultaneous provider and baseURL usage

* fix: disable tools on qwen 2.5 vl

* feat: make sure json is correctly formatted

chart/env/prod.yaml CHANGED
@@ -60,6 +60,7 @@ envVars:
60
  "max_new_tokens": 1024,
61
  "truncate": 7167
62
  },
 
63
  "promptExamples": [
64
  {
65
  "title": "Write an email",
@@ -91,6 +92,7 @@ envVars:
91
  "stop": ["<|endoftext|>", "<|im_end|>"],
92
  "temperature": 0.6,
93
  },
 
94
  "promptExamples": [
95
  {
96
  "title": "Write an email",
@@ -107,7 +109,7 @@ envVars:
107
  ],
108
  "endpoints": [
109
  {
110
- "type": "openai",
111
  "baseURL": "https://api-inference.endpoints.huggingface.tech/models/Qwen/Qwen3-235B-A22B/v1"
112
  }
113
  ]
@@ -126,6 +128,7 @@ envVars:
126
  "max_new_tokens": 3072
127
  },
128
  "tools": true,
 
129
  "promptExamples": [
130
  {
131
  "title": "Write an email",
@@ -148,12 +151,14 @@ envVars:
148
  "websiteUrl": "https://docs.cohere.com/docs/command-r-plus",
149
  "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/cohere-logo.png",
150
  "tools": true,
 
151
  "parameters": {
152
  "stop": ["<|END_OF_TURN_TOKEN|>", "<|im_end|>"],
153
  "truncate": 28672,
154
  "max_new_tokens": 2048,
155
  "temperature": 0.3
156
  },
 
157
  "promptExamples": [
158
  {
159
  "title": "Generate image",
@@ -180,6 +185,7 @@ envVars:
180
  "beginToken": "",
181
  "endToken": "</think>"
182
  },
 
183
  "promptExamples": [
184
  {
185
  "title": "Rs in strawberry",
@@ -196,8 +202,8 @@ envVars:
196
  ],
197
  "endpoints": [
198
  {
199
- "type": "openai",
200
- "baseURL": "https://api-inference.endpoints.huggingface.tech/models/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B/v1"
201
  }
202
  ]
203
  },
@@ -229,13 +235,14 @@ envVars:
229
  ],
230
  "endpoints": [
231
  {
232
- "type": "openai",
233
  "baseURL": "https://api-inference.endpoints.huggingface.tech/models/nvidia/Llama-3.1-Nemotron-70B-Instruct-HF/v1"
234
  }
235
  ]
236
  },
237
  {
238
  "name": "Qwen/QwQ-32B",
 
239
  "preprompt": "You are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step.",
240
  "modelUrl": "https://huggingface.co/Qwen/QwQ-32B",
241
  "websiteUrl": "https://qwenlm.github.io/blog/qwq-32b/",
@@ -262,8 +269,7 @@ envVars:
262
  ],
263
  "endpoints": [
264
  {
265
- "type": "openai",
266
- "baseURL": "https://atv7xs1nxxtx2wl0.us-east-1.aws.endpoints.huggingface.cloud/v1"
267
  }
268
  ]
269
  },
@@ -271,6 +277,8 @@ envVars:
271
  "name": "google/gemma-3-27b-it",
272
  "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/google-logo.png",
273
  "multimodal": true,
 
 
274
  "description": "Google's latest open model with great multilingual performance, supports image inputs natively.",
275
  "websiteUrl": "https://blog.google/technology/developers/gemma-3/",
276
  "promptExamples": [
@@ -289,15 +297,15 @@ envVars:
289
  ],
290
  "endpoints": [
291
  {
292
- "type": "openai",
293
  "baseURL": "https://wp0d3hn6s3k8jk22.us-east-1.aws.endpoints.huggingface.cloud/v1",
294
  "multimodal": {
295
  "image": {
296
  "maxSizeInMB": 10,
297
  "maxWidth": 560,
298
  "maxHeight": 560,
299
- "supportedMimeTypes": ["image/jpeg"],
300
- "preferredMimeType": "image/jpeg"
301
  }
302
  }
303
  }
@@ -305,6 +313,7 @@ envVars:
305
  },
306
  {
307
  "name": "mistralai/Mistral-Small-3.1-24B-Instruct-2503",
 
308
  "displayName": "mistralai/Mistral-Small-3.1-24B-Instruct-2503",
309
  "description": "A small model with good capabilities in language understanding and commonsense reasoning.",
310
  "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/mistral-logo.png",
@@ -328,8 +337,8 @@ envVars:
328
 
329
  "endpoints": [
330
  {
331
- "type": "openai",
332
- "baseURL": "https://hkjfqcryevvq9cie.us-east-1.aws.endpoints.huggingface.cloud/v1"
333
  }
334
  ]
335
  },
@@ -356,8 +365,7 @@ envVars:
356
  ],
357
  "endpoints": [
358
  {
359
- "type": "openai",
360
- "baseURL": "https://lf91qeosuambouj4.us-east-1.aws.endpoints.huggingface.cloud/v1",
361
  "multimodal": {
362
  "image": {
363
  "maxSizeInMB": 10,
@@ -372,6 +380,8 @@ envVars:
372
  },
373
  {
374
  "name": "microsoft/Phi-4",
 
 
375
  "description": "One of the best small models, super fast for simple tasks.",
376
  "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/microsoft-logo.png",
377
  "modelUrl": "https://huggingface.co/microsoft/Phi-4",
@@ -399,7 +409,7 @@ envVars:
399
  ],
400
  "endpoints": [
401
  {
402
- "type": "openai",
403
  "baseURL": "https://up5ijetg6a2e9zlb.us-east-1.aws.endpoints.huggingface.cloud/v1"
404
  }
405
  ]
@@ -407,6 +417,7 @@ envVars:
407
  {
408
  "name": "NousResearch/Hermes-3-Llama-3.1-8B",
409
  "description": "Nous Research's latest Hermes 3 release in 8B size. Follows instruction closely.",
 
410
  "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/nous-logo.png",
411
  "websiteUrl": "https://nousresearch.com/",
412
  "modelUrl": "https://huggingface.co/NousResearch/Hermes-3-Llama-3.1-8B",
@@ -429,23 +440,8 @@ envVars:
429
  "temperature": 0.6,
430
  "truncate": 14336,
431
  "max_new_tokens": 1536
432
- }
433
- },
434
- {
435
- "name": "internal/task",
436
- "tokenizer" : "NousResearch/Hermes-3-Llama-3.1-8B",
437
- "unlisted": true,
438
- "tools" : true,
439
- "endpoints": [
440
- {
441
- "type": "openai",
442
- "baseURL": "https://api-inference.endpoints.huggingface.tech/models/NousResearch/Hermes-3-Llama-3.1-8B/v1"
443
- }
444
- ],
445
- "parameters": {
446
- "temperature": 0.1,
447
- "max_new_tokens": 256
448
  },
 
449
  }
450
  ]
451
 
@@ -539,7 +535,18 @@ envVars:
539
  PUBLIC_APP_DISCLAIMER: 1
540
  PUBLIC_PLAUSIBLE_SCRIPT_URL: "/js/script.js"
541
  REQUIRE_FEATURED_ASSISTANTS: "true"
542
- TASK_MODEL: "internal/task"
 
 
 
 
 
 
 
 
 
 
 
543
  TEXT_EMBEDDING_MODELS: >
544
  [{
545
  "name": "bge-base-en-v1-5-sxa",
 
60
  "max_new_tokens": 1024,
61
  "truncate": 7167
62
  },
63
+ "endpoints": [{"type" : "inference-client"}],
64
  "promptExamples": [
65
  {
66
  "title": "Write an email",
 
92
  "stop": ["<|endoftext|>", "<|im_end|>"],
93
  "temperature": 0.6,
94
  },
95
+ "tools": true,
96
  "promptExamples": [
97
  {
98
  "title": "Write an email",
 
109
  ],
110
  "endpoints": [
111
  {
112
+ "type": "inference-client",
113
  "baseURL": "https://api-inference.endpoints.huggingface.tech/models/Qwen/Qwen3-235B-A22B/v1"
114
  }
115
  ]
 
128
  "max_new_tokens": 3072
129
  },
130
  "tools": true,
131
+ "endpoints": [{"type" : "inference-client"}],
132
  "promptExamples": [
133
  {
134
  "title": "Write an email",
 
151
  "websiteUrl": "https://docs.cohere.com/docs/command-r-plus",
152
  "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/cohere-logo.png",
153
  "tools": true,
154
+ "systemRoleSupported": false,
155
  "parameters": {
156
  "stop": ["<|END_OF_TURN_TOKEN|>", "<|im_end|>"],
157
  "truncate": 28672,
158
  "max_new_tokens": 2048,
159
  "temperature": 0.3
160
  },
161
+ "endpoints": [{"type" : "inference-client"}],
162
  "promptExamples": [
163
  {
164
  "title": "Generate image",
 
185
  "beginToken": "",
186
  "endToken": "</think>"
187
  },
188
+ "tools": true,
189
  "promptExamples": [
190
  {
191
  "title": "Rs in strawberry",
 
202
  ],
203
  "endpoints": [
204
  {
205
+ "type": "inference-client",
206
+ "baseURL": "https://internal.api-inference.huggingface.co/models/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B/v1"
207
  }
208
  ]
209
  },
 
235
  ],
236
  "endpoints": [
237
  {
238
+ "type": "inference-client",
239
  "baseURL": "https://api-inference.endpoints.huggingface.tech/models/nvidia/Llama-3.1-Nemotron-70B-Instruct-HF/v1"
240
  }
241
  ]
242
  },
243
  {
244
  "name": "Qwen/QwQ-32B",
245
+ "tools": true,
246
  "preprompt": "You are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step.",
247
  "modelUrl": "https://huggingface.co/Qwen/QwQ-32B",
248
  "websiteUrl": "https://qwenlm.github.io/blog/qwq-32b/",
 
269
  ],
270
  "endpoints": [
271
  {
272
+ "type": "inference-client",
 
273
  }
274
  ]
275
  },
 
277
  "name": "google/gemma-3-27b-it",
278
  "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/google-logo.png",
279
  "multimodal": true,
280
+ "tools": true,
281
+ "systemRoleSupported" : false,
282
  "description": "Google's latest open model with great multilingual performance, supports image inputs natively.",
283
  "websiteUrl": "https://blog.google/technology/developers/gemma-3/",
284
  "promptExamples": [
 
297
  ],
298
  "endpoints": [
299
  {
300
+ "type": "inference-client",
301
  "baseURL": "https://wp0d3hn6s3k8jk22.us-east-1.aws.endpoints.huggingface.cloud/v1",
302
  "multimodal": {
303
  "image": {
304
  "maxSizeInMB": 10,
305
  "maxWidth": 560,
306
  "maxHeight": 560,
307
+ "supportedMimeTypes": ["image/jpeg", "image/png", "image/webp"],
308
+ "preferredMimeType": "image/webp"
309
  }
310
  }
311
  }
 
313
  },
314
  {
315
  "name": "mistralai/Mistral-Small-3.1-24B-Instruct-2503",
316
+ "tools": true,
317
  "displayName": "mistralai/Mistral-Small-3.1-24B-Instruct-2503",
318
  "description": "A small model with good capabilities in language understanding and commonsense reasoning.",
319
  "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/mistral-logo.png",
 
337
 
338
  "endpoints": [
339
  {
340
+ "type": "inference-client",
341
+ "baseURL": "https://hkjfqcryevvq9cie.us-east-1.aws.endpoints.huggingface.cloud/v1"
342
  }
343
  ]
344
  },
 
365
  ],
366
  "endpoints": [
367
  {
368
+ "type": "inference-client",
 
369
  "multimodal": {
370
  "image": {
371
  "maxSizeInMB": 10,
 
380
  },
381
  {
382
  "name": "microsoft/Phi-4",
383
+ "tools": true,
384
+ "systemRoleSupported": false,
385
  "description": "One of the best small models, super fast for simple tasks.",
386
  "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/microsoft-logo.png",
387
  "modelUrl": "https://huggingface.co/microsoft/Phi-4",
 
409
  ],
410
  "endpoints": [
411
  {
412
+ "type": "inference-client",
413
  "baseURL": "https://up5ijetg6a2e9zlb.us-east-1.aws.endpoints.huggingface.cloud/v1"
414
  }
415
  ]
 
417
  {
418
  "name": "NousResearch/Hermes-3-Llama-3.1-8B",
419
  "description": "Nous Research's latest Hermes 3 release in 8B size. Follows instruction closely.",
420
+ "tools": true,
421
  "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/nous-logo.png",
422
  "websiteUrl": "https://nousresearch.com/",
423
  "modelUrl": "https://huggingface.co/NousResearch/Hermes-3-Llama-3.1-8B",
 
440
  "temperature": 0.6,
441
  "truncate": 14336,
442
  "max_new_tokens": 1536
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
443
  },
444
+ "endpoints": [{"type" : "inference-client"}]
445
  }
446
  ]
447
 
 
535
  PUBLIC_APP_DISCLAIMER: 1
536
  PUBLIC_PLAUSIBLE_SCRIPT_URL: "/js/script.js"
537
  REQUIRE_FEATURED_ASSISTANTS: "true"
538
+ TASK_MODEL: >
539
+ {
540
+ "name": "NousResearch/Hermes-3-Llama-3.1-8B",
541
+ "unlisted": true,
542
+ "endpoints": [{"type" : "inference-client"}],
543
+ "parameters": {
544
+ "temperature": 0.1,
545
+ "max_new_tokens": 256
546
+ }
547
+ }
548
+
549
+
550
  TEXT_EMBEDDING_MODELS: >
551
  [{
552
  "name": "bge-base-en-v1-5-sxa",
package-lock.json CHANGED
@@ -12,7 +12,9 @@
12
  "@cliqz/adblocker-playwright": "^1.34.0",
13
  "@gradio/client": "^1.8.0",
14
  "@huggingface/hub": "^0.5.1",
15
- "@huggingface/inference": "^2.8.1",
 
 
16
  "@huggingface/transformers": "^3.1.1",
17
  "@iconify-json/bi": "^1.1.21",
18
  "@playwright/browser-chromium": "^1.52.0",
@@ -86,6 +88,7 @@
86
  "fs-extra": "^11.3.0",
87
  "isomorphic-dompurify": "^2.13.0",
88
  "js-yaml": "^4.1.0",
 
89
  "minimist": "^1.2.8",
90
  "mongodb-memory-server": "^10.1.2",
91
  "node-llama-cpp": "^3.6.0",
@@ -2032,17 +2035,27 @@
2032
  }
2033
  },
2034
  "node_modules/@huggingface/inference": {
2035
- "version": "2.8.1",
2036
- "resolved": "https://registry.npmjs.org/@huggingface/inference/-/inference-2.8.1.tgz",
2037
- "integrity": "sha512-EfsNtY9OR6JCNaUa5bZu2mrs48iqeTz0Gutwf+fU0Kypx33xFQB4DKMhp8u4Ee6qVbLbNWvTHuWwlppLQl4p4Q==",
2038
  "license": "MIT",
2039
  "dependencies": {
2040
- "@huggingface/tasks": "^0.12.9"
 
2041
  },
2042
  "engines": {
2043
  "node": ">=18"
2044
  }
2045
  },
 
 
 
 
 
 
 
 
 
2046
  "node_modules/@huggingface/jinja": {
2047
  "version": "0.3.3",
2048
  "resolved": "https://registry.npmjs.org/@huggingface/jinja/-/jinja-0.3.3.tgz",
@@ -2052,10 +2065,33 @@
2052
  "node": ">=18"
2053
  }
2054
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2055
  "node_modules/@huggingface/tasks": {
2056
- "version": "0.12.30",
2057
- "resolved": "https://registry.npmjs.org/@huggingface/tasks/-/tasks-0.12.30.tgz",
2058
- "integrity": "sha512-A1ITdxbEzx9L8wKR8pF7swyrTLxWNDFIGDLUWInxvks2ruQ8PLRBZe8r0EcjC3CDdtlj9jV1V4cgV35K/iy3GQ==",
2059
  "license": "MIT"
2060
  },
2061
  "node_modules/@huggingface/transformers": {
@@ -2784,6 +2820,340 @@
2784
  "dev": true,
2785
  "license": "MIT"
2786
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2787
  "node_modules/@mongodb-js/saslprep": {
2788
  "version": "1.1.9",
2789
  "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.9.tgz",
@@ -6264,16 +6634,27 @@
6264
  "node": ">=8"
6265
  }
6266
  },
6267
- "node_modules/call-bind": {
6268
- "version": "1.0.7",
6269
- "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
6270
- "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
 
6271
  "dependencies": {
6272
- "es-define-property": "^1.0.0",
6273
  "es-errors": "^1.3.0",
6274
- "function-bind": "^1.1.2",
6275
- "get-intrinsic": "^1.2.4",
6276
- "set-function-length": "^1.2.1"
 
 
 
 
 
 
 
 
 
 
 
6277
  },
6278
  "engines": {
6279
  "node": ">= 0.4"
@@ -6866,6 +7247,19 @@
6866
  "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
6867
  "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
6868
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
6869
  "node_modules/create-require": {
6870
  "version": "1.1.1",
6871
  "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
@@ -7045,22 +7439,6 @@
7045
  "node": ">=0.10.0"
7046
  }
7047
  },
7048
- "node_modules/define-data-property": {
7049
- "version": "1.1.4",
7050
- "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
7051
- "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
7052
- "dependencies": {
7053
- "es-define-property": "^1.0.0",
7054
- "es-errors": "^1.3.0",
7055
- "gopd": "^1.0.1"
7056
- },
7057
- "engines": {
7058
- "node": ">= 0.4"
7059
- },
7060
- "funding": {
7061
- "url": "https://github.com/sponsors/ljharb"
7062
- }
7063
- },
7064
  "node_modules/delayed-stream": {
7065
  "version": "1.0.0",
7066
  "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
@@ -7235,6 +7613,20 @@
7235
  "url": "https://dotenvx.com"
7236
  }
7237
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7238
  "node_modules/eastasianwidth": {
7239
  "version": "0.2.0",
7240
  "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
@@ -7312,12 +7704,10 @@
7312
  }
7313
  },
7314
  "node_modules/es-define-property": {
7315
- "version": "1.0.0",
7316
- "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
7317
- "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
7318
- "dependencies": {
7319
- "get-intrinsic": "^1.2.4"
7320
- },
7321
  "engines": {
7322
  "node": ">= 0.4"
7323
  }
@@ -7326,6 +7716,7 @@
7326
  "version": "1.3.0",
7327
  "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
7328
  "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
 
7329
  "engines": {
7330
  "node": ">= 0.4"
7331
  }
@@ -7337,6 +7728,18 @@
7337
  "dev": true,
7338
  "license": "MIT"
7339
  },
 
 
 
 
 
 
 
 
 
 
 
 
7340
  "node_modules/esbuild": {
7341
  "version": "0.25.1",
7342
  "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.1.tgz",
@@ -7800,6 +8203,15 @@
7800
  "node": ">=12.0.0"
7801
  }
7802
  },
 
 
 
 
 
 
 
 
 
7803
  "node_modules/execa": {
7804
  "version": "8.0.1",
7805
  "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz",
@@ -7899,6 +8311,21 @@
7899
  "url": "https://opencollective.com/express"
7900
  }
7901
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7902
  "node_modules/express/node_modules/cookie": {
7903
  "version": "0.7.1",
7904
  "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz",
@@ -8542,15 +8969,21 @@
8542
  }
8543
  },
8544
  "node_modules/get-intrinsic": {
8545
- "version": "1.2.4",
8546
- "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
8547
- "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
 
8548
  "dependencies": {
 
 
8549
  "es-errors": "^1.3.0",
 
8550
  "function-bind": "^1.1.2",
8551
- "has-proto": "^1.0.1",
8552
- "has-symbols": "^1.0.3",
8553
- "hasown": "^2.0.0"
 
 
8554
  },
8555
  "engines": {
8556
  "node": ">= 0.4"
@@ -8559,6 +8992,19 @@
8559
  "url": "https://github.com/sponsors/ljharb"
8560
  }
8561
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
8562
  "node_modules/get-stream": {
8563
  "version": "9.0.1",
8564
  "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz",
@@ -8670,11 +9116,12 @@
8670
  }
8671
  },
8672
  "node_modules/gopd": {
8673
- "version": "1.0.1",
8674
- "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
8675
- "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
8676
- "dependencies": {
8677
- "get-intrinsic": "^1.1.3"
 
8678
  },
8679
  "funding": {
8680
  "url": "https://github.com/sponsors/ljharb"
@@ -8747,32 +9194,11 @@
8747
  "node": ">=8"
8748
  }
8749
  },
8750
- "node_modules/has-property-descriptors": {
8751
- "version": "1.0.2",
8752
- "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
8753
- "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
8754
- "dependencies": {
8755
- "es-define-property": "^1.0.0"
8756
- },
8757
- "funding": {
8758
- "url": "https://github.com/sponsors/ljharb"
8759
- }
8760
- },
8761
- "node_modules/has-proto": {
8762
- "version": "1.0.3",
8763
- "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
8764
- "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==",
8765
- "engines": {
8766
- "node": ">= 0.4"
8767
- },
8768
- "funding": {
8769
- "url": "https://github.com/sponsors/ljharb"
8770
- }
8771
- },
8772
  "node_modules/has-symbols": {
8773
- "version": "1.0.3",
8774
- "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
8775
- "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
 
8776
  "engines": {
8777
  "node": ">= 0.4"
8778
  },
@@ -9375,6 +9801,12 @@
9375
  "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
9376
  "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ=="
9377
  },
 
 
 
 
 
 
9378
  "node_modules/is-reference": {
9379
  "version": "1.2.1",
9380
  "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
@@ -9798,6 +10230,16 @@
9798
  "underscore": "1.12.1"
9799
  }
9800
  },
 
 
 
 
 
 
 
 
 
 
9801
  "node_modules/jwa": {
9802
  "version": "2.0.0",
9803
  "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz",
@@ -10338,6 +10780,15 @@
10338
  "node": ">= 18"
10339
  }
10340
  },
 
 
 
 
 
 
 
 
 
10341
  "node_modules/media-typer": {
10342
  "version": "0.3.0",
10343
  "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@@ -11359,9 +11810,10 @@
11359
  }
11360
  },
11361
  "node_modules/object-inspect": {
11362
- "version": "1.13.2",
11363
- "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz",
11364
- "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==",
 
11365
  "engines": {
11366
  "node": ">= 0.4"
11367
  },
@@ -12031,6 +12483,15 @@
12031
  "node": ">= 6"
12032
  }
12033
  },
 
 
 
 
 
 
 
 
 
12034
  "node_modules/pkg-dir": {
12035
  "version": "4.2.0",
12036
  "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
@@ -12989,6 +13450,48 @@
12989
  "fsevents": "~2.3.2"
12990
  }
12991
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12992
  "node_modules/rrweb-cssom": {
12993
  "version": "0.6.0",
12994
  "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.6.0.tgz",
@@ -13236,22 +13739,6 @@
13236
  "integrity": "sha512-lXLOiqpkUumhRdFF3k1osNXCy9akgx/dyPZ5p8qAg9seJzXr5ZrlqZuWIMuY6ejOsVLE6flJ5/h3lsn57fQ/PQ==",
13237
  "dev": true
13238
  },
13239
- "node_modules/set-function-length": {
13240
- "version": "1.2.2",
13241
- "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
13242
- "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==",
13243
- "dependencies": {
13244
- "define-data-property": "^1.1.4",
13245
- "es-errors": "^1.3.0",
13246
- "function-bind": "^1.1.2",
13247
- "get-intrinsic": "^1.2.4",
13248
- "gopd": "^1.0.1",
13249
- "has-property-descriptors": "^1.0.2"
13250
- },
13251
- "engines": {
13252
- "node": ">= 0.4"
13253
- }
13254
- },
13255
  "node_modules/setprototypeof": {
13256
  "version": "1.2.0",
13257
  "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
@@ -13315,14 +13802,69 @@
13315
  }
13316
  },
13317
  "node_modules/side-channel": {
13318
- "version": "1.0.6",
13319
- "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
13320
- "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13321
  "dependencies": {
13322
- "call-bind": "^1.0.7",
13323
  "es-errors": "^1.3.0",
13324
- "get-intrinsic": "^1.2.4",
13325
- "object-inspect": "^1.13.1"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13326
  },
13327
  "engines": {
13328
  "node": ">= 0.4"
@@ -15578,12 +16120,22 @@
15578
  "license": "MIT"
15579
  },
15580
  "node_modules/zod": {
15581
- "version": "3.23.8",
15582
- "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",
15583
- "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==",
 
15584
  "funding": {
15585
  "url": "https://github.com/sponsors/colinhacks"
15586
  }
 
 
 
 
 
 
 
 
 
15587
  }
15588
  }
15589
  }
 
12
  "@cliqz/adblocker-playwright": "^1.34.0",
13
  "@gradio/client": "^1.8.0",
14
  "@huggingface/hub": "^0.5.1",
15
+ "@huggingface/inference": "^3.12.1",
16
+ "@huggingface/mcp-client": "^0.1.1",
17
+ "@huggingface/tasks": "^0.19.1",
18
  "@huggingface/transformers": "^3.1.1",
19
  "@iconify-json/bi": "^1.1.21",
20
  "@playwright/browser-chromium": "^1.52.0",
 
88
  "fs-extra": "^11.3.0",
89
  "isomorphic-dompurify": "^2.13.0",
90
  "js-yaml": "^4.1.0",
91
+ "jsonrepair": "^3.12.0",
92
  "minimist": "^1.2.8",
93
  "mongodb-memory-server": "^10.1.2",
94
  "node-llama-cpp": "^3.6.0",
 
2035
  }
2036
  },
2037
  "node_modules/@huggingface/inference": {
2038
+ "version": "3.12.1",
2039
+ "resolved": "https://registry.npmjs.org/@huggingface/inference/-/inference-3.12.1.tgz",
2040
+ "integrity": "sha512-gRnRHZkVAb7mzmPnLcFrttA17yZdUiz+xLqk19FBwCsCjBBlcDCXVIrZ3RW1DdZq297PB6m6t995600sDq3T6g==",
2041
  "license": "MIT",
2042
  "dependencies": {
2043
+ "@huggingface/jinja": "^0.4.1",
2044
+ "@huggingface/tasks": "^0.19.2"
2045
  },
2046
  "engines": {
2047
  "node": ">=18"
2048
  }
2049
  },
2050
+ "node_modules/@huggingface/inference/node_modules/@huggingface/jinja": {
2051
+ "version": "0.4.1",
2052
+ "resolved": "https://registry.npmjs.org/@huggingface/jinja/-/jinja-0.4.1.tgz",
2053
+ "integrity": "sha512-3WXbMFaPkk03LRCM0z0sylmn8ddDm4ubjU7X+Hg4M2GOuMklwoGAFXp9V2keq7vltoB/c7McE5aHUVVddAewsw==",
2054
+ "license": "MIT",
2055
+ "engines": {
2056
+ "node": ">=18"
2057
+ }
2058
+ },
2059
  "node_modules/@huggingface/jinja": {
2060
  "version": "0.3.3",
2061
  "resolved": "https://registry.npmjs.org/@huggingface/jinja/-/jinja-0.3.3.tgz",
 
2065
  "node": ">=18"
2066
  }
2067
  },
2068
+ "node_modules/@huggingface/mcp-client": {
2069
+ "version": "0.1.1",
2070
+ "resolved": "https://registry.npmjs.org/@huggingface/mcp-client/-/mcp-client-0.1.1.tgz",
2071
+ "integrity": "sha512-jr8m0msG8XxqxJ6ibGZNcR8sHBeU3J0YCVbzjqL2UVe0YHShowMBgTdGzbuf2AVcjXbcU5bzJR+T0m7q3YooCw==",
2072
+ "license": "MIT",
2073
+ "dependencies": {
2074
+ "@huggingface/inference": "^3.9.2",
2075
+ "@huggingface/tasks": "^0.18.11",
2076
+ "@modelcontextprotocol/sdk": "^1.9.0"
2077
+ },
2078
+ "bin": {
2079
+ "tiny-agent": "dist/cli.js"
2080
+ },
2081
+ "engines": {
2082
+ "node": ">=18"
2083
+ }
2084
+ },
2085
+ "node_modules/@huggingface/mcp-client/node_modules/@huggingface/tasks": {
2086
+ "version": "0.18.12",
2087
+ "resolved": "https://registry.npmjs.org/@huggingface/tasks/-/tasks-0.18.12.tgz",
2088
+ "integrity": "sha512-hUEYhXJzJCUhLSBNglW+Sji5fuzMnpBimp3kbdcGor+MaN9xb+qrcLnMC7X8aOcZaZdCErwYYIqz2oSP2EM4Bg==",
2089
+ "license": "MIT"
2090
+ },
2091
  "node_modules/@huggingface/tasks": {
2092
+ "version": "0.19.4",
2093
+ "resolved": "https://registry.npmjs.org/@huggingface/tasks/-/tasks-0.19.4.tgz",
2094
+ "integrity": "sha512-biTcoKBAtX0QaW5Rmx9O1YqU5YYpehiZDcSoAVx0SbwoMkXxFs23O59TcdPbFE4a3j5jK1eH0kltATxeGLp6dQ==",
2095
  "license": "MIT"
2096
  },
2097
  "node_modules/@huggingface/transformers": {
 
2820
  "dev": true,
2821
  "license": "MIT"
2822
  },
2823
+ "node_modules/@modelcontextprotocol/sdk": {
2824
+ "version": "1.10.2",
2825
+ "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.10.2.tgz",
2826
+ "integrity": "sha512-rb6AMp2DR4SN+kc6L1ta2NCpApyA9WYNx3CrTSZvGxq9wH71bRur+zRqPfg0vQ9mjywR7qZdX2RGHOPq3ss+tA==",
2827
+ "license": "MIT",
2828
+ "dependencies": {
2829
+ "content-type": "^1.0.5",
2830
+ "cors": "^2.8.5",
2831
+ "cross-spawn": "^7.0.3",
2832
+ "eventsource": "^3.0.2",
2833
+ "express": "^5.0.1",
2834
+ "express-rate-limit": "^7.5.0",
2835
+ "pkce-challenge": "^5.0.0",
2836
+ "raw-body": "^3.0.0",
2837
+ "zod": "^3.23.8",
2838
+ "zod-to-json-schema": "^3.24.1"
2839
+ },
2840
+ "engines": {
2841
+ "node": ">=18"
2842
+ }
2843
+ },
2844
+ "node_modules/@modelcontextprotocol/sdk/node_modules/accepts": {
2845
+ "version": "2.0.0",
2846
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz",
2847
+ "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==",
2848
+ "license": "MIT",
2849
+ "dependencies": {
2850
+ "mime-types": "^3.0.0",
2851
+ "negotiator": "^1.0.0"
2852
+ },
2853
+ "engines": {
2854
+ "node": ">= 0.6"
2855
+ }
2856
+ },
2857
+ "node_modules/@modelcontextprotocol/sdk/node_modules/body-parser": {
2858
+ "version": "2.2.0",
2859
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz",
2860
+ "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==",
2861
+ "license": "MIT",
2862
+ "dependencies": {
2863
+ "bytes": "^3.1.2",
2864
+ "content-type": "^1.0.5",
2865
+ "debug": "^4.4.0",
2866
+ "http-errors": "^2.0.0",
2867
+ "iconv-lite": "^0.6.3",
2868
+ "on-finished": "^2.4.1",
2869
+ "qs": "^6.14.0",
2870
+ "raw-body": "^3.0.0",
2871
+ "type-is": "^2.0.0"
2872
+ },
2873
+ "engines": {
2874
+ "node": ">=18"
2875
+ }
2876
+ },
2877
+ "node_modules/@modelcontextprotocol/sdk/node_modules/content-disposition": {
2878
+ "version": "1.0.0",
2879
+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz",
2880
+ "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==",
2881
+ "license": "MIT",
2882
+ "dependencies": {
2883
+ "safe-buffer": "5.2.1"
2884
+ },
2885
+ "engines": {
2886
+ "node": ">= 0.6"
2887
+ }
2888
+ },
2889
+ "node_modules/@modelcontextprotocol/sdk/node_modules/cookie": {
2890
+ "version": "0.7.2",
2891
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
2892
+ "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
2893
+ "license": "MIT",
2894
+ "engines": {
2895
+ "node": ">= 0.6"
2896
+ }
2897
+ },
2898
+ "node_modules/@modelcontextprotocol/sdk/node_modules/cookie-signature": {
2899
+ "version": "1.2.2",
2900
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
2901
+ "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==",
2902
+ "license": "MIT",
2903
+ "engines": {
2904
+ "node": ">=6.6.0"
2905
+ }
2906
+ },
2907
+ "node_modules/@modelcontextprotocol/sdk/node_modules/debug": {
2908
+ "version": "4.4.0",
2909
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
2910
+ "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",
2911
+ "license": "MIT",
2912
+ "dependencies": {
2913
+ "ms": "^2.1.3"
2914
+ },
2915
+ "engines": {
2916
+ "node": ">=6.0"
2917
+ },
2918
+ "peerDependenciesMeta": {
2919
+ "supports-color": {
2920
+ "optional": true
2921
+ }
2922
+ }
2923
+ },
2924
+ "node_modules/@modelcontextprotocol/sdk/node_modules/encodeurl": {
2925
+ "version": "2.0.0",
2926
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
2927
+ "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
2928
+ "license": "MIT",
2929
+ "engines": {
2930
+ "node": ">= 0.8"
2931
+ }
2932
+ },
2933
+ "node_modules/@modelcontextprotocol/sdk/node_modules/eventsource": {
2934
+ "version": "3.0.6",
2935
+ "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.6.tgz",
2936
+ "integrity": "sha512-l19WpE2m9hSuyP06+FbuUUf1G+R0SFLrtQfbRb9PRr+oimOfxQhgGCbVaXg5IvZyyTThJsxh6L/srkMiCeBPDA==",
2937
+ "license": "MIT",
2938
+ "dependencies": {
2939
+ "eventsource-parser": "^3.0.1"
2940
+ },
2941
+ "engines": {
2942
+ "node": ">=18.0.0"
2943
+ }
2944
+ },
2945
+ "node_modules/@modelcontextprotocol/sdk/node_modules/express": {
2946
+ "version": "5.1.0",
2947
+ "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz",
2948
+ "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==",
2949
+ "license": "MIT",
2950
+ "dependencies": {
2951
+ "accepts": "^2.0.0",
2952
+ "body-parser": "^2.2.0",
2953
+ "content-disposition": "^1.0.0",
2954
+ "content-type": "^1.0.5",
2955
+ "cookie": "^0.7.1",
2956
+ "cookie-signature": "^1.2.1",
2957
+ "debug": "^4.4.0",
2958
+ "encodeurl": "^2.0.0",
2959
+ "escape-html": "^1.0.3",
2960
+ "etag": "^1.8.1",
2961
+ "finalhandler": "^2.1.0",
2962
+ "fresh": "^2.0.0",
2963
+ "http-errors": "^2.0.0",
2964
+ "merge-descriptors": "^2.0.0",
2965
+ "mime-types": "^3.0.0",
2966
+ "on-finished": "^2.4.1",
2967
+ "once": "^1.4.0",
2968
+ "parseurl": "^1.3.3",
2969
+ "proxy-addr": "^2.0.7",
2970
+ "qs": "^6.14.0",
2971
+ "range-parser": "^1.2.1",
2972
+ "router": "^2.2.0",
2973
+ "send": "^1.1.0",
2974
+ "serve-static": "^2.2.0",
2975
+ "statuses": "^2.0.1",
2976
+ "type-is": "^2.0.1",
2977
+ "vary": "^1.1.2"
2978
+ },
2979
+ "engines": {
2980
+ "node": ">= 18"
2981
+ },
2982
+ "funding": {
2983
+ "type": "opencollective",
2984
+ "url": "https://opencollective.com/express"
2985
+ }
2986
+ },
2987
+ "node_modules/@modelcontextprotocol/sdk/node_modules/finalhandler": {
2988
+ "version": "2.1.0",
2989
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz",
2990
+ "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==",
2991
+ "license": "MIT",
2992
+ "dependencies": {
2993
+ "debug": "^4.4.0",
2994
+ "encodeurl": "^2.0.0",
2995
+ "escape-html": "^1.0.3",
2996
+ "on-finished": "^2.4.1",
2997
+ "parseurl": "^1.3.3",
2998
+ "statuses": "^2.0.1"
2999
+ },
3000
+ "engines": {
3001
+ "node": ">= 0.8"
3002
+ }
3003
+ },
3004
+ "node_modules/@modelcontextprotocol/sdk/node_modules/fresh": {
3005
+ "version": "2.0.0",
3006
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz",
3007
+ "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==",
3008
+ "license": "MIT",
3009
+ "engines": {
3010
+ "node": ">= 0.8"
3011
+ }
3012
+ },
3013
+ "node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite": {
3014
+ "version": "0.6.3",
3015
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
3016
+ "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
3017
+ "license": "MIT",
3018
+ "dependencies": {
3019
+ "safer-buffer": ">= 2.1.2 < 3.0.0"
3020
+ },
3021
+ "engines": {
3022
+ "node": ">=0.10.0"
3023
+ }
3024
+ },
3025
+ "node_modules/@modelcontextprotocol/sdk/node_modules/media-typer": {
3026
+ "version": "1.1.0",
3027
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz",
3028
+ "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==",
3029
+ "license": "MIT",
3030
+ "engines": {
3031
+ "node": ">= 0.8"
3032
+ }
3033
+ },
3034
+ "node_modules/@modelcontextprotocol/sdk/node_modules/merge-descriptors": {
3035
+ "version": "2.0.0",
3036
+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz",
3037
+ "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==",
3038
+ "license": "MIT",
3039
+ "engines": {
3040
+ "node": ">=18"
3041
+ },
3042
+ "funding": {
3043
+ "url": "https://github.com/sponsors/sindresorhus"
3044
+ }
3045
+ },
3046
+ "node_modules/@modelcontextprotocol/sdk/node_modules/mime-db": {
3047
+ "version": "1.54.0",
3048
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",
3049
+ "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==",
3050
+ "license": "MIT",
3051
+ "engines": {
3052
+ "node": ">= 0.6"
3053
+ }
3054
+ },
3055
+ "node_modules/@modelcontextprotocol/sdk/node_modules/mime-types": {
3056
+ "version": "3.0.1",
3057
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz",
3058
+ "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==",
3059
+ "license": "MIT",
3060
+ "dependencies": {
3061
+ "mime-db": "^1.54.0"
3062
+ },
3063
+ "engines": {
3064
+ "node": ">= 0.6"
3065
+ }
3066
+ },
3067
+ "node_modules/@modelcontextprotocol/sdk/node_modules/negotiator": {
3068
+ "version": "1.0.0",
3069
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
3070
+ "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==",
3071
+ "license": "MIT",
3072
+ "engines": {
3073
+ "node": ">= 0.6"
3074
+ }
3075
+ },
3076
+ "node_modules/@modelcontextprotocol/sdk/node_modules/qs": {
3077
+ "version": "6.14.0",
3078
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz",
3079
+ "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==",
3080
+ "license": "BSD-3-Clause",
3081
+ "dependencies": {
3082
+ "side-channel": "^1.1.0"
3083
+ },
3084
+ "engines": {
3085
+ "node": ">=0.6"
3086
+ },
3087
+ "funding": {
3088
+ "url": "https://github.com/sponsors/ljharb"
3089
+ }
3090
+ },
3091
+ "node_modules/@modelcontextprotocol/sdk/node_modules/raw-body": {
3092
+ "version": "3.0.0",
3093
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.0.tgz",
3094
+ "integrity": "sha512-RmkhL8CAyCRPXCE28MMH0z2PNWQBNk2Q09ZdxM9IOOXwxwZbN+qbWaatPkdkWIKL2ZVDImrN/pK5HTRz2PcS4g==",
3095
+ "license": "MIT",
3096
+ "dependencies": {
3097
+ "bytes": "3.1.2",
3098
+ "http-errors": "2.0.0",
3099
+ "iconv-lite": "0.6.3",
3100
+ "unpipe": "1.0.0"
3101
+ },
3102
+ "engines": {
3103
+ "node": ">= 0.8"
3104
+ }
3105
+ },
3106
+ "node_modules/@modelcontextprotocol/sdk/node_modules/send": {
3107
+ "version": "1.2.0",
3108
+ "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz",
3109
+ "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==",
3110
+ "license": "MIT",
3111
+ "dependencies": {
3112
+ "debug": "^4.3.5",
3113
+ "encodeurl": "^2.0.0",
3114
+ "escape-html": "^1.0.3",
3115
+ "etag": "^1.8.1",
3116
+ "fresh": "^2.0.0",
3117
+ "http-errors": "^2.0.0",
3118
+ "mime-types": "^3.0.1",
3119
+ "ms": "^2.1.3",
3120
+ "on-finished": "^2.4.1",
3121
+ "range-parser": "^1.2.1",
3122
+ "statuses": "^2.0.1"
3123
+ },
3124
+ "engines": {
3125
+ "node": ">= 18"
3126
+ }
3127
+ },
3128
+ "node_modules/@modelcontextprotocol/sdk/node_modules/serve-static": {
3129
+ "version": "2.2.0",
3130
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz",
3131
+ "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==",
3132
+ "license": "MIT",
3133
+ "dependencies": {
3134
+ "encodeurl": "^2.0.0",
3135
+ "escape-html": "^1.0.3",
3136
+ "parseurl": "^1.3.3",
3137
+ "send": "^1.2.0"
3138
+ },
3139
+ "engines": {
3140
+ "node": ">= 18"
3141
+ }
3142
+ },
3143
+ "node_modules/@modelcontextprotocol/sdk/node_modules/type-is": {
3144
+ "version": "2.0.1",
3145
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz",
3146
+ "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==",
3147
+ "license": "MIT",
3148
+ "dependencies": {
3149
+ "content-type": "^1.0.5",
3150
+ "media-typer": "^1.1.0",
3151
+ "mime-types": "^3.0.0"
3152
+ },
3153
+ "engines": {
3154
+ "node": ">= 0.6"
3155
+ }
3156
+ },
3157
  "node_modules/@mongodb-js/saslprep": {
3158
  "version": "1.1.9",
3159
  "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.9.tgz",
 
6634
  "node": ">=8"
6635
  }
6636
  },
6637
+ "node_modules/call-bind-apply-helpers": {
6638
+ "version": "1.0.2",
6639
+ "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
6640
+ "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
6641
+ "license": "MIT",
6642
  "dependencies": {
 
6643
  "es-errors": "^1.3.0",
6644
+ "function-bind": "^1.1.2"
6645
+ },
6646
+ "engines": {
6647
+ "node": ">= 0.4"
6648
+ }
6649
+ },
6650
+ "node_modules/call-bound": {
6651
+ "version": "1.0.4",
6652
+ "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
6653
+ "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
6654
+ "license": "MIT",
6655
+ "dependencies": {
6656
+ "call-bind-apply-helpers": "^1.0.2",
6657
+ "get-intrinsic": "^1.3.0"
6658
  },
6659
  "engines": {
6660
  "node": ">= 0.4"
 
7247
  "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
7248
  "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
7249
  },
7250
+ "node_modules/cors": {
7251
+ "version": "2.8.5",
7252
+ "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
7253
+ "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
7254
+ "license": "MIT",
7255
+ "dependencies": {
7256
+ "object-assign": "^4",
7257
+ "vary": "^1"
7258
+ },
7259
+ "engines": {
7260
+ "node": ">= 0.10"
7261
+ }
7262
+ },
7263
  "node_modules/create-require": {
7264
  "version": "1.1.1",
7265
  "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
 
7439
  "node": ">=0.10.0"
7440
  }
7441
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7442
  "node_modules/delayed-stream": {
7443
  "version": "1.0.0",
7444
  "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
 
7613
  "url": "https://dotenvx.com"
7614
  }
7615
  },
7616
+ "node_modules/dunder-proto": {
7617
+ "version": "1.0.1",
7618
+ "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
7619
+ "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
7620
+ "license": "MIT",
7621
+ "dependencies": {
7622
+ "call-bind-apply-helpers": "^1.0.1",
7623
+ "es-errors": "^1.3.0",
7624
+ "gopd": "^1.2.0"
7625
+ },
7626
+ "engines": {
7627
+ "node": ">= 0.4"
7628
+ }
7629
+ },
7630
  "node_modules/eastasianwidth": {
7631
  "version": "0.2.0",
7632
  "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
 
7704
  }
7705
  },
7706
  "node_modules/es-define-property": {
7707
+ "version": "1.0.1",
7708
+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
7709
+ "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
7710
+ "license": "MIT",
 
 
7711
  "engines": {
7712
  "node": ">= 0.4"
7713
  }
 
7716
  "version": "1.3.0",
7717
  "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
7718
  "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
7719
+ "license": "MIT",
7720
  "engines": {
7721
  "node": ">= 0.4"
7722
  }
 
7728
  "dev": true,
7729
  "license": "MIT"
7730
  },
7731
+ "node_modules/es-object-atoms": {
7732
+ "version": "1.1.1",
7733
+ "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
7734
+ "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
7735
+ "license": "MIT",
7736
+ "dependencies": {
7737
+ "es-errors": "^1.3.0"
7738
+ },
7739
+ "engines": {
7740
+ "node": ">= 0.4"
7741
+ }
7742
+ },
7743
  "node_modules/esbuild": {
7744
  "version": "0.25.1",
7745
  "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.1.tgz",
 
8203
  "node": ">=12.0.0"
8204
  }
8205
  },
8206
+ "node_modules/eventsource-parser": {
8207
+ "version": "3.0.1",
8208
+ "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.1.tgz",
8209
+ "integrity": "sha512-VARTJ9CYeuQYb0pZEPbzi740OWFgpHe7AYJ2WFZVnUDUQp5Dk2yJUgF36YsZ81cOyxT0QxmXD2EQpapAouzWVA==",
8210
+ "license": "MIT",
8211
+ "engines": {
8212
+ "node": ">=18.0.0"
8213
+ }
8214
+ },
8215
  "node_modules/execa": {
8216
  "version": "8.0.1",
8217
  "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz",
 
8311
  "url": "https://opencollective.com/express"
8312
  }
8313
  },
8314
+ "node_modules/express-rate-limit": {
8315
+ "version": "7.5.0",
8316
+ "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.0.tgz",
8317
+ "integrity": "sha512-eB5zbQh5h+VenMPM3fh+nw1YExi5nMr6HUCR62ELSP11huvxm/Uir1H1QEyTkk5QX6A58pX6NmaTMceKZ0Eodg==",
8318
+ "license": "MIT",
8319
+ "engines": {
8320
+ "node": ">= 16"
8321
+ },
8322
+ "funding": {
8323
+ "url": "https://github.com/sponsors/express-rate-limit"
8324
+ },
8325
+ "peerDependencies": {
8326
+ "express": "^4.11 || 5 || ^5.0.0-beta.1"
8327
+ }
8328
+ },
8329
  "node_modules/express/node_modules/cookie": {
8330
  "version": "0.7.1",
8331
  "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz",
 
8969
  }
8970
  },
8971
  "node_modules/get-intrinsic": {
8972
+ "version": "1.3.0",
8973
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
8974
+ "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
8975
+ "license": "MIT",
8976
  "dependencies": {
8977
+ "call-bind-apply-helpers": "^1.0.2",
8978
+ "es-define-property": "^1.0.1",
8979
  "es-errors": "^1.3.0",
8980
+ "es-object-atoms": "^1.1.1",
8981
  "function-bind": "^1.1.2",
8982
+ "get-proto": "^1.0.1",
8983
+ "gopd": "^1.2.0",
8984
+ "has-symbols": "^1.1.0",
8985
+ "hasown": "^2.0.2",
8986
+ "math-intrinsics": "^1.1.0"
8987
  },
8988
  "engines": {
8989
  "node": ">= 0.4"
 
8992
  "url": "https://github.com/sponsors/ljharb"
8993
  }
8994
  },
8995
+ "node_modules/get-proto": {
8996
+ "version": "1.0.1",
8997
+ "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
8998
+ "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
8999
+ "license": "MIT",
9000
+ "dependencies": {
9001
+ "dunder-proto": "^1.0.1",
9002
+ "es-object-atoms": "^1.0.0"
9003
+ },
9004
+ "engines": {
9005
+ "node": ">= 0.4"
9006
+ }
9007
+ },
9008
  "node_modules/get-stream": {
9009
  "version": "9.0.1",
9010
  "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz",
 
9116
  }
9117
  },
9118
  "node_modules/gopd": {
9119
+ "version": "1.2.0",
9120
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
9121
+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
9122
+ "license": "MIT",
9123
+ "engines": {
9124
+ "node": ">= 0.4"
9125
  },
9126
  "funding": {
9127
  "url": "https://github.com/sponsors/ljharb"
 
9194
  "node": ">=8"
9195
  }
9196
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9197
  "node_modules/has-symbols": {
9198
+ "version": "1.1.0",
9199
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
9200
+ "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
9201
+ "license": "MIT",
9202
  "engines": {
9203
  "node": ">= 0.4"
9204
  },
 
9801
  "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
9802
  "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ=="
9803
  },
9804
+ "node_modules/is-promise": {
9805
+ "version": "4.0.0",
9806
+ "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
9807
+ "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
9808
+ "license": "MIT"
9809
+ },
9810
  "node_modules/is-reference": {
9811
  "version": "1.2.1",
9812
  "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
 
10230
  "underscore": "1.12.1"
10231
  }
10232
  },
10233
+ "node_modules/jsonrepair": {
10234
+ "version": "3.12.0",
10235
+ "resolved": "https://registry.npmjs.org/jsonrepair/-/jsonrepair-3.12.0.tgz",
10236
+ "integrity": "sha512-SWfjz8SuQ0wZjwsxtSJ3Zy8vvLg6aO/kxcp9TWNPGwJKgTZVfhNEQBMk/vPOpYCDFWRxD6QWuI6IHR1t615f0w==",
10237
+ "dev": true,
10238
+ "license": "ISC",
10239
+ "bin": {
10240
+ "jsonrepair": "bin/cli.js"
10241
+ }
10242
+ },
10243
  "node_modules/jwa": {
10244
  "version": "2.0.0",
10245
  "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz",
 
10780
  "node": ">= 18"
10781
  }
10782
  },
10783
+ "node_modules/math-intrinsics": {
10784
+ "version": "1.1.0",
10785
+ "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
10786
+ "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
10787
+ "license": "MIT",
10788
+ "engines": {
10789
+ "node": ">= 0.4"
10790
+ }
10791
+ },
10792
  "node_modules/media-typer": {
10793
  "version": "0.3.0",
10794
  "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
 
11810
  }
11811
  },
11812
  "node_modules/object-inspect": {
11813
+ "version": "1.13.4",
11814
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
11815
+ "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
11816
+ "license": "MIT",
11817
  "engines": {
11818
  "node": ">= 0.4"
11819
  },
 
12483
  "node": ">= 6"
12484
  }
12485
  },
12486
+ "node_modules/pkce-challenge": {
12487
+ "version": "5.0.0",
12488
+ "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.0.tgz",
12489
+ "integrity": "sha512-ueGLflrrnvwB3xuo/uGob5pd5FN7l0MsLf0Z87o/UQmRtwjvfylfc9MurIxRAWywCYTgrvpXBcqjV4OfCYGCIQ==",
12490
+ "license": "MIT",
12491
+ "engines": {
12492
+ "node": ">=16.20.0"
12493
+ }
12494
+ },
12495
  "node_modules/pkg-dir": {
12496
  "version": "4.2.0",
12497
  "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
 
13450
  "fsevents": "~2.3.2"
13451
  }
13452
  },
13453
+ "node_modules/router": {
13454
+ "version": "2.2.0",
13455
+ "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
13456
+ "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==",
13457
+ "license": "MIT",
13458
+ "dependencies": {
13459
+ "debug": "^4.4.0",
13460
+ "depd": "^2.0.0",
13461
+ "is-promise": "^4.0.0",
13462
+ "parseurl": "^1.3.3",
13463
+ "path-to-regexp": "^8.0.0"
13464
+ },
13465
+ "engines": {
13466
+ "node": ">= 18"
13467
+ }
13468
+ },
13469
+ "node_modules/router/node_modules/debug": {
13470
+ "version": "4.4.0",
13471
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
13472
+ "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",
13473
+ "license": "MIT",
13474
+ "dependencies": {
13475
+ "ms": "^2.1.3"
13476
+ },
13477
+ "engines": {
13478
+ "node": ">=6.0"
13479
+ },
13480
+ "peerDependenciesMeta": {
13481
+ "supports-color": {
13482
+ "optional": true
13483
+ }
13484
+ }
13485
+ },
13486
+ "node_modules/router/node_modules/path-to-regexp": {
13487
+ "version": "8.2.0",
13488
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz",
13489
+ "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==",
13490
+ "license": "MIT",
13491
+ "engines": {
13492
+ "node": ">=16"
13493
+ }
13494
+ },
13495
  "node_modules/rrweb-cssom": {
13496
  "version": "0.6.0",
13497
  "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.6.0.tgz",
 
13739
  "integrity": "sha512-lXLOiqpkUumhRdFF3k1osNXCy9akgx/dyPZ5p8qAg9seJzXr5ZrlqZuWIMuY6ejOsVLE6flJ5/h3lsn57fQ/PQ==",
13740
  "dev": true
13741
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13742
  "node_modules/setprototypeof": {
13743
  "version": "1.2.0",
13744
  "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
 
13802
  }
13803
  },
13804
  "node_modules/side-channel": {
13805
+ "version": "1.1.0",
13806
+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
13807
+ "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
13808
+ "license": "MIT",
13809
+ "dependencies": {
13810
+ "es-errors": "^1.3.0",
13811
+ "object-inspect": "^1.13.3",
13812
+ "side-channel-list": "^1.0.0",
13813
+ "side-channel-map": "^1.0.1",
13814
+ "side-channel-weakmap": "^1.0.2"
13815
+ },
13816
+ "engines": {
13817
+ "node": ">= 0.4"
13818
+ },
13819
+ "funding": {
13820
+ "url": "https://github.com/sponsors/ljharb"
13821
+ }
13822
+ },
13823
+ "node_modules/side-channel-list": {
13824
+ "version": "1.0.0",
13825
+ "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
13826
+ "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
13827
+ "license": "MIT",
13828
+ "dependencies": {
13829
+ "es-errors": "^1.3.0",
13830
+ "object-inspect": "^1.13.3"
13831
+ },
13832
+ "engines": {
13833
+ "node": ">= 0.4"
13834
+ },
13835
+ "funding": {
13836
+ "url": "https://github.com/sponsors/ljharb"
13837
+ }
13838
+ },
13839
+ "node_modules/side-channel-map": {
13840
+ "version": "1.0.1",
13841
+ "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
13842
+ "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
13843
+ "license": "MIT",
13844
  "dependencies": {
13845
+ "call-bound": "^1.0.2",
13846
  "es-errors": "^1.3.0",
13847
+ "get-intrinsic": "^1.2.5",
13848
+ "object-inspect": "^1.13.3"
13849
+ },
13850
+ "engines": {
13851
+ "node": ">= 0.4"
13852
+ },
13853
+ "funding": {
13854
+ "url": "https://github.com/sponsors/ljharb"
13855
+ }
13856
+ },
13857
+ "node_modules/side-channel-weakmap": {
13858
+ "version": "1.0.2",
13859
+ "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
13860
+ "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
13861
+ "license": "MIT",
13862
+ "dependencies": {
13863
+ "call-bound": "^1.0.2",
13864
+ "es-errors": "^1.3.0",
13865
+ "get-intrinsic": "^1.2.5",
13866
+ "object-inspect": "^1.13.3",
13867
+ "side-channel-map": "^1.0.1"
13868
  },
13869
  "engines": {
13870
  "node": ">= 0.4"
 
16120
  "license": "MIT"
16121
  },
16122
  "node_modules/zod": {
16123
+ "version": "3.24.3",
16124
+ "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.3.tgz",
16125
+ "integrity": "sha512-HhY1oqzWCQWuUqvBFnsyrtZRhyPeR7SUGv+C4+MsisMuVfSPx8HpwWqH8tRahSlt6M3PiFAcoeFhZAqIXTxoSg==",
16126
+ "license": "MIT",
16127
  "funding": {
16128
  "url": "https://github.com/sponsors/colinhacks"
16129
  }
16130
+ },
16131
+ "node_modules/zod-to-json-schema": {
16132
+ "version": "3.24.5",
16133
+ "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.24.5.tgz",
16134
+ "integrity": "sha512-/AuWwMP+YqiPbsJx5D6TfgRTc4kTLjsh5SOcd4bLsfUg2RcEXrFMJl1DGgdHy2aCfsIA/cr/1JM0xcB2GZji8g==",
16135
+ "license": "ISC",
16136
+ "peerDependencies": {
16137
+ "zod": "^3.24.1"
16138
+ }
16139
  }
16140
  }
16141
  }
package.json CHANGED
@@ -47,6 +47,7 @@
47
  "fs-extra": "^11.3.0",
48
  "isomorphic-dompurify": "^2.13.0",
49
  "js-yaml": "^4.1.0",
 
50
  "minimist": "^1.2.8",
51
  "mongodb-memory-server": "^10.1.2",
52
  "node-llama-cpp": "^3.6.0",
@@ -72,7 +73,9 @@
72
  "@cliqz/adblocker-playwright": "^1.34.0",
73
  "@gradio/client": "^1.8.0",
74
  "@huggingface/hub": "^0.5.1",
75
- "@huggingface/inference": "^2.8.1",
 
 
76
  "@huggingface/transformers": "^3.1.1",
77
  "@iconify-json/bi": "^1.1.21",
78
  "@playwright/browser-chromium": "^1.52.0",
 
47
  "fs-extra": "^11.3.0",
48
  "isomorphic-dompurify": "^2.13.0",
49
  "js-yaml": "^4.1.0",
50
+ "jsonrepair": "^3.12.0",
51
  "minimist": "^1.2.8",
52
  "mongodb-memory-server": "^10.1.2",
53
  "node-llama-cpp": "^3.6.0",
 
73
  "@cliqz/adblocker-playwright": "^1.34.0",
74
  "@gradio/client": "^1.8.0",
75
  "@huggingface/hub": "^0.5.1",
76
+ "@huggingface/inference": "^3.12.1",
77
+ "@huggingface/mcp-client": "^0.1.1",
78
+ "@huggingface/tasks": "^0.19.1",
79
  "@huggingface/transformers": "^3.1.1",
80
  "@iconify-json/bi": "^1.1.21",
81
  "@playwright/browser-chromium": "^1.52.0",
src/lib/components/chat/ChatMessage.svelte CHANGED
@@ -155,7 +155,7 @@
155
  >
156
  {#if message.files?.length}
157
  <div class="flex h-fit flex-wrap gap-x-5 gap-y-2">
158
- {#each message.files as file}
159
  <UploadedFile {file} canClose={false} />
160
  {/each}
161
  </div>
@@ -196,7 +196,9 @@
196
  <div
197
  class="prose max-w-none dark:prose-invert max-sm:prose-sm prose-headings:font-semibold prose-h1:text-lg prose-h2:text-base prose-h3:text-base prose-pre:bg-gray-800 dark:prose-pre:bg-gray-900"
198
  >
199
- <MarkdownRenderer content={message.content} sources={webSearchSources} />
 
 
200
  </div>
201
  </div>
202
 
 
155
  >
156
  {#if message.files?.length}
157
  <div class="flex h-fit flex-wrap gap-x-5 gap-y-2">
158
+ {#each message.files as file (file.value)}
159
  <UploadedFile {file} canClose={false} />
160
  {/each}
161
  </div>
 
196
  <div
197
  class="prose max-w-none dark:prose-invert max-sm:prose-sm prose-headings:font-semibold prose-h1:text-lg prose-h2:text-base prose-h3:text-base prose-pre:bg-gray-800 dark:prose-pre:bg-gray-900"
198
  >
199
+ {#key message.content}
200
+ <MarkdownRenderer content={message.content} sources={webSearchSources} />
201
+ {/key}
202
  </div>
203
  </div>
204
 
src/lib/components/chat/OpenReasoningResults.svelte CHANGED
@@ -67,7 +67,9 @@
67
  <div
68
  class="space-y-4 border-t border-gray-200 px-5 pb-2 pt-2 text-sm text-gray-600 dark:border-gray-800 dark:text-gray-400"
69
  >
70
- <MarkdownRenderer {content} />
 
 
71
  </div>
72
  </details>
73
 
 
67
  <div
68
  class="space-y-4 border-t border-gray-200 px-5 pb-2 pt-2 text-sm text-gray-600 dark:border-gray-800 dark:text-gray-400"
69
  >
70
+ {#key content}
71
+ <MarkdownRenderer {content} />
72
+ {/key}
73
  </div>
74
  </details>
75
 
src/lib/server/endpoints/aws/endpointAws.ts CHANGED
@@ -64,7 +64,6 @@ export async function endpointAws(
64
  inputs: prompt,
65
  },
66
  {
67
- use_cache: false,
68
  fetch: signedFetch,
69
  }
70
  );
 
64
  inputs: prompt,
65
  },
66
  {
 
67
  fetch: signedFetch,
68
  }
69
  );
src/lib/server/endpoints/endpoints.ts CHANGED
@@ -31,6 +31,10 @@ import endpointLangserve, {
31
  import type { Tool, ToolCall, ToolResult } from "$lib/types/Tool";
32
  import type { ObjectId } from "mongodb";
33
  import { endpointLocal, endpointLocalParametersSchema } from "./local/endpointLocal";
 
 
 
 
34
 
35
  export type EndpointMessage = Omit<Message, "id">;
36
 
@@ -77,6 +81,7 @@ export const endpoints = {
77
  cohere: endpointCohere,
78
  langserve: endpointLangserve,
79
  local: endpointLocal,
 
80
  };
81
 
82
  export const endpointSchema = z.discriminatedUnion("type", [
@@ -94,5 +99,6 @@ export const endpointSchema = z.discriminatedUnion("type", [
94
  endpointCohereParametersSchema,
95
  endpointLangserveParametersSchema,
96
  endpointLocalParametersSchema,
 
97
  ]);
98
  export default endpoints;
 
31
  import type { Tool, ToolCall, ToolResult } from "$lib/types/Tool";
32
  import type { ObjectId } from "mongodb";
33
  import { endpointLocal, endpointLocalParametersSchema } from "./local/endpointLocal";
34
+ import {
35
+ endpointInferenceClient,
36
+ endpointInferenceClientParametersSchema,
37
+ } from "./inference-client/endpointInferenceClient";
38
 
39
  export type EndpointMessage = Omit<Message, "id">;
40
 
 
81
  cohere: endpointCohere,
82
  langserve: endpointLangserve,
83
  local: endpointLocal,
84
+ inferenceClient: endpointInferenceClient,
85
  };
86
 
87
  export const endpointSchema = z.discriminatedUnion("type", [
 
99
  endpointCohereParametersSchema,
100
  endpointLangserveParametersSchema,
101
  endpointLocalParametersSchema,
102
+ endpointInferenceClientParametersSchema,
103
  ]);
104
  export default endpoints;
src/lib/server/endpoints/inference-client/endpointInferenceClient.ts ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { z } from "zod";
2
+ import type { Endpoint, TextGenerationStreamOutputWithToolsAndWebSources } from "../endpoints";
3
+ import { createImageProcessorOptionsValidator, makeImageProcessor } from "../images";
4
+ import { INFERENCE_PROVIDERS, InferenceClient } from "@huggingface/inference";
5
+ import { config } from "$lib/server/config";
6
+ import type { Tool, ToolCall } from "$lib/types/Tool";
7
+ import type { ChatCompletionStreamOutput } from "@huggingface/tasks";
8
+ import type { FunctionDefinition } from "openai/resources/index.mjs";
9
+ import type { ChatCompletionTool, FunctionParameters } from "openai/resources/index.mjs";
10
+ import { logger } from "$lib/server/logger";
11
+ import type { MessageFile } from "$lib/types/Message";
12
+ import { v4 as uuidv4 } from "uuid";
13
+ import type { Conversation } from "$lib/types/Conversation";
14
+ import { downloadFile } from "$lib/server/files/downloadFile";
15
+ import { jsonrepair } from "jsonrepair";
16
+ type DeltaToolCall = NonNullable<
17
+ ChatCompletionStreamOutput["choices"][number]["delta"]["tool_calls"]
18
+ >[number];
19
+
20
+ function createChatCompletionToolsArray(tools: Tool[] | undefined): ChatCompletionTool[] {
21
+ const toolChoices = [] as ChatCompletionTool[];
22
+ if (tools === undefined) {
23
+ return toolChoices;
24
+ }
25
+
26
+ for (const t of tools) {
27
+ const requiredProperties = [] as string[];
28
+
29
+ const properties = {} as Record<string, unknown>;
30
+ for (const idx in t.inputs) {
31
+ const parameterDefinition = t.inputs[idx];
32
+
33
+ const parameter = {} as Record<string, unknown>;
34
+ switch (parameterDefinition.type) {
35
+ case "str":
36
+ parameter.type = "string";
37
+ break;
38
+ case "float":
39
+ case "int":
40
+ parameter.type = "number";
41
+ break;
42
+ case "bool":
43
+ parameter.type = "boolean";
44
+ break;
45
+ case "file":
46
+ throw new Error("File type's currently not supported");
47
+ default:
48
+ throw new Error(`Unknown tool IO type: ${t}`);
49
+ }
50
+
51
+ if ("description" in parameterDefinition) {
52
+ parameter.description = parameterDefinition.description;
53
+ }
54
+
55
+ if (parameterDefinition.paramType == "required") {
56
+ requiredProperties.push(t.inputs[idx].name);
57
+ }
58
+
59
+ properties[t.inputs[idx].name] = parameter;
60
+ }
61
+
62
+ const functionParameters: FunctionParameters = {
63
+ type: "object",
64
+ ...(requiredProperties.length > 0 ? { required: requiredProperties } : {}),
65
+ properties,
66
+ };
67
+
68
+ const functionDefinition: FunctionDefinition = {
69
+ name: t.name,
70
+ description: t.description,
71
+ parameters: functionParameters,
72
+ };
73
+
74
+ const toolDefinition: ChatCompletionTool = {
75
+ type: "function",
76
+ function: functionDefinition,
77
+ };
78
+
79
+ toolChoices.push(toolDefinition);
80
+ }
81
+
82
+ return toolChoices;
83
+ }
84
+
85
+ export const endpointInferenceClientParametersSchema = z.object({
86
+ type: z.literal("inference-client"),
87
+ weight: z.number().int().positive().default(1),
88
+ model: z.any(),
89
+ provider: z.enum(INFERENCE_PROVIDERS).optional(),
90
+ supportedRoles: z
91
+ .array(z.enum(["user", "assistant", "system", "tool"]))
92
+ .default(["user", "assistant", "system", "tool"]),
93
+ modelName: z.string().optional(),
94
+ baseURL: z.string().optional(),
95
+ multimodal: z
96
+ .object({
97
+ image: createImageProcessorOptionsValidator({
98
+ supportedMimeTypes: [
99
+ "image/png",
100
+ "image/jpeg",
101
+ "image/webp",
102
+ "image/avif",
103
+ "image/tiff",
104
+ "image/gif",
105
+ ],
106
+ preferredMimeType: "image/webp",
107
+ maxSizeInMB: Infinity,
108
+ maxWidth: 4096,
109
+ maxHeight: 4096,
110
+ }),
111
+ })
112
+ .default({}),
113
+ });
114
+
115
+ export async function endpointInferenceClient(
116
+ input: z.input<typeof endpointInferenceClientParametersSchema>
117
+ ): Promise<Endpoint> {
118
+ const { model, provider, modelName, baseURL, multimodal } =
119
+ endpointInferenceClientParametersSchema.parse(input);
120
+
121
+ if (!!provider && !!baseURL) {
122
+ throw new Error("provider and baseURL cannot both be provided");
123
+ }
124
+ const client = baseURL
125
+ ? new InferenceClient(config.HF_TOKEN, { endpointUrl: baseURL })
126
+ : new InferenceClient(config.HF_TOKEN);
127
+
128
+ const imageProcessor = multimodal.image ? makeImageProcessor(multimodal.image) : undefined;
129
+
130
+ async function prepareFiles(files: MessageFile[], conversationId?: Conversation["_id"]) {
131
+ if (!imageProcessor) {
132
+ return [];
133
+ }
134
+ const processedFiles = await Promise.all(
135
+ files
136
+ .filter((file) => file.mime.startsWith("image/"))
137
+ .map(async (file) => {
138
+ if (file.type === "hash" && conversationId) {
139
+ file = await downloadFile(file.value, conversationId);
140
+ }
141
+ return imageProcessor(file);
142
+ })
143
+ );
144
+ return processedFiles.map((file) => ({
145
+ type: "image_url" as const,
146
+ image_url: {
147
+ url: `data:${file.mime};base64,${file.image.toString("base64")}`,
148
+ },
149
+ }));
150
+ }
151
+
152
+ return async ({ messages, generateSettings, tools, toolResults, preprompt, conversationId }) => {
153
+ /* eslint-disable @typescript-eslint/no-explicit-any */
154
+ let messagesArray = (await Promise.all(
155
+ messages.map(async (message) => {
156
+ return {
157
+ role: message.from,
158
+ content: [
159
+ ...(await prepareFiles(message.files ?? [], conversationId)),
160
+ { type: "text" as const, text: message.content },
161
+ ],
162
+ };
163
+ })
164
+ )) as any[];
165
+
166
+ if (
167
+ !model.systemRoleSupported &&
168
+ messagesArray.length > 0 &&
169
+ messagesArray[0]?.role === "system"
170
+ ) {
171
+ messagesArray[0].role = "user";
172
+ } else if (messagesArray[0].role !== "system") {
173
+ messagesArray.unshift({
174
+ role: "system",
175
+ content: preprompt ?? "",
176
+ });
177
+ }
178
+
179
+ if (toolResults && toolResults.length > 0) {
180
+ messagesArray = [
181
+ ...messagesArray,
182
+ {
183
+ role: "assistant",
184
+ content: [
185
+ {
186
+ type: "text" as const,
187
+ text: "",
188
+ },
189
+ ],
190
+ tool_calls: toolResults.map((toolResult) => ({
191
+ type: "function",
192
+ function: {
193
+ name: toolResult.call.name,
194
+ arguments: JSON.stringify(toolResult.call.parameters),
195
+ },
196
+ id: toolResult?.call?.toolId || uuidv4(),
197
+ })),
198
+ },
199
+ ...toolResults.map((toolResult) => ({
200
+ role: model.systemRoleSupported ? "tool" : "user",
201
+ content: [
202
+ {
203
+ type: "text" as const,
204
+ text: JSON.stringify(toolResult),
205
+ },
206
+ ],
207
+ tool_call_id: toolResult?.call?.toolId || uuidv4(),
208
+ })),
209
+ ];
210
+ }
211
+
212
+ messagesArray = messagesArray.reduce((acc: typeof messagesArray, current) => {
213
+ if (acc.length === 0 || current.role !== acc[acc.length - 1].role) {
214
+ acc.push(current);
215
+ } else {
216
+ const prevMessage = acc[acc.length - 1];
217
+
218
+ prevMessage.content = [
219
+ ...prevMessage.content.filter((item: any) => item.type !== "text"),
220
+ ...current.content.filter((item: any) => item.type !== "text"),
221
+ {
222
+ type: "text" as const,
223
+ text: [
224
+ ...prevMessage.content.filter((item: any) => item.type === "text"),
225
+ ...current.content.filter((item: any) => item.type === "text"),
226
+ ]
227
+ .map((item: any) => item.text)
228
+ .join("\n")
229
+ .replace(/^\n/, ""),
230
+ },
231
+ ];
232
+
233
+ prevMessage.files = [...(prevMessage?.files ?? []), ...(current?.files ?? [])];
234
+
235
+ prevMessage.tool_calls = [
236
+ ...(prevMessage?.tool_calls ?? []),
237
+ ...(current?.tool_calls ?? []),
238
+ ];
239
+ }
240
+ return acc;
241
+ }, []);
242
+ const toolCallChoices = createChatCompletionToolsArray(tools);
243
+ const stream = client.chatCompletionStream(
244
+ {
245
+ ...model.parameters,
246
+ ...generateSettings,
247
+ model: modelName ?? model.id ?? model.name,
248
+ provider: baseURL ? undefined : provider || ("hf-inference" as const),
249
+ messages: messagesArray,
250
+ ...(toolCallChoices.length > 0 ? { tools: toolCallChoices, tool_choice: "auto" } : {}),
251
+ toolResults,
252
+ },
253
+ {
254
+ fetch: async (url, options) => {
255
+ return fetch(url, {
256
+ ...options,
257
+ headers: {
258
+ ...options?.headers,
259
+ "X-Use-Cache": "false",
260
+ "ChatUI-Conversation-ID": conversationId?.toString() ?? "",
261
+ },
262
+ });
263
+ },
264
+ }
265
+ );
266
+
267
+ let tokenId = 0;
268
+ let generated_text = "";
269
+ const finalToolCalls: DeltaToolCall[] = [];
270
+
271
+ async function* convertStream(): AsyncGenerator<
272
+ TextGenerationStreamOutputWithToolsAndWebSources,
273
+ void,
274
+ void
275
+ > {
276
+ for await (const chunk of stream) {
277
+ const token = chunk.choices?.[0]?.delta?.content || "";
278
+
279
+ generated_text += token;
280
+
281
+ const toolCalls = chunk.choices?.[0]?.delta?.tool_calls ?? [];
282
+
283
+ for (const toolCall of toolCalls) {
284
+ const index = toolCall.index ?? 0;
285
+
286
+ if (!finalToolCalls[index]) {
287
+ finalToolCalls[index] = toolCall;
288
+ } else {
289
+ if (finalToolCalls[index].function.arguments === undefined) {
290
+ finalToolCalls[index].function.arguments = "";
291
+ }
292
+ if (toolCall.function.arguments) {
293
+ finalToolCalls[index].function.arguments += toolCall.function.arguments;
294
+ }
295
+ }
296
+ }
297
+
298
+ yield {
299
+ token: {
300
+ id: tokenId++,
301
+ text: token,
302
+ logprob: 0,
303
+ special: false,
304
+ },
305
+ details: null,
306
+ generated_text: null,
307
+ };
308
+ }
309
+
310
+ let mappedToolCalls: ToolCall[] | undefined;
311
+ try {
312
+ if (finalToolCalls.length === 0) {
313
+ mappedToolCalls = undefined;
314
+ } else {
315
+ // Ensure finalToolCalls is an array
316
+ const toolCallsArray = Array.isArray(finalToolCalls) ? finalToolCalls : [finalToolCalls];
317
+
318
+ mappedToolCalls = toolCallsArray.map((tc) => ({
319
+ id: tc.id,
320
+ name: tc.function.name ?? "",
321
+ parameters: JSON.parse(jsonrepair(tc.function.arguments || "{}")),
322
+ }));
323
+ }
324
+ } catch (e) {
325
+ logger.error(e, "error mapping tool calls");
326
+ }
327
+
328
+ yield {
329
+ token: {
330
+ id: tokenId++,
331
+ text: "",
332
+ logprob: 0,
333
+ special: true,
334
+ toolCalls: mappedToolCalls,
335
+ },
336
+ generated_text,
337
+ details: null,
338
+ };
339
+ }
340
+
341
+ return convertStream();
342
+ };
343
+ }
src/lib/server/endpoints/tgi/endpointTgi.ts CHANGED
@@ -66,7 +66,6 @@ export function endpointTgi(input: z.input<typeof endpointTgiParametersSchema>):
66
  accessToken,
67
  },
68
  {
69
- use_cache: false,
70
  fetch: async (endpointUrl, info) => {
71
  if (info && authorization && !accessToken) {
72
  // Set authorization header if it is defined and HF_TOKEN is empty
@@ -74,6 +73,7 @@ export function endpointTgi(input: z.input<typeof endpointTgiParametersSchema>):
74
  ...info.headers,
75
  Authorization: authorization,
76
  "ChatUI-Conversation-ID": conversationId?.toString() ?? "",
 
77
  };
78
  }
79
  return fetch(endpointUrl, info);
 
66
  accessToken,
67
  },
68
  {
 
69
  fetch: async (endpointUrl, info) => {
70
  if (info && authorization && !accessToken) {
71
  // Set authorization header if it is defined and HF_TOKEN is empty
 
73
  ...info.headers,
74
  Authorization: authorization,
75
  "ChatUI-Conversation-ID": conversationId?.toString() ?? "",
76
+ "X-Use-Cache": "false",
77
  };
78
  }
79
  return fetch(endpointUrl, info);
src/lib/server/models.ts CHANGED
@@ -12,7 +12,7 @@ import type { PreTrainedTokenizer } from "@huggingface/transformers";
12
  import JSON5 from "json5";
13
  import { getTokenizer } from "$lib/utils/getTokenizer";
14
  import { logger } from "$lib/server/logger";
15
- import { ToolResultStatus, type ToolInput } from "$lib/types/Tool";
16
  import { join, dirname } from "path";
17
  import { resolveModelFile, readGgufFileInfo } from "node-llama-cpp";
18
  import { fileURLToPath } from "url";
@@ -195,13 +195,7 @@ async function getChatPromptRender(
195
  process.exit();
196
  }
197
 
198
- const renderTemplate = ({
199
- messages,
200
- preprompt,
201
- tools,
202
- toolResults,
203
- continueMessage,
204
- }: ChatTemplateInput) => {
205
  let formattedMessages: {
206
  role: string;
207
  content: string;
@@ -235,74 +229,6 @@ async function getChatPromptRender(
235
  ];
236
  }
237
 
238
- if (toolResults?.length) {
239
- // todo: should update the command r+ tokenizer to support system messages at any location
240
- // or use the `rag` mode without the citations
241
- const id = m.id ?? m.name;
242
-
243
- if (config.isHuggingChat && id.startsWith("CohereForAI")) {
244
- formattedMessages = [
245
- {
246
- role: "user",
247
- content:
248
- "\n\n<results>\n" +
249
- toolResults
250
- .flatMap((result, idx) => {
251
- if (result.status === ToolResultStatus.Error) {
252
- return (
253
- `Document: ${idx}\n` + `Tool "${result.call.name}" error\n` + result.message
254
- );
255
- }
256
- return (
257
- `Document: ${idx}\n` +
258
- result.outputs
259
- .flatMap((output) =>
260
- Object.entries(output).map(([title, text]) => `${title}\n${text}`)
261
- )
262
- .join("\n")
263
- );
264
- })
265
- .join("\n\n") +
266
- "\n</results>",
267
- },
268
- ...formattedMessages,
269
- ];
270
- } else if (config.isHuggingChat && id.startsWith("meta-llama")) {
271
- const results = toolResults.flatMap((result) => {
272
- if (result.status === ToolResultStatus.Error) {
273
- return [
274
- {
275
- tool_call_id: result.call.name,
276
- output: "Error: " + result.message,
277
- },
278
- ];
279
- } else {
280
- return result.outputs.map((output) => ({
281
- tool_call_id: result.call.name,
282
- output: JSON.stringify(output),
283
- }));
284
- }
285
- });
286
-
287
- formattedMessages = [
288
- ...formattedMessages,
289
- {
290
- role: "python",
291
- content: JSON.stringify(results),
292
- },
293
- ];
294
- } else {
295
- formattedMessages = [
296
- ...formattedMessages,
297
- {
298
- role: m.systemRoleSupported ? "system" : "user",
299
- content: JSON.stringify(toolResults),
300
- },
301
- ];
302
- }
303
- tools = [];
304
- }
305
-
306
  const mappedTools =
307
  tools?.map((tool) => {
308
  const inputs: Record<
@@ -380,6 +306,8 @@ const addEndpoint = (m: Awaited<ReturnType<typeof processModel>>) => ({
380
  return endpoints.tgi(args);
381
  case "local":
382
  return endpoints.local(args);
 
 
383
  case "anthropic":
384
  return endpoints.anthropic(args);
385
  case "anthropic-vertex":
 
12
  import JSON5 from "json5";
13
  import { getTokenizer } from "$lib/utils/getTokenizer";
14
  import { logger } from "$lib/server/logger";
15
+ import { type ToolInput } from "$lib/types/Tool";
16
  import { join, dirname } from "path";
17
  import { resolveModelFile, readGgufFileInfo } from "node-llama-cpp";
18
  import { fileURLToPath } from "url";
 
195
  process.exit();
196
  }
197
 
198
+ const renderTemplate = ({ messages, preprompt, tools, continueMessage }: ChatTemplateInput) => {
 
 
 
 
 
 
199
  let formattedMessages: {
200
  role: string;
201
  content: string;
 
229
  ];
230
  }
231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  const mappedTools =
233
  tools?.map((tool) => {
234
  const inputs: Record<
 
306
  return endpoints.tgi(args);
307
  case "local":
308
  return endpoints.local(args);
309
+ case "inference-client":
310
+ return endpoints.inferenceClient(args);
311
  case "anthropic":
312
  return endpoints.anthropic(args);
313
  case "anthropic-vertex":
src/lib/server/textGeneration/tools.ts CHANGED
@@ -181,11 +181,9 @@ export async function* runTools(
181
 
182
  // put fileMsg before last if files.length > 0
183
  formattedMessages = files.length
184
- ? [...formattedMessages.slice(0, -1), fileMsg, ...formattedMessages.slice(-1)]
185
  : messages;
186
 
187
- let rawText = "";
188
-
189
  const mappedTools = tools.map((tool) => ({
190
  ...tool,
191
  inputs: tool.inputs.map((input) => ({
@@ -208,24 +206,6 @@ export async function* runTools(
208
  continue;
209
  }
210
 
211
- if (output.token.text) {
212
- rawText += output.token.text;
213
- }
214
-
215
- // if we dont see a tool call in the first 25 chars, something is going wrong and we abort
216
- if (rawText.length > 100 && !(rawText.includes("```json") || rawText.includes("{"))) {
217
- return [];
218
- }
219
-
220
- // if we see a directly_answer tool call, we skip the rest
221
- if (
222
- rawText.includes("directly_answer") ||
223
- rawText.includes("directlyAnswer") ||
224
- rawText.includes("directly-answer")
225
- ) {
226
- return [];
227
- }
228
-
229
  // look for a code blocks of ```json and parse them
230
  // if they're valid json, add them to the calls array
231
  if (output.generated_text) {
 
181
 
182
  // put fileMsg before last if files.length > 0
183
  formattedMessages = files.length
184
+ ? [...formattedMessages.slice(0, 1), fileMsg, ...formattedMessages.slice(1)]
185
  : messages;
186
 
 
 
187
  const mappedTools = tools.map((tool) => ({
188
  ...tool,
189
  inputs: tool.inputs.map((input) => ({
 
206
  continue;
207
  }
208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  // look for a code blocks of ```json and parse them
210
  // if they're valid json, add them to the calls array
211
  if (output.generated_text) {
src/lib/server/tools/web/search.ts CHANGED
@@ -5,7 +5,7 @@ import { runWebSearch } from "../../websearch/runWebSearch";
5
  const websearch: ConfigTool = {
6
  _id: new ObjectId("00000000000000000000000A"),
7
  type: "config",
8
- description: "Search the web for answers to the user's query",
9
  color: "blue",
10
  icon: "wikis",
11
  displayName: "Web Search",
@@ -16,7 +16,7 @@ const websearch: ConfigTool = {
16
  name: "query",
17
  type: "str",
18
  description:
19
- "A search query which will be used to fetch the most relevant snippets regarding the user's query",
20
  paramType: "required",
21
  },
22
  ],
@@ -35,7 +35,12 @@ const websearch: ConfigTool = {
35
  {
36
  websearch:
37
  webSearchContext +
38
- "\n\nWhen answering the question, you must reference the sources you used inline by wrapping the index in brackets like this: [1]. If multiple sources are used, you must reference each one of them without commas like this: [1][2][3].",
 
 
 
 
 
39
  },
40
  ],
41
  display: false,
 
5
  const websearch: ConfigTool = {
6
  _id: new ObjectId("00000000000000000000000A"),
7
  type: "config",
8
+ description: "Search the web for up-to-date answers to the user's query.",
9
  color: "blue",
10
  icon: "wikis",
11
  displayName: "Web Search",
 
16
  name: "query",
17
  type: "str",
18
  description:
19
+ "A search query which will be used to fetch the most relevant snippets regarding the user's query.",
20
  paramType: "required",
21
  },
22
  ],
 
35
  {
36
  websearch:
37
  webSearchContext +
38
+ "\n\nWhen answering the question, you must reference the sources you used inline by wrapping the index in brackets like this: [1]. If multiple sources are used, you must reference each one of them without commas like this: [1][2][3]. This information was fetched live from the web, today on " +
39
+ new Date().toLocaleDateString("en-US", {
40
+ year: "numeric",
41
+ month: "long",
42
+ day: "numeric",
43
+ }),
44
  },
45
  ],
46
  display: false,
src/routes/models/+page.svelte CHANGED
@@ -70,55 +70,62 @@
70
  aria-hidden="true"
71
  ></div>
72
  {/if}
73
- {#if model.tools}
74
- <span
75
- title="This model supports tools."
76
- class="ml-auto grid size-[21px] place-items-center rounded-lg border border-purple-300 dark:border-purple-700"
77
- aria-label="Model supports tools"
78
- role="img"
79
- >
80
- <CarbonTools class="text-xxs text-purple-700 dark:text-purple-500" />
81
- </span>
82
- {/if}
83
- {#if model.multimodal}
84
- <span
85
- title="This model is multimodal and supports image inputs natively."
86
- class="ml-auto flex size-[21px] items-center justify-center rounded-lg border border-blue-700 dark:border-blue-500"
87
- aria-label="Model is multimodal"
88
- role="img"
89
- >
90
- <CarbonImage class="text-xxs text-blue-700 dark:text-blue-500" />
91
- </span>
92
- {/if}
93
- {#if model.reasoning}
94
- <span
95
- title="This model supports reasoning."
96
- class="ml-auto grid size-[21px] place-items-center rounded-lg border border-purple-300 dark:border-purple-700"
97
- aria-label="Model supports reasoning"
98
- role="img"
99
- >
100
- <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 32 32">
101
- <path
102
- class="stroke-purple-700"
103
- style="stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 50;"
104
- d="M16 6v3.33M16 6c0-2.65 3.25-4.3 5.4-2.62 1.2.95 1.6 2.65.95 4.04a3.63 3.63 0 0 1 4.61.16 3.45 3.45 0 0 1 .46 4.37 5.32 5.32 0 0 1 1.87 4.75c-.22 1.66-1.39 3.6-3.07 4.14M16 6c0-2.65-3.25-4.3-5.4-2.62a3.37 3.37 0 0 0-.95 4.04 3.65 3.65 0 0 0-4.6.16 3.37 3.37 0 0 0-.49 4.27 5.57 5.57 0 0 0-1.85 4.85 5.3 5.3 0 0 0 3.07 4.15M16 9.33v17.34m0-17.34c0 2.18 1.82 4 4 4m6.22 7.5c.67 1.3.56 2.91-.27 4.11a4.05 4.05 0 0 1-4.62 1.5c0 1.53-1.05 2.9-2.66 2.9A2.7 2.7 0 0 1 16 26.66m10.22-5.83a4.05 4.05 0 0 0-3.55-2.17m-16.9 2.18a4.05 4.05 0 0 0 .28 4.1c1 1.44 2.92 2.09 4.59 1.5 0 1.52 1.12 2.88 2.7 2.88A2.7 2.7 0 0 0 16 26.67M5.78 20.85a4.04 4.04 0 0 1 3.55-2.18"
105
- />
106
- </svg>
107
- </span>
108
- {/if}
109
- {#if model.id === $settings.activeModel}
110
- <span
111
- class="rounded-full border border-blue-500 bg-blue-500/5 px-2 py-0.5 text-xs text-blue-500 dark:border-blue-500 dark:bg-blue-500/10"
112
- >
113
- Active
114
- </span>
115
- {:else if index === 0}
116
- <span
117
- class="rounded-full border border-gray-300 px-2 py-0.5 text-xs text-gray-500 dark:border-gray-500 dark:text-gray-400"
118
- >
119
- Default
120
- </span>
121
- {/if}
 
 
 
 
 
 
 
122
  </div>
123
  <span class="flex items-center gap-2 font-semibold">
124
  {model.displayName}
 
70
  aria-hidden="true"
71
  ></div>
72
  {/if}
73
+ <div class="flex items-center gap-1">
74
+ {#if model.tools}
75
+ <span
76
+ title="This model supports tools."
77
+ class="ml-auto grid size-[21px] place-items-center rounded-lg border border-purple-300 dark:border-purple-700"
78
+ aria-label="Model supports tools"
79
+ role="img"
80
+ >
81
+ <CarbonTools class="text-xxs text-purple-700 dark:text-purple-500" />
82
+ </span>
83
+ {/if}
84
+ {#if model.multimodal}
85
+ <span
86
+ title="This model is multimodal and supports image inputs natively."
87
+ class="ml-auto flex size-[21px] items-center justify-center rounded-lg border border-blue-700 dark:border-blue-500"
88
+ aria-label="Model is multimodal"
89
+ role="img"
90
+ >
91
+ <CarbonImage class="text-xxs text-blue-700 dark:text-blue-500" />
92
+ </span>
93
+ {/if}
94
+ {#if model.reasoning}
95
+ <span
96
+ title="This model supports reasoning."
97
+ class="ml-auto grid size-[21px] place-items-center rounded-lg border border-purple-300 dark:border-purple-700"
98
+ aria-label="Model supports reasoning"
99
+ role="img"
100
+ >
101
+ <svg
102
+ xmlns="http://www.w3.org/2000/svg"
103
+ width="14"
104
+ height="14"
105
+ viewBox="0 0 32 32"
106
+ >
107
+ <path
108
+ class="stroke-purple-700"
109
+ style="stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 50;"
110
+ d="M16 6v3.33M16 6c0-2.65 3.25-4.3 5.4-2.62 1.2.95 1.6 2.65.95 4.04a3.63 3.63 0 0 1 4.61.16 3.45 3.45 0 0 1 .46 4.37 5.32 5.32 0 0 1 1.87 4.75c-.22 1.66-1.39 3.6-3.07 4.14M16 6c0-2.65-3.25-4.3-5.4-2.62a3.37 3.37 0 0 0-.95 4.04 3.65 3.65 0 0 0-4.6.16 3.37 3.37 0 0 0-.49 4.27 5.57 5.57 0 0 0-1.85 4.85 5.3 5.3 0 0 0 3.07 4.15M16 9.33v17.34m0-17.34c0 2.18 1.82 4 4 4m6.22 7.5c.67 1.3.56 2.91-.27 4.11a4.05 4.05 0 0 1-4.62 1.5c0 1.53-1.05 2.9-2.66 2.9A2.7 2.7 0 0 1 16 26.66m10.22-5.83a4.05 4.05 0 0 0-3.55-2.17m-16.9 2.18a4.05 4.05 0 0 0 .28 4.1c1 1.44 2.92 2.09 4.59 1.5 0 1.52 1.12 2.88 2.7 2.88A2.7 2.7 0 0 0 16 26.67M5.78 20.85a4.04 4.04 0 0 1 3.55-2.18"
111
+ />
112
+ </svg>
113
+ </span>
114
+ {/if}
115
+ {#if model.id === $settings.activeModel}
116
+ <span
117
+ class="rounded-full border border-blue-500 bg-blue-500/5 px-2 py-0.5 text-xs text-blue-500 dark:border-blue-500 dark:bg-blue-500/10"
118
+ >
119
+ Active
120
+ </span>
121
+ {:else if index === 0}
122
+ <span
123
+ class="rounded-full border border-gray-300 px-2 py-0.5 text-xs text-gray-500 dark:border-gray-500 dark:text-gray-400"
124
+ >
125
+ Default
126
+ </span>
127
+ {/if}
128
+ </div>
129
  </div>
130
  <span class="flex items-center gap-2 font-semibold">
131
  {model.displayName}