@huggingface/tasks 0.10.19 → 0.10.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +115 -38
- package/dist/index.js +115 -38
- package/dist/src/local-apps.d.ts +4 -4
- package/dist/src/local-apps.d.ts.map +1 -1
- package/dist/src/model-libraries.d.ts +9 -2
- package/dist/src/model-libraries.d.ts.map +1 -1
- package/dist/src/snippets/curl.d.ts +1 -0
- package/dist/src/snippets/curl.d.ts.map +1 -1
- package/dist/src/snippets/js.d.ts +1 -0
- package/dist/src/snippets/js.d.ts.map +1 -1
- package/dist/src/snippets/python.d.ts +2 -1
- package/dist/src/snippets/python.d.ts.map +1 -1
- package/dist/src/snippets/types.d.ts +1 -1
- package/dist/src/snippets/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/local-apps.ts +7 -6
- package/src/model-libraries.ts +7 -0
- package/src/snippets/curl.ts +19 -1
- package/src/snippets/inputs.ts +25 -25
- package/src/snippets/js.ts +40 -6
- package/src/snippets/python.ts +27 -4
- package/src/snippets/types.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4918,6 +4918,13 @@ var MODEL_LIBRARIES_UI_ELEMENTS = {
|
|
|
4918
4918
|
filter: false,
|
|
4919
4919
|
countDownloads: `path:"gliner_config.json"`
|
|
4920
4920
|
},
|
|
4921
|
+
"glyph-byt5": {
|
|
4922
|
+
prettyLabel: "Glyph-ByT5",
|
|
4923
|
+
repoName: "Glyph-ByT5",
|
|
4924
|
+
repoUrl: "https://github.com/AIGText/Glyph-ByT5",
|
|
4925
|
+
filter: false,
|
|
4926
|
+
countDownloads: `path:"checkpoints/byt5_model.pt"`
|
|
4927
|
+
},
|
|
4921
4928
|
grok: {
|
|
4922
4929
|
prettyLabel: "Grok",
|
|
4923
4930
|
repoName: "Grok",
|
|
@@ -5239,39 +5246,39 @@ var inputsZeroShotClassification = () => `"Hi, I recently bought a device from y
|
|
|
5239
5246
|
var inputsTranslation = () => `"\u041C\u0435\u043D\u044F \u0437\u043E\u0432\u0443\u0442 \u0412\u043E\u043B\u044C\u0444\u0433\u0430\u043D\u0433 \u0438 \u044F \u0436\u0438\u0432\u0443 \u0432 \u0411\u0435\u0440\u043B\u0438\u043D\u0435"`;
|
|
5240
5247
|
var inputsSummarization = () => `"The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct."`;
|
|
5241
5248
|
var inputsTableQuestionAnswering = () => `{
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5249
|
+
"query": "How many stars does the transformers repository have?",
|
|
5250
|
+
"table": {
|
|
5251
|
+
"Repository": ["Transformers", "Datasets", "Tokenizers"],
|
|
5252
|
+
"Stars": ["36542", "4512", "3934"],
|
|
5253
|
+
"Contributors": ["651", "77", "34"],
|
|
5254
|
+
"Programming language": [
|
|
5255
|
+
"Python",
|
|
5256
|
+
"Python",
|
|
5257
|
+
"Rust, Python and NodeJS"
|
|
5258
|
+
]
|
|
5259
|
+
}
|
|
5260
|
+
}`;
|
|
5254
5261
|
var inputsVisualQuestionAnswering = () => `{
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5262
|
+
"image": "cat.png",
|
|
5263
|
+
"question": "What is in this image?"
|
|
5264
|
+
}`;
|
|
5258
5265
|
var inputsQuestionAnswering = () => `{
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5266
|
+
"question": "What is my name?",
|
|
5267
|
+
"context": "My name is Clara and I live in Berkeley."
|
|
5268
|
+
}`;
|
|
5262
5269
|
var inputsTextClassification = () => `"I like you. I love you"`;
|
|
5263
5270
|
var inputsTokenClassification = () => `"My name is Sarah Jessica Parker but you can call me Jessica"`;
|
|
5264
5271
|
var inputsTextGeneration = () => `"Can you please let us know more details about your "`;
|
|
5265
5272
|
var inputsText2TextGeneration = () => `"The answer to the universe is"`;
|
|
5266
5273
|
var inputsFillMask = (model) => `"The answer to the universe is ${model.mask_token}."`;
|
|
5267
5274
|
var inputsSentenceSimilarity = () => `{
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
+
"source_sentence": "That is a happy person",
|
|
5276
|
+
"sentences": [
|
|
5277
|
+
"That is a happy dog",
|
|
5278
|
+
"That is a very happy person",
|
|
5279
|
+
"Today is a sunny day"
|
|
5280
|
+
]
|
|
5281
|
+
}`;
|
|
5275
5282
|
var inputsFeatureExtraction = () => `"Today is a sunny day and I will get some ice cream."`;
|
|
5276
5283
|
var inputsImageClassification = () => `"cats.jpg"`;
|
|
5277
5284
|
var inputsImageToText = () => `"cats.jpg"`;
|
|
@@ -5340,6 +5347,7 @@ __export(curl_exports, {
|
|
|
5340
5347
|
hasCurlInferenceSnippet: () => hasCurlInferenceSnippet,
|
|
5341
5348
|
snippetBasic: () => snippetBasic,
|
|
5342
5349
|
snippetFile: () => snippetFile,
|
|
5350
|
+
snippetTextGeneration: () => snippetTextGeneration,
|
|
5343
5351
|
snippetZeroShotClassification: () => snippetZeroShotClassification
|
|
5344
5352
|
});
|
|
5345
5353
|
var snippetBasic = (model, accessToken) => `curl https://api-inference.huggingface.co/models/${model.id} \\
|
|
@@ -5348,6 +5356,22 @@ var snippetBasic = (model, accessToken) => `curl https://api-inference.huggingfa
|
|
|
5348
5356
|
-H 'Content-Type: application/json' \\
|
|
5349
5357
|
-H "Authorization: Bearer ${accessToken || `{API_TOKEN}`}"
|
|
5350
5358
|
`;
|
|
5359
|
+
var snippetTextGeneration = (model, accessToken) => {
|
|
5360
|
+
if (model.config?.tokenizer_config?.chat_template) {
|
|
5361
|
+
return `curl 'https://api-inference.huggingface.co/models/${model.id}/v1/chat/completions' \\
|
|
5362
|
+
-H "Authorization: Bearer ${accessToken || `{API_TOKEN}`}" \\
|
|
5363
|
+
-H 'Content-Type: application/json' \\
|
|
5364
|
+
-d '{
|
|
5365
|
+
"model": "${model.id}",
|
|
5366
|
+
"messages": [{"role": "user", "content": "What is the capital of France?"}],
|
|
5367
|
+
"max_tokens": 500,
|
|
5368
|
+
"stream": false
|
|
5369
|
+
}'
|
|
5370
|
+
`;
|
|
5371
|
+
} else {
|
|
5372
|
+
return snippetBasic(model, accessToken);
|
|
5373
|
+
}
|
|
5374
|
+
};
|
|
5351
5375
|
var snippetZeroShotClassification = (model, accessToken) => `curl https://api-inference.huggingface.co/models/${model.id} \\
|
|
5352
5376
|
-X POST \\
|
|
5353
5377
|
-d '{"inputs": ${getModelInputSnippet(model, true)}, "parameters": {"candidate_labels": ["refund", "legal", "faq"]}}' \\
|
|
@@ -5369,7 +5393,7 @@ var curlSnippets = {
|
|
|
5369
5393
|
translation: snippetBasic,
|
|
5370
5394
|
summarization: snippetBasic,
|
|
5371
5395
|
"feature-extraction": snippetBasic,
|
|
5372
|
-
"text-generation":
|
|
5396
|
+
"text-generation": snippetTextGeneration,
|
|
5373
5397
|
"text2text-generation": snippetBasic,
|
|
5374
5398
|
"fill-mask": snippetBasic,
|
|
5375
5399
|
"sentence-similarity": snippetBasic,
|
|
@@ -5398,6 +5422,7 @@ __export(python_exports, {
|
|
|
5398
5422
|
hasPythonInferenceSnippet: () => hasPythonInferenceSnippet,
|
|
5399
5423
|
pythonSnippets: () => pythonSnippets,
|
|
5400
5424
|
snippetBasic: () => snippetBasic2,
|
|
5425
|
+
snippetConversational: () => snippetConversational,
|
|
5401
5426
|
snippetDocumentQuestionAnswering: () => snippetDocumentQuestionAnswering,
|
|
5402
5427
|
snippetFile: () => snippetFile2,
|
|
5403
5428
|
snippetTabular: () => snippetTabular,
|
|
@@ -5406,6 +5431,20 @@ __export(python_exports, {
|
|
|
5406
5431
|
snippetZeroShotClassification: () => snippetZeroShotClassification2,
|
|
5407
5432
|
snippetZeroShotImageClassification: () => snippetZeroShotImageClassification
|
|
5408
5433
|
});
|
|
5434
|
+
var snippetConversational = (model, accessToken) => `from huggingface_hub import InferenceClient
|
|
5435
|
+
|
|
5436
|
+
client = InferenceClient(
|
|
5437
|
+
"${model.id}",
|
|
5438
|
+
token="${accessToken || "{API_TOKEN}"}",
|
|
5439
|
+
)
|
|
5440
|
+
|
|
5441
|
+
for message in client.chat_completion(
|
|
5442
|
+
messages=[{"role": "user", "content": "What is the capital of France?"}],
|
|
5443
|
+
max_tokens=500,
|
|
5444
|
+
stream=True,
|
|
5445
|
+
):
|
|
5446
|
+
print(message.choices[0].delta.content, end="")
|
|
5447
|
+
`;
|
|
5409
5448
|
var snippetZeroShotClassification2 = (model) => `def query(payload):
|
|
5410
5449
|
response = requests.post(API_URL, headers=headers, json=payload)
|
|
5411
5450
|
return response.json()
|
|
@@ -5523,13 +5562,17 @@ var pythonSnippets = {
|
|
|
5523
5562
|
"zero-shot-image-classification": snippetZeroShotImageClassification
|
|
5524
5563
|
};
|
|
5525
5564
|
function getPythonInferenceSnippet(model, accessToken) {
|
|
5526
|
-
|
|
5527
|
-
|
|
5565
|
+
if (model.pipeline_tag === "text-generation" && model.config?.tokenizer_config?.chat_template) {
|
|
5566
|
+
return snippetConversational(model, accessToken);
|
|
5567
|
+
} else {
|
|
5568
|
+
const body = model.pipeline_tag && model.pipeline_tag in pythonSnippets ? pythonSnippets[model.pipeline_tag]?.(model, accessToken) ?? "" : "";
|
|
5569
|
+
return `import requests
|
|
5528
5570
|
|
|
5529
5571
|
API_URL = "https://api-inference.huggingface.co/models/${model.id}"
|
|
5530
5572
|
headers = {"Authorization": ${accessToken ? `"Bearer ${accessToken}"` : `f"Bearer {API_TOKEN}"`}}
|
|
5531
5573
|
|
|
5532
5574
|
${body}`;
|
|
5575
|
+
}
|
|
5533
5576
|
}
|
|
5534
5577
|
function hasPythonInferenceSnippet(model) {
|
|
5535
5578
|
return !!model.pipeline_tag && model.pipeline_tag in pythonSnippets;
|
|
@@ -5543,6 +5586,7 @@ __export(js_exports, {
|
|
|
5543
5586
|
jsSnippets: () => jsSnippets,
|
|
5544
5587
|
snippetBasic: () => snippetBasic3,
|
|
5545
5588
|
snippetFile: () => snippetFile3,
|
|
5589
|
+
snippetTextGeneration: () => snippetTextGeneration2,
|
|
5546
5590
|
snippetTextToAudio: () => snippetTextToAudio2,
|
|
5547
5591
|
snippetTextToImage: () => snippetTextToImage2,
|
|
5548
5592
|
snippetZeroShotClassification: () => snippetZeroShotClassification3
|
|
@@ -5551,7 +5595,10 @@ var snippetBasic3 = (model, accessToken) => `async function query(data) {
|
|
|
5551
5595
|
const response = await fetch(
|
|
5552
5596
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
5553
5597
|
{
|
|
5554
|
-
headers: {
|
|
5598
|
+
headers: {
|
|
5599
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
5600
|
+
"Content-Type": "application/json",
|
|
5601
|
+
},
|
|
5555
5602
|
method: "POST",
|
|
5556
5603
|
body: JSON.stringify(data),
|
|
5557
5604
|
}
|
|
@@ -5563,11 +5610,32 @@ var snippetBasic3 = (model, accessToken) => `async function query(data) {
|
|
|
5563
5610
|
query({"inputs": ${getModelInputSnippet(model)}}).then((response) => {
|
|
5564
5611
|
console.log(JSON.stringify(response));
|
|
5565
5612
|
});`;
|
|
5613
|
+
var snippetTextGeneration2 = (model, accessToken) => {
|
|
5614
|
+
if (model.config?.tokenizer_config?.chat_template) {
|
|
5615
|
+
return `import { HfInference } from "@huggingface/inference";
|
|
5616
|
+
|
|
5617
|
+
const inference = new HfInference("${accessToken || `{API_TOKEN}`}");
|
|
5618
|
+
|
|
5619
|
+
for await (const chunk of inference.chatCompletionStream({
|
|
5620
|
+
model: "${model.id}",
|
|
5621
|
+
messages: [{ role: "user", content: "What is the capital of France?" }],
|
|
5622
|
+
max_tokens: 500,
|
|
5623
|
+
})) {
|
|
5624
|
+
process.stdout.write(chunk.choices[0]?.delta?.content || "");
|
|
5625
|
+
}
|
|
5626
|
+
`;
|
|
5627
|
+
} else {
|
|
5628
|
+
return snippetBasic3(model, accessToken);
|
|
5629
|
+
}
|
|
5630
|
+
};
|
|
5566
5631
|
var snippetZeroShotClassification3 = (model, accessToken) => `async function query(data) {
|
|
5567
5632
|
const response = await fetch(
|
|
5568
5633
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
5569
5634
|
{
|
|
5570
|
-
headers: {
|
|
5635
|
+
headers: {
|
|
5636
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
5637
|
+
"Content-Type": "application/json",
|
|
5638
|
+
},
|
|
5571
5639
|
method: "POST",
|
|
5572
5640
|
body: JSON.stringify(data),
|
|
5573
5641
|
}
|
|
@@ -5585,7 +5653,10 @@ var snippetTextToImage2 = (model, accessToken) => `async function query(data) {
|
|
|
5585
5653
|
const response = await fetch(
|
|
5586
5654
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
5587
5655
|
{
|
|
5588
|
-
headers: {
|
|
5656
|
+
headers: {
|
|
5657
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
5658
|
+
"Content-Type": "application/json",
|
|
5659
|
+
},
|
|
5589
5660
|
method: "POST",
|
|
5590
5661
|
body: JSON.stringify(data),
|
|
5591
5662
|
}
|
|
@@ -5601,7 +5672,10 @@ var snippetTextToAudio2 = (model, accessToken) => {
|
|
|
5601
5672
|
const response = await fetch(
|
|
5602
5673
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
5603
5674
|
{
|
|
5604
|
-
headers: {
|
|
5675
|
+
headers: {
|
|
5676
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
5677
|
+
"Content-Type": "application/json",
|
|
5678
|
+
},
|
|
5605
5679
|
method: "POST",
|
|
5606
5680
|
body: JSON.stringify(data),
|
|
5607
5681
|
}
|
|
@@ -5630,7 +5704,10 @@ var snippetFile3 = (model, accessToken) => `async function query(filename) {
|
|
|
5630
5704
|
const response = await fetch(
|
|
5631
5705
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
5632
5706
|
{
|
|
5633
|
-
headers: {
|
|
5707
|
+
headers: {
|
|
5708
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
5709
|
+
"Content-Type": "application/json",
|
|
5710
|
+
},
|
|
5634
5711
|
method: "POST",
|
|
5635
5712
|
body: data,
|
|
5636
5713
|
}
|
|
@@ -5652,7 +5729,7 @@ var jsSnippets = {
|
|
|
5652
5729
|
translation: snippetBasic3,
|
|
5653
5730
|
summarization: snippetBasic3,
|
|
5654
5731
|
"feature-extraction": snippetBasic3,
|
|
5655
|
-
"text-generation":
|
|
5732
|
+
"text-generation": snippetTextGeneration2,
|
|
5656
5733
|
"text2text-generation": snippetBasic3,
|
|
5657
5734
|
"fill-mask": snippetBasic3,
|
|
5658
5735
|
"sentence-similarity": snippetBasic3,
|
|
@@ -6077,7 +6154,7 @@ var SKUS = {
|
|
|
6077
6154
|
function isGgufModel(model) {
|
|
6078
6155
|
return model.tags.includes("gguf");
|
|
6079
6156
|
}
|
|
6080
|
-
var snippetLlamacpp = (model) => {
|
|
6157
|
+
var snippetLlamacpp = (model, filepath) => {
|
|
6081
6158
|
return [
|
|
6082
6159
|
`# Option 1: use llama.cpp with brew
|
|
6083
6160
|
brew install llama.cpp
|
|
@@ -6085,7 +6162,7 @@ brew install llama.cpp
|
|
|
6085
6162
|
# Load and run the model
|
|
6086
6163
|
llama \\
|
|
6087
6164
|
--hf-repo "${model.id}" \\
|
|
6088
|
-
--hf-file {{GGUF_FILE}} \\
|
|
6165
|
+
--hf-file ${filepath ?? "{{GGUF_FILE}}"} \\
|
|
6089
6166
|
-p "I believe the meaning of life is" \\
|
|
6090
6167
|
-n 128`,
|
|
6091
6168
|
`# Option 2: build llama.cpp from source with curl support
|
|
@@ -6096,7 +6173,7 @@ LLAMA_CURL=1 make
|
|
|
6096
6173
|
# Load and run the model
|
|
6097
6174
|
./main \\
|
|
6098
6175
|
--hf-repo "${model.id}" \\
|
|
6099
|
-
-m {{GGUF_FILE}} \\
|
|
6176
|
+
-m ${filepath ?? "{{GGUF_FILE}}"} \\
|
|
6100
6177
|
-p "I believe the meaning of life is" \\
|
|
6101
6178
|
-n 128`
|
|
6102
6179
|
];
|
|
@@ -6114,7 +6191,7 @@ var LOCAL_APPS = {
|
|
|
6114
6191
|
docsUrl: "https://lmstudio.ai",
|
|
6115
6192
|
mainTask: "text-generation",
|
|
6116
6193
|
displayOnModelPage: isGgufModel,
|
|
6117
|
-
deeplink: (model) => new URL(`lmstudio://open_from_hf?model=${model.id}`)
|
|
6194
|
+
deeplink: (model, filepath) => new URL(`lmstudio://open_from_hf?model=${model.id}${filepath ? `&file=${filepath}` : ""}`)
|
|
6118
6195
|
},
|
|
6119
6196
|
jan: {
|
|
6120
6197
|
prettyLabel: "Jan",
|
package/dist/index.js
CHANGED
|
@@ -4879,6 +4879,13 @@ var MODEL_LIBRARIES_UI_ELEMENTS = {
|
|
|
4879
4879
|
filter: false,
|
|
4880
4880
|
countDownloads: `path:"gliner_config.json"`
|
|
4881
4881
|
},
|
|
4882
|
+
"glyph-byt5": {
|
|
4883
|
+
prettyLabel: "Glyph-ByT5",
|
|
4884
|
+
repoName: "Glyph-ByT5",
|
|
4885
|
+
repoUrl: "https://github.com/AIGText/Glyph-ByT5",
|
|
4886
|
+
filter: false,
|
|
4887
|
+
countDownloads: `path:"checkpoints/byt5_model.pt"`
|
|
4888
|
+
},
|
|
4882
4889
|
grok: {
|
|
4883
4890
|
prettyLabel: "Grok",
|
|
4884
4891
|
repoName: "Grok",
|
|
@@ -5200,39 +5207,39 @@ var inputsZeroShotClassification = () => `"Hi, I recently bought a device from y
|
|
|
5200
5207
|
var inputsTranslation = () => `"\u041C\u0435\u043D\u044F \u0437\u043E\u0432\u0443\u0442 \u0412\u043E\u043B\u044C\u0444\u0433\u0430\u043D\u0433 \u0438 \u044F \u0436\u0438\u0432\u0443 \u0432 \u0411\u0435\u0440\u043B\u0438\u043D\u0435"`;
|
|
5201
5208
|
var inputsSummarization = () => `"The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct."`;
|
|
5202
5209
|
var inputsTableQuestionAnswering = () => `{
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5210
|
+
"query": "How many stars does the transformers repository have?",
|
|
5211
|
+
"table": {
|
|
5212
|
+
"Repository": ["Transformers", "Datasets", "Tokenizers"],
|
|
5213
|
+
"Stars": ["36542", "4512", "3934"],
|
|
5214
|
+
"Contributors": ["651", "77", "34"],
|
|
5215
|
+
"Programming language": [
|
|
5216
|
+
"Python",
|
|
5217
|
+
"Python",
|
|
5218
|
+
"Rust, Python and NodeJS"
|
|
5219
|
+
]
|
|
5220
|
+
}
|
|
5221
|
+
}`;
|
|
5215
5222
|
var inputsVisualQuestionAnswering = () => `{
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5223
|
+
"image": "cat.png",
|
|
5224
|
+
"question": "What is in this image?"
|
|
5225
|
+
}`;
|
|
5219
5226
|
var inputsQuestionAnswering = () => `{
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5227
|
+
"question": "What is my name?",
|
|
5228
|
+
"context": "My name is Clara and I live in Berkeley."
|
|
5229
|
+
}`;
|
|
5223
5230
|
var inputsTextClassification = () => `"I like you. I love you"`;
|
|
5224
5231
|
var inputsTokenClassification = () => `"My name is Sarah Jessica Parker but you can call me Jessica"`;
|
|
5225
5232
|
var inputsTextGeneration = () => `"Can you please let us know more details about your "`;
|
|
5226
5233
|
var inputsText2TextGeneration = () => `"The answer to the universe is"`;
|
|
5227
5234
|
var inputsFillMask = (model) => `"The answer to the universe is ${model.mask_token}."`;
|
|
5228
5235
|
var inputsSentenceSimilarity = () => `{
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
+
"source_sentence": "That is a happy person",
|
|
5237
|
+
"sentences": [
|
|
5238
|
+
"That is a happy dog",
|
|
5239
|
+
"That is a very happy person",
|
|
5240
|
+
"Today is a sunny day"
|
|
5241
|
+
]
|
|
5242
|
+
}`;
|
|
5236
5243
|
var inputsFeatureExtraction = () => `"Today is a sunny day and I will get some ice cream."`;
|
|
5237
5244
|
var inputsImageClassification = () => `"cats.jpg"`;
|
|
5238
5245
|
var inputsImageToText = () => `"cats.jpg"`;
|
|
@@ -5301,6 +5308,7 @@ __export(curl_exports, {
|
|
|
5301
5308
|
hasCurlInferenceSnippet: () => hasCurlInferenceSnippet,
|
|
5302
5309
|
snippetBasic: () => snippetBasic,
|
|
5303
5310
|
snippetFile: () => snippetFile,
|
|
5311
|
+
snippetTextGeneration: () => snippetTextGeneration,
|
|
5304
5312
|
snippetZeroShotClassification: () => snippetZeroShotClassification
|
|
5305
5313
|
});
|
|
5306
5314
|
var snippetBasic = (model, accessToken) => `curl https://api-inference.huggingface.co/models/${model.id} \\
|
|
@@ -5309,6 +5317,22 @@ var snippetBasic = (model, accessToken) => `curl https://api-inference.huggingfa
|
|
|
5309
5317
|
-H 'Content-Type: application/json' \\
|
|
5310
5318
|
-H "Authorization: Bearer ${accessToken || `{API_TOKEN}`}"
|
|
5311
5319
|
`;
|
|
5320
|
+
var snippetTextGeneration = (model, accessToken) => {
|
|
5321
|
+
if (model.config?.tokenizer_config?.chat_template) {
|
|
5322
|
+
return `curl 'https://api-inference.huggingface.co/models/${model.id}/v1/chat/completions' \\
|
|
5323
|
+
-H "Authorization: Bearer ${accessToken || `{API_TOKEN}`}" \\
|
|
5324
|
+
-H 'Content-Type: application/json' \\
|
|
5325
|
+
-d '{
|
|
5326
|
+
"model": "${model.id}",
|
|
5327
|
+
"messages": [{"role": "user", "content": "What is the capital of France?"}],
|
|
5328
|
+
"max_tokens": 500,
|
|
5329
|
+
"stream": false
|
|
5330
|
+
}'
|
|
5331
|
+
`;
|
|
5332
|
+
} else {
|
|
5333
|
+
return snippetBasic(model, accessToken);
|
|
5334
|
+
}
|
|
5335
|
+
};
|
|
5312
5336
|
var snippetZeroShotClassification = (model, accessToken) => `curl https://api-inference.huggingface.co/models/${model.id} \\
|
|
5313
5337
|
-X POST \\
|
|
5314
5338
|
-d '{"inputs": ${getModelInputSnippet(model, true)}, "parameters": {"candidate_labels": ["refund", "legal", "faq"]}}' \\
|
|
@@ -5330,7 +5354,7 @@ var curlSnippets = {
|
|
|
5330
5354
|
translation: snippetBasic,
|
|
5331
5355
|
summarization: snippetBasic,
|
|
5332
5356
|
"feature-extraction": snippetBasic,
|
|
5333
|
-
"text-generation":
|
|
5357
|
+
"text-generation": snippetTextGeneration,
|
|
5334
5358
|
"text2text-generation": snippetBasic,
|
|
5335
5359
|
"fill-mask": snippetBasic,
|
|
5336
5360
|
"sentence-similarity": snippetBasic,
|
|
@@ -5359,6 +5383,7 @@ __export(python_exports, {
|
|
|
5359
5383
|
hasPythonInferenceSnippet: () => hasPythonInferenceSnippet,
|
|
5360
5384
|
pythonSnippets: () => pythonSnippets,
|
|
5361
5385
|
snippetBasic: () => snippetBasic2,
|
|
5386
|
+
snippetConversational: () => snippetConversational,
|
|
5362
5387
|
snippetDocumentQuestionAnswering: () => snippetDocumentQuestionAnswering,
|
|
5363
5388
|
snippetFile: () => snippetFile2,
|
|
5364
5389
|
snippetTabular: () => snippetTabular,
|
|
@@ -5367,6 +5392,20 @@ __export(python_exports, {
|
|
|
5367
5392
|
snippetZeroShotClassification: () => snippetZeroShotClassification2,
|
|
5368
5393
|
snippetZeroShotImageClassification: () => snippetZeroShotImageClassification
|
|
5369
5394
|
});
|
|
5395
|
+
var snippetConversational = (model, accessToken) => `from huggingface_hub import InferenceClient
|
|
5396
|
+
|
|
5397
|
+
client = InferenceClient(
|
|
5398
|
+
"${model.id}",
|
|
5399
|
+
token="${accessToken || "{API_TOKEN}"}",
|
|
5400
|
+
)
|
|
5401
|
+
|
|
5402
|
+
for message in client.chat_completion(
|
|
5403
|
+
messages=[{"role": "user", "content": "What is the capital of France?"}],
|
|
5404
|
+
max_tokens=500,
|
|
5405
|
+
stream=True,
|
|
5406
|
+
):
|
|
5407
|
+
print(message.choices[0].delta.content, end="")
|
|
5408
|
+
`;
|
|
5370
5409
|
var snippetZeroShotClassification2 = (model) => `def query(payload):
|
|
5371
5410
|
response = requests.post(API_URL, headers=headers, json=payload)
|
|
5372
5411
|
return response.json()
|
|
@@ -5484,13 +5523,17 @@ var pythonSnippets = {
|
|
|
5484
5523
|
"zero-shot-image-classification": snippetZeroShotImageClassification
|
|
5485
5524
|
};
|
|
5486
5525
|
function getPythonInferenceSnippet(model, accessToken) {
|
|
5487
|
-
|
|
5488
|
-
|
|
5526
|
+
if (model.pipeline_tag === "text-generation" && model.config?.tokenizer_config?.chat_template) {
|
|
5527
|
+
return snippetConversational(model, accessToken);
|
|
5528
|
+
} else {
|
|
5529
|
+
const body = model.pipeline_tag && model.pipeline_tag in pythonSnippets ? pythonSnippets[model.pipeline_tag]?.(model, accessToken) ?? "" : "";
|
|
5530
|
+
return `import requests
|
|
5489
5531
|
|
|
5490
5532
|
API_URL = "https://api-inference.huggingface.co/models/${model.id}"
|
|
5491
5533
|
headers = {"Authorization": ${accessToken ? `"Bearer ${accessToken}"` : `f"Bearer {API_TOKEN}"`}}
|
|
5492
5534
|
|
|
5493
5535
|
${body}`;
|
|
5536
|
+
}
|
|
5494
5537
|
}
|
|
5495
5538
|
function hasPythonInferenceSnippet(model) {
|
|
5496
5539
|
return !!model.pipeline_tag && model.pipeline_tag in pythonSnippets;
|
|
@@ -5504,6 +5547,7 @@ __export(js_exports, {
|
|
|
5504
5547
|
jsSnippets: () => jsSnippets,
|
|
5505
5548
|
snippetBasic: () => snippetBasic3,
|
|
5506
5549
|
snippetFile: () => snippetFile3,
|
|
5550
|
+
snippetTextGeneration: () => snippetTextGeneration2,
|
|
5507
5551
|
snippetTextToAudio: () => snippetTextToAudio2,
|
|
5508
5552
|
snippetTextToImage: () => snippetTextToImage2,
|
|
5509
5553
|
snippetZeroShotClassification: () => snippetZeroShotClassification3
|
|
@@ -5512,7 +5556,10 @@ var snippetBasic3 = (model, accessToken) => `async function query(data) {
|
|
|
5512
5556
|
const response = await fetch(
|
|
5513
5557
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
5514
5558
|
{
|
|
5515
|
-
headers: {
|
|
5559
|
+
headers: {
|
|
5560
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
5561
|
+
"Content-Type": "application/json",
|
|
5562
|
+
},
|
|
5516
5563
|
method: "POST",
|
|
5517
5564
|
body: JSON.stringify(data),
|
|
5518
5565
|
}
|
|
@@ -5524,11 +5571,32 @@ var snippetBasic3 = (model, accessToken) => `async function query(data) {
|
|
|
5524
5571
|
query({"inputs": ${getModelInputSnippet(model)}}).then((response) => {
|
|
5525
5572
|
console.log(JSON.stringify(response));
|
|
5526
5573
|
});`;
|
|
5574
|
+
var snippetTextGeneration2 = (model, accessToken) => {
|
|
5575
|
+
if (model.config?.tokenizer_config?.chat_template) {
|
|
5576
|
+
return `import { HfInference } from "@huggingface/inference";
|
|
5577
|
+
|
|
5578
|
+
const inference = new HfInference("${accessToken || `{API_TOKEN}`}");
|
|
5579
|
+
|
|
5580
|
+
for await (const chunk of inference.chatCompletionStream({
|
|
5581
|
+
model: "${model.id}",
|
|
5582
|
+
messages: [{ role: "user", content: "What is the capital of France?" }],
|
|
5583
|
+
max_tokens: 500,
|
|
5584
|
+
})) {
|
|
5585
|
+
process.stdout.write(chunk.choices[0]?.delta?.content || "");
|
|
5586
|
+
}
|
|
5587
|
+
`;
|
|
5588
|
+
} else {
|
|
5589
|
+
return snippetBasic3(model, accessToken);
|
|
5590
|
+
}
|
|
5591
|
+
};
|
|
5527
5592
|
var snippetZeroShotClassification3 = (model, accessToken) => `async function query(data) {
|
|
5528
5593
|
const response = await fetch(
|
|
5529
5594
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
5530
5595
|
{
|
|
5531
|
-
headers: {
|
|
5596
|
+
headers: {
|
|
5597
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
5598
|
+
"Content-Type": "application/json",
|
|
5599
|
+
},
|
|
5532
5600
|
method: "POST",
|
|
5533
5601
|
body: JSON.stringify(data),
|
|
5534
5602
|
}
|
|
@@ -5546,7 +5614,10 @@ var snippetTextToImage2 = (model, accessToken) => `async function query(data) {
|
|
|
5546
5614
|
const response = await fetch(
|
|
5547
5615
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
5548
5616
|
{
|
|
5549
|
-
headers: {
|
|
5617
|
+
headers: {
|
|
5618
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
5619
|
+
"Content-Type": "application/json",
|
|
5620
|
+
},
|
|
5550
5621
|
method: "POST",
|
|
5551
5622
|
body: JSON.stringify(data),
|
|
5552
5623
|
}
|
|
@@ -5562,7 +5633,10 @@ var snippetTextToAudio2 = (model, accessToken) => {
|
|
|
5562
5633
|
const response = await fetch(
|
|
5563
5634
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
5564
5635
|
{
|
|
5565
|
-
headers: {
|
|
5636
|
+
headers: {
|
|
5637
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
5638
|
+
"Content-Type": "application/json",
|
|
5639
|
+
},
|
|
5566
5640
|
method: "POST",
|
|
5567
5641
|
body: JSON.stringify(data),
|
|
5568
5642
|
}
|
|
@@ -5591,7 +5665,10 @@ var snippetFile3 = (model, accessToken) => `async function query(filename) {
|
|
|
5591
5665
|
const response = await fetch(
|
|
5592
5666
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
5593
5667
|
{
|
|
5594
|
-
headers: {
|
|
5668
|
+
headers: {
|
|
5669
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
5670
|
+
"Content-Type": "application/json",
|
|
5671
|
+
},
|
|
5595
5672
|
method: "POST",
|
|
5596
5673
|
body: data,
|
|
5597
5674
|
}
|
|
@@ -5613,7 +5690,7 @@ var jsSnippets = {
|
|
|
5613
5690
|
translation: snippetBasic3,
|
|
5614
5691
|
summarization: snippetBasic3,
|
|
5615
5692
|
"feature-extraction": snippetBasic3,
|
|
5616
|
-
"text-generation":
|
|
5693
|
+
"text-generation": snippetTextGeneration2,
|
|
5617
5694
|
"text2text-generation": snippetBasic3,
|
|
5618
5695
|
"fill-mask": snippetBasic3,
|
|
5619
5696
|
"sentence-similarity": snippetBasic3,
|
|
@@ -6038,7 +6115,7 @@ var SKUS = {
|
|
|
6038
6115
|
function isGgufModel(model) {
|
|
6039
6116
|
return model.tags.includes("gguf");
|
|
6040
6117
|
}
|
|
6041
|
-
var snippetLlamacpp = (model) => {
|
|
6118
|
+
var snippetLlamacpp = (model, filepath) => {
|
|
6042
6119
|
return [
|
|
6043
6120
|
`# Option 1: use llama.cpp with brew
|
|
6044
6121
|
brew install llama.cpp
|
|
@@ -6046,7 +6123,7 @@ brew install llama.cpp
|
|
|
6046
6123
|
# Load and run the model
|
|
6047
6124
|
llama \\
|
|
6048
6125
|
--hf-repo "${model.id}" \\
|
|
6049
|
-
--hf-file {{GGUF_FILE}} \\
|
|
6126
|
+
--hf-file ${filepath ?? "{{GGUF_FILE}}"} \\
|
|
6050
6127
|
-p "I believe the meaning of life is" \\
|
|
6051
6128
|
-n 128`,
|
|
6052
6129
|
`# Option 2: build llama.cpp from source with curl support
|
|
@@ -6057,7 +6134,7 @@ LLAMA_CURL=1 make
|
|
|
6057
6134
|
# Load and run the model
|
|
6058
6135
|
./main \\
|
|
6059
6136
|
--hf-repo "${model.id}" \\
|
|
6060
|
-
-m {{GGUF_FILE}} \\
|
|
6137
|
+
-m ${filepath ?? "{{GGUF_FILE}}"} \\
|
|
6061
6138
|
-p "I believe the meaning of life is" \\
|
|
6062
6139
|
-n 128`
|
|
6063
6140
|
];
|
|
@@ -6075,7 +6152,7 @@ var LOCAL_APPS = {
|
|
|
6075
6152
|
docsUrl: "https://lmstudio.ai",
|
|
6076
6153
|
mainTask: "text-generation",
|
|
6077
6154
|
displayOnModelPage: isGgufModel,
|
|
6078
|
-
deeplink: (model) => new URL(`lmstudio://open_from_hf?model=${model.id}`)
|
|
6155
|
+
deeplink: (model, filepath) => new URL(`lmstudio://open_from_hf?model=${model.id}${filepath ? `&file=${filepath}` : ""}`)
|
|
6079
6156
|
},
|
|
6080
6157
|
jan: {
|
|
6081
6158
|
prettyLabel: "Jan",
|
package/dist/src/local-apps.d.ts
CHANGED
|
@@ -29,13 +29,13 @@ export type LocalApp = {
|
|
|
29
29
|
/**
|
|
30
30
|
* If the app supports deeplink, URL to open.
|
|
31
31
|
*/
|
|
32
|
-
deeplink: (model: ModelData) => URL;
|
|
32
|
+
deeplink: (model: ModelData, filepath?: string) => URL;
|
|
33
33
|
} | {
|
|
34
34
|
/**
|
|
35
35
|
* And if not (mostly llama.cpp), snippet to copy/paste in your terminal
|
|
36
36
|
* Support the placeholder {{GGUF_FILE}} that will be replaced by the gguf file path or the list of available files.
|
|
37
37
|
*/
|
|
38
|
-
snippet: (model: ModelData) => string | string[];
|
|
38
|
+
snippet: (model: ModelData, filepath?: string) => string | string[];
|
|
39
39
|
});
|
|
40
40
|
declare function isGgufModel(model: ModelData): boolean;
|
|
41
41
|
/**
|
|
@@ -55,14 +55,14 @@ export declare const LOCAL_APPS: {
|
|
|
55
55
|
docsUrl: string;
|
|
56
56
|
mainTask: "text-generation";
|
|
57
57
|
displayOnModelPage: typeof isGgufModel;
|
|
58
|
-
snippet: (model: ModelData) => string[];
|
|
58
|
+
snippet: (model: ModelData, filepath?: string) => string[];
|
|
59
59
|
};
|
|
60
60
|
lmstudio: {
|
|
61
61
|
prettyLabel: string;
|
|
62
62
|
docsUrl: string;
|
|
63
63
|
mainTask: "text-generation";
|
|
64
64
|
displayOnModelPage: typeof isGgufModel;
|
|
65
|
-
deeplink: (model: ModelData) => URL;
|
|
65
|
+
deeplink: (model: ModelData, filepath: string | undefined) => URL;
|
|
66
66
|
};
|
|
67
67
|
jan: {
|
|
68
68
|
prettyLabel: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-apps.d.ts","sourceRoot":"","sources":["../../src/local-apps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,EAAE,YAAY,CAAC;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,kBAAkB,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC;CAClD,GAAG,CACD;IACA;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"local-apps.d.ts","sourceRoot":"","sources":["../../src/local-apps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,EAAE,YAAY,CAAC;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,kBAAkB,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC;CAClD,GAAG,CACD;IACA;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CACtD,GACD;IACA;;;OAGG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,EAAE,CAAC;CACnE,CACH,CAAC;AAEF,iBAAS,WAAW,CAAC,KAAK,EAAE,SAAS,WAEpC;AA2BD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU;;;;;;yBApCS,SAAS,aAAa,MAAM,KAAG,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmInC,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,UAAU,CAAC"}
|
|
@@ -209,6 +209,13 @@ export declare const MODEL_LIBRARIES_UI_ELEMENTS: {
|
|
|
209
209
|
filter: false;
|
|
210
210
|
countDownloads: string;
|
|
211
211
|
};
|
|
212
|
+
"glyph-byt5": {
|
|
213
|
+
prettyLabel: string;
|
|
214
|
+
repoName: string;
|
|
215
|
+
repoUrl: string;
|
|
216
|
+
filter: false;
|
|
217
|
+
countDownloads: string;
|
|
218
|
+
};
|
|
212
219
|
grok: {
|
|
213
220
|
prettyLabel: string;
|
|
214
221
|
repoName: string;
|
|
@@ -487,6 +494,6 @@ export declare const MODEL_LIBRARIES_UI_ELEMENTS: {
|
|
|
487
494
|
};
|
|
488
495
|
};
|
|
489
496
|
export type ModelLibraryKey = keyof typeof MODEL_LIBRARIES_UI_ELEMENTS;
|
|
490
|
-
export declare const ALL_MODEL_LIBRARY_KEYS: ("adapter-transformers" | "allennlp" | "asteroid" | "audiocraft" | "audioseal" | "bertopic" | "big_vision" | "bm25s" | "chat_tts" | "diffusers" | "doctr" | "edsnlp" | "elm" | "espnet" | "fairseq" | "fastai" | "fasttext" | "flair" | "gemma.cpp" | "gliner" | "grok" | "hunyuan-dit" | "keras" | "keras-nlp" | "k2" | "mindspore" | "ml-agents" | "mlx" | "mlx-image" | "nemo" | "open_clip" | "paddlenlp" | "peft" | "pyannote-audio" | "pythae" | "recurrentgemma" | "sample-factory" | "sentence-transformers" | "setfit" | "sklearn" | "spacy" | "span-marker" | "speechbrain" | "stable-audio-tools" | "diffusion-single-file" | "stable-baselines3" | "stanza" | "tensorflowtts" | "tic-clip" | "timesfm" | "timm" | "transformers" | "transformers.js" | "unity-sentis" | "voicecraft" | "whisperkit")[];
|
|
491
|
-
export declare const ALL_DISPLAY_MODEL_LIBRARY_KEYS: ("adapter-transformers" | "allennlp" | "asteroid" | "audiocraft" | "audioseal" | "bertopic" | "big_vision" | "bm25s" | "chat_tts" | "diffusers" | "doctr" | "edsnlp" | "elm" | "espnet" | "fairseq" | "fastai" | "fasttext" | "flair" | "gemma.cpp" | "gliner" | "grok" | "hunyuan-dit" | "keras" | "keras-nlp" | "k2" | "mindspore" | "ml-agents" | "mlx" | "mlx-image" | "nemo" | "open_clip" | "paddlenlp" | "peft" | "pyannote-audio" | "pythae" | "recurrentgemma" | "sample-factory" | "sentence-transformers" | "setfit" | "sklearn" | "spacy" | "span-marker" | "speechbrain" | "stable-audio-tools" | "diffusion-single-file" | "stable-baselines3" | "stanza" | "tensorflowtts" | "tic-clip" | "timesfm" | "timm" | "transformers" | "transformers.js" | "unity-sentis" | "voicecraft" | "whisperkit")[];
|
|
497
|
+
export declare const ALL_MODEL_LIBRARY_KEYS: ("adapter-transformers" | "allennlp" | "asteroid" | "audiocraft" | "audioseal" | "bertopic" | "big_vision" | "bm25s" | "chat_tts" | "diffusers" | "doctr" | "edsnlp" | "elm" | "espnet" | "fairseq" | "fastai" | "fasttext" | "flair" | "gemma.cpp" | "gliner" | "glyph-byt5" | "grok" | "hunyuan-dit" | "keras" | "keras-nlp" | "k2" | "mindspore" | "ml-agents" | "mlx" | "mlx-image" | "nemo" | "open_clip" | "paddlenlp" | "peft" | "pyannote-audio" | "pythae" | "recurrentgemma" | "sample-factory" | "sentence-transformers" | "setfit" | "sklearn" | "spacy" | "span-marker" | "speechbrain" | "stable-audio-tools" | "diffusion-single-file" | "stable-baselines3" | "stanza" | "tensorflowtts" | "tic-clip" | "timesfm" | "timm" | "transformers" | "transformers.js" | "unity-sentis" | "voicecraft" | "whisperkit")[];
|
|
498
|
+
export declare const ALL_DISPLAY_MODEL_LIBRARY_KEYS: ("adapter-transformers" | "allennlp" | "asteroid" | "audiocraft" | "audioseal" | "bertopic" | "big_vision" | "bm25s" | "chat_tts" | "diffusers" | "doctr" | "edsnlp" | "elm" | "espnet" | "fairseq" | "fastai" | "fasttext" | "flair" | "gemma.cpp" | "gliner" | "glyph-byt5" | "grok" | "hunyuan-dit" | "keras" | "keras-nlp" | "k2" | "mindspore" | "ml-agents" | "mlx" | "mlx-image" | "nemo" | "open_clip" | "paddlenlp" | "peft" | "pyannote-audio" | "pythae" | "recurrentgemma" | "sample-factory" | "sentence-transformers" | "setfit" | "sklearn" | "spacy" | "span-marker" | "speechbrain" | "stable-audio-tools" | "diffusion-single-file" | "stable-baselines3" | "stanza" | "tensorflowtts" | "tic-clip" | "timesfm" | "timm" | "transformers" | "transformers.js" | "unity-sentis" | "voicecraft" | "whisperkit")[];
|
|
492
499
|
//# sourceMappingURL=model-libraries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-libraries.d.ts","sourceRoot":"","sources":["../../src/model-libraries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,MAAM,EAAE,CAAC;IAC1C;;;;;OAKG;IACH,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,2BAA2B
|
|
1
|
+
{"version":3,"file":"model-libraries.d.ts","sourceRoot":"","sources":["../../src/model-libraries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,MAAM,EAAE,CAAC;IAC1C;;;;;OAKG;IACH,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwbI,CAAC;AAE7C,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,2BAA2B,CAAC;AAEvE,eAAO,MAAM,sBAAsB,myBAAgE,CAAC;AAEpG,eAAO,MAAM,8BAA8B,myBAQ1B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PipelineType } from "../pipelines.js";
|
|
2
2
|
import type { ModelDataMinimal } from "./types.js";
|
|
3
3
|
export declare const snippetBasic: (model: ModelDataMinimal, accessToken: string) => string;
|
|
4
|
+
export declare const snippetTextGeneration: (model: ModelDataMinimal, accessToken: string) => string;
|
|
4
5
|
export declare const snippetZeroShotClassification: (model: ModelDataMinimal, accessToken: string) => string;
|
|
5
6
|
export declare const snippetFile: (model: ModelDataMinimal, accessToken: string) => string;
|
|
6
7
|
export declare const curlSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal, accessToken: string) => string>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../../src/snippets/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,eAAO,MAAM,YAAY,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAM3E,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAM5F,CAAC;AAEF,eAAO,MAAM,WAAW,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAK1E,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC,CAwBhH,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAI5F;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,GAAG,OAAO,CAE9F"}
|
|
1
|
+
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../../src/snippets/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,eAAO,MAAM,YAAY,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAM3E,CAAC;AAEF,eAAO,MAAM,qBAAqB,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAgBpF,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAM5F,CAAC;AAEF,eAAO,MAAM,WAAW,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAK1E,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC,CAwBhH,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAI5F;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,GAAG,OAAO,CAE9F"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PipelineType } from "../pipelines.js";
|
|
2
2
|
import type { ModelDataMinimal } from "./types.js";
|
|
3
3
|
export declare const snippetBasic: (model: ModelDataMinimal, accessToken: string) => string;
|
|
4
|
+
export declare const snippetTextGeneration: (model: ModelDataMinimal, accessToken: string) => string;
|
|
4
5
|
export declare const snippetZeroShotClassification: (model: ModelDataMinimal, accessToken: string) => string;
|
|
5
6
|
export declare const snippetTextToImage: (model: ModelDataMinimal, accessToken: string) => string;
|
|
6
7
|
export declare const snippetTextToAudio: (model: ModelDataMinimal, accessToken: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js.d.ts","sourceRoot":"","sources":["../../../src/snippets/js.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,eAAO,MAAM,YAAY,UAAW,gBAAgB,eAAe,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"js.d.ts","sourceRoot":"","sources":["../../../src/snippets/js.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,eAAO,MAAM,YAAY,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAmBxE,CAAC;AAEL,eAAO,MAAM,qBAAqB,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAkBpF,CAAC;AACF,eAAO,MAAM,6BAA6B,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAqBzF,CAAC;AAEL,eAAO,MAAM,kBAAkB,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAkB9E,CAAC;AAEL,eAAO,MAAM,kBAAkB,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAqCjF,CAAC;AAEF,eAAO,MAAM,WAAW,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAoBvE,CAAC;AAEL,eAAO,MAAM,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC,CAwB9G,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAI1F;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAEtE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PipelineType } from "../pipelines.js";
|
|
2
2
|
import type { ModelDataMinimal } from "./types.js";
|
|
3
|
+
export declare const snippetConversational: (model: ModelDataMinimal, accessToken: string) => string;
|
|
3
4
|
export declare const snippetZeroShotClassification: (model: ModelDataMinimal) => string;
|
|
4
5
|
export declare const snippetZeroShotImageClassification: (model: ModelDataMinimal) => string;
|
|
5
6
|
export declare const snippetBasic: (model: ModelDataMinimal) => string;
|
|
@@ -8,7 +9,7 @@ export declare const snippetTextToImage: (model: ModelDataMinimal) => string;
|
|
|
8
9
|
export declare const snippetTabular: (model: ModelDataMinimal) => string;
|
|
9
10
|
export declare const snippetTextToAudio: (model: ModelDataMinimal) => string;
|
|
10
11
|
export declare const snippetDocumentQuestionAnswering: (model: ModelDataMinimal) => string;
|
|
11
|
-
export declare const pythonSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal) => string>>;
|
|
12
|
+
export declare const pythonSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal, accessToken: string) => string>>;
|
|
12
13
|
export declare function getPythonInferenceSnippet(model: ModelDataMinimal, accessToken: string): string;
|
|
13
14
|
export declare function hasPythonInferenceSnippet(model: ModelDataMinimal): boolean;
|
|
14
15
|
//# sourceMappingURL=python.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../../src/snippets/python.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,eAAO,MAAM,6BAA6B,UAAW,gBAAgB,KAAG,MAQrE,CAAC;AAEJ,eAAO,MAAM,kCAAkC,UAAW,gBAAgB,KAAG,MAc1E,CAAC;AAEJ,eAAO,MAAM,YAAY,UAAW,gBAAgB,KAAG,MAOpD,CAAC;AAEJ,eAAO,MAAM,WAAW,UAAW,gBAAgB,KAAG,MAOP,CAAC;AAEhD,eAAO,MAAM,kBAAkB,UAAW,gBAAgB,KAAG,MAUjB,CAAC;AAE7C,eAAO,MAAM,cAAc,UAAW,gBAAgB,KAAG,MAMtD,CAAC;AAEJ,eAAO,MAAM,kBAAkB,UAAW,gBAAgB,KAAG,MA2B5D,CAAC;AAEF,eAAO,MAAM,gCAAgC,UAAW,gBAAgB,KAAG,MAUxE,CAAC;AAEJ,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../../src/snippets/python.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,eAAO,MAAM,qBAAqB,UAAW,gBAAgB,eAAe,MAAM,KAAG,MAcpF,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAAW,gBAAgB,KAAG,MAQrE,CAAC;AAEJ,eAAO,MAAM,kCAAkC,UAAW,gBAAgB,KAAG,MAc1E,CAAC;AAEJ,eAAO,MAAM,YAAY,UAAW,gBAAgB,KAAG,MAOpD,CAAC;AAEJ,eAAO,MAAM,WAAW,UAAW,gBAAgB,KAAG,MAOP,CAAC;AAEhD,eAAO,MAAM,kBAAkB,UAAW,gBAAgB,KAAG,MAUjB,CAAC;AAE7C,eAAO,MAAM,cAAc,UAAW,gBAAgB,KAAG,MAMtD,CAAC;AAEJ,eAAO,MAAM,kBAAkB,UAAW,gBAAgB,KAAG,MA2B5D,CAAC;AAEF,eAAO,MAAM,gCAAgC,UAAW,gBAAgB,KAAG,MAUxE,CAAC;AAEJ,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC,CA4BlH,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAiB9F;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAE1E"}
|
|
@@ -4,5 +4,5 @@ import type { ModelData } from "../model-data";
|
|
|
4
4
|
*
|
|
5
5
|
* Add more fields as needed.
|
|
6
6
|
*/
|
|
7
|
-
export type ModelDataMinimal = Pick<ModelData, "id" | "pipeline_tag" | "mask_token" | "library_name">;
|
|
7
|
+
export type ModelDataMinimal = Pick<ModelData, "id" | "pipeline_tag" | "mask_token" | "library_name" | "config">;
|
|
8
8
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/snippets/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,cAAc,GAAG,YAAY,GAAG,cAAc,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/snippets/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,cAAc,GAAG,YAAY,GAAG,cAAc,GAAG,QAAQ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huggingface/tasks",
|
|
3
3
|
"packageManager": "pnpm@8.10.5",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.21",
|
|
5
5
|
"description": "List of ML tasks for huggingface.co/tasks",
|
|
6
6
|
"repository": "https://github.com/huggingface/huggingface.js.git",
|
|
7
7
|
"publishConfig": {
|
package/src/local-apps.ts
CHANGED
|
@@ -32,14 +32,14 @@ export type LocalApp = {
|
|
|
32
32
|
/**
|
|
33
33
|
* If the app supports deeplink, URL to open.
|
|
34
34
|
*/
|
|
35
|
-
deeplink: (model: ModelData) => URL;
|
|
35
|
+
deeplink: (model: ModelData, filepath?: string) => URL;
|
|
36
36
|
}
|
|
37
37
|
| {
|
|
38
38
|
/**
|
|
39
39
|
* And if not (mostly llama.cpp), snippet to copy/paste in your terminal
|
|
40
40
|
* Support the placeholder {{GGUF_FILE}} that will be replaced by the gguf file path or the list of available files.
|
|
41
41
|
*/
|
|
42
|
-
snippet: (model: ModelData) => string | string[];
|
|
42
|
+
snippet: (model: ModelData, filepath?: string) => string | string[];
|
|
43
43
|
}
|
|
44
44
|
);
|
|
45
45
|
|
|
@@ -47,7 +47,7 @@ function isGgufModel(model: ModelData) {
|
|
|
47
47
|
return model.tags.includes("gguf");
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const snippetLlamacpp = (model: ModelData): string[] => {
|
|
50
|
+
const snippetLlamacpp = (model: ModelData, filepath?: string): string[] => {
|
|
51
51
|
return [
|
|
52
52
|
`# Option 1: use llama.cpp with brew
|
|
53
53
|
brew install llama.cpp
|
|
@@ -55,7 +55,7 @@ brew install llama.cpp
|
|
|
55
55
|
# Load and run the model
|
|
56
56
|
llama \\
|
|
57
57
|
--hf-repo "${model.id}" \\
|
|
58
|
-
--hf-file {{GGUF_FILE}} \\
|
|
58
|
+
--hf-file ${filepath ?? "{{GGUF_FILE}}"} \\
|
|
59
59
|
-p "I believe the meaning of life is" \\
|
|
60
60
|
-n 128`,
|
|
61
61
|
`# Option 2: build llama.cpp from source with curl support
|
|
@@ -66,7 +66,7 @@ LLAMA_CURL=1 make
|
|
|
66
66
|
# Load and run the model
|
|
67
67
|
./main \\
|
|
68
68
|
--hf-repo "${model.id}" \\
|
|
69
|
-
-m {{GGUF_FILE}} \\
|
|
69
|
+
-m ${filepath ?? "{{GGUF_FILE}}"} \\
|
|
70
70
|
-p "I believe the meaning of life is" \\
|
|
71
71
|
-n 128`,
|
|
72
72
|
];
|
|
@@ -96,7 +96,8 @@ export const LOCAL_APPS = {
|
|
|
96
96
|
docsUrl: "https://lmstudio.ai",
|
|
97
97
|
mainTask: "text-generation",
|
|
98
98
|
displayOnModelPage: isGgufModel,
|
|
99
|
-
deeplink: (model) =>
|
|
99
|
+
deeplink: (model, filepath) =>
|
|
100
|
+
new URL(`lmstudio://open_from_hf?model=${model.id}${filepath ? `&file=${filepath}` : ""}`),
|
|
100
101
|
},
|
|
101
102
|
jan: {
|
|
102
103
|
prettyLabel: "Jan",
|
package/src/model-libraries.ts
CHANGED
|
@@ -214,6 +214,13 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
|
|
|
214
214
|
filter: false,
|
|
215
215
|
countDownloads: `path:"gliner_config.json"`,
|
|
216
216
|
},
|
|
217
|
+
"glyph-byt5": {
|
|
218
|
+
prettyLabel: "Glyph-ByT5",
|
|
219
|
+
repoName: "Glyph-ByT5",
|
|
220
|
+
repoUrl: "https://github.com/AIGText/Glyph-ByT5",
|
|
221
|
+
filter: false,
|
|
222
|
+
countDownloads: `path:"checkpoints/byt5_model.pt"`,
|
|
223
|
+
},
|
|
217
224
|
grok: {
|
|
218
225
|
prettyLabel: "Grok",
|
|
219
226
|
repoName: "Grok",
|
package/src/snippets/curl.ts
CHANGED
|
@@ -10,6 +10,24 @@ export const snippetBasic = (model: ModelDataMinimal, accessToken: string): stri
|
|
|
10
10
|
-H "Authorization: Bearer ${accessToken || `{API_TOKEN}`}"
|
|
11
11
|
`;
|
|
12
12
|
|
|
13
|
+
export const snippetTextGeneration = (model: ModelDataMinimal, accessToken: string): string => {
|
|
14
|
+
if (model.config?.tokenizer_config?.chat_template) {
|
|
15
|
+
// Conversational model detected, so we display a code snippet that features the Messages API
|
|
16
|
+
return `curl 'https://api-inference.huggingface.co/models/${model.id}/v1/chat/completions' \\
|
|
17
|
+
-H "Authorization: Bearer ${accessToken || `{API_TOKEN}`}" \\
|
|
18
|
+
-H 'Content-Type: application/json' \\
|
|
19
|
+
-d '{
|
|
20
|
+
"model": "${model.id}",
|
|
21
|
+
"messages": [{"role": "user", "content": "What is the capital of France?"}],
|
|
22
|
+
"max_tokens": 500,
|
|
23
|
+
"stream": false
|
|
24
|
+
}'
|
|
25
|
+
`;
|
|
26
|
+
} else {
|
|
27
|
+
return snippetBasic(model, accessToken);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
13
31
|
export const snippetZeroShotClassification = (model: ModelDataMinimal, accessToken: string): string =>
|
|
14
32
|
`curl https://api-inference.huggingface.co/models/${model.id} \\
|
|
15
33
|
-X POST \\
|
|
@@ -35,7 +53,7 @@ export const curlSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal
|
|
|
35
53
|
translation: snippetBasic,
|
|
36
54
|
summarization: snippetBasic,
|
|
37
55
|
"feature-extraction": snippetBasic,
|
|
38
|
-
"text-generation":
|
|
56
|
+
"text-generation": snippetTextGeneration,
|
|
39
57
|
"text2text-generation": snippetBasic,
|
|
40
58
|
"fill-mask": snippetBasic,
|
|
41
59
|
"sentence-similarity": snippetBasic,
|
package/src/snippets/inputs.ts
CHANGED
|
@@ -11,30 +11,30 @@ const inputsSummarization = () =>
|
|
|
11
11
|
|
|
12
12
|
const inputsTableQuestionAnswering = () =>
|
|
13
13
|
`{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
"query": "How many stars does the transformers repository have?",
|
|
15
|
+
"table": {
|
|
16
|
+
"Repository": ["Transformers", "Datasets", "Tokenizers"],
|
|
17
|
+
"Stars": ["36542", "4512", "3934"],
|
|
18
|
+
"Contributors": ["651", "77", "34"],
|
|
19
|
+
"Programming language": [
|
|
20
|
+
"Python",
|
|
21
|
+
"Python",
|
|
22
|
+
"Rust, Python and NodeJS"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}`;
|
|
26
26
|
|
|
27
27
|
const inputsVisualQuestionAnswering = () =>
|
|
28
28
|
`{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
"image": "cat.png",
|
|
30
|
+
"question": "What is in this image?"
|
|
31
|
+
}`;
|
|
32
32
|
|
|
33
33
|
const inputsQuestionAnswering = () =>
|
|
34
34
|
`{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
"question": "What is my name?",
|
|
36
|
+
"context": "My name is Clara and I live in Berkeley."
|
|
37
|
+
}`;
|
|
38
38
|
|
|
39
39
|
const inputsTextClassification = () => `"I like you. I love you"`;
|
|
40
40
|
|
|
@@ -48,13 +48,13 @@ const inputsFillMask = (model: ModelDataMinimal) => `"The answer to the universe
|
|
|
48
48
|
|
|
49
49
|
const inputsSentenceSimilarity = () =>
|
|
50
50
|
`{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
"source_sentence": "That is a happy person",
|
|
52
|
+
"sentences": [
|
|
53
|
+
"That is a happy dog",
|
|
54
|
+
"That is a very happy person",
|
|
55
|
+
"Today is a sunny day"
|
|
56
|
+
]
|
|
57
|
+
}`;
|
|
58
58
|
|
|
59
59
|
const inputsFeatureExtraction = () => `"Today is a sunny day and I will get some ice cream."`;
|
|
60
60
|
|
package/src/snippets/js.ts
CHANGED
|
@@ -7,7 +7,10 @@ export const snippetBasic = (model: ModelDataMinimal, accessToken: string): stri
|
|
|
7
7
|
const response = await fetch(
|
|
8
8
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
9
9
|
{
|
|
10
|
-
headers: {
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
12
|
+
"Content-Type": "application/json",
|
|
13
|
+
},
|
|
11
14
|
method: "POST",
|
|
12
15
|
body: JSON.stringify(data),
|
|
13
16
|
}
|
|
@@ -20,12 +23,34 @@ query({"inputs": ${getModelInputSnippet(model)}}).then((response) => {
|
|
|
20
23
|
console.log(JSON.stringify(response));
|
|
21
24
|
});`;
|
|
22
25
|
|
|
26
|
+
export const snippetTextGeneration = (model: ModelDataMinimal, accessToken: string): string => {
|
|
27
|
+
if (model.config?.tokenizer_config?.chat_template) {
|
|
28
|
+
// Conversational model detected, so we display a code snippet that features the Messages API
|
|
29
|
+
return `import { HfInference } from "@huggingface/inference";
|
|
30
|
+
|
|
31
|
+
const inference = new HfInference("${accessToken || `{API_TOKEN}`}");
|
|
32
|
+
|
|
33
|
+
for await (const chunk of inference.chatCompletionStream({
|
|
34
|
+
model: "${model.id}",
|
|
35
|
+
messages: [{ role: "user", content: "What is the capital of France?" }],
|
|
36
|
+
max_tokens: 500,
|
|
37
|
+
})) {
|
|
38
|
+
process.stdout.write(chunk.choices[0]?.delta?.content || "");
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
} else {
|
|
42
|
+
return snippetBasic(model, accessToken);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
23
45
|
export const snippetZeroShotClassification = (model: ModelDataMinimal, accessToken: string): string =>
|
|
24
46
|
`async function query(data) {
|
|
25
47
|
const response = await fetch(
|
|
26
48
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
27
49
|
{
|
|
28
|
-
headers: {
|
|
50
|
+
headers: {
|
|
51
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
52
|
+
"Content-Type": "application/json",
|
|
53
|
+
},
|
|
29
54
|
method: "POST",
|
|
30
55
|
body: JSON.stringify(data),
|
|
31
56
|
}
|
|
@@ -45,7 +70,10 @@ export const snippetTextToImage = (model: ModelDataMinimal, accessToken: string)
|
|
|
45
70
|
const response = await fetch(
|
|
46
71
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
47
72
|
{
|
|
48
|
-
headers: {
|
|
73
|
+
headers: {
|
|
74
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
75
|
+
"Content-Type": "application/json",
|
|
76
|
+
},
|
|
49
77
|
method: "POST",
|
|
50
78
|
body: JSON.stringify(data),
|
|
51
79
|
}
|
|
@@ -62,7 +90,10 @@ export const snippetTextToAudio = (model: ModelDataMinimal, accessToken: string)
|
|
|
62
90
|
const response = await fetch(
|
|
63
91
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
64
92
|
{
|
|
65
|
-
headers: {
|
|
93
|
+
headers: {
|
|
94
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
95
|
+
"Content-Type": "application/json",
|
|
96
|
+
},
|
|
66
97
|
method: "POST",
|
|
67
98
|
body: JSON.stringify(data),
|
|
68
99
|
}
|
|
@@ -99,7 +130,10 @@ export const snippetFile = (model: ModelDataMinimal, accessToken: string): strin
|
|
|
99
130
|
const response = await fetch(
|
|
100
131
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
101
132
|
{
|
|
102
|
-
headers: {
|
|
133
|
+
headers: {
|
|
134
|
+
Authorization: "Bearer ${accessToken || `{API_TOKEN}`}"
|
|
135
|
+
"Content-Type": "application/json",
|
|
136
|
+
},
|
|
103
137
|
method: "POST",
|
|
104
138
|
body: data,
|
|
105
139
|
}
|
|
@@ -122,7 +156,7 @@ export const jsSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal,
|
|
|
122
156
|
translation: snippetBasic,
|
|
123
157
|
summarization: snippetBasic,
|
|
124
158
|
"feature-extraction": snippetBasic,
|
|
125
|
-
"text-generation":
|
|
159
|
+
"text-generation": snippetTextGeneration,
|
|
126
160
|
"text2text-generation": snippetBasic,
|
|
127
161
|
"fill-mask": snippetBasic,
|
|
128
162
|
"sentence-similarity": snippetBasic,
|
package/src/snippets/python.ts
CHANGED
|
@@ -2,6 +2,22 @@ import type { PipelineType } from "../pipelines.js";
|
|
|
2
2
|
import { getModelInputSnippet } from "./inputs.js";
|
|
3
3
|
import type { ModelDataMinimal } from "./types.js";
|
|
4
4
|
|
|
5
|
+
export const snippetConversational = (model: ModelDataMinimal, accessToken: string): string =>
|
|
6
|
+
`from huggingface_hub import InferenceClient
|
|
7
|
+
|
|
8
|
+
client = InferenceClient(
|
|
9
|
+
"${model.id}",
|
|
10
|
+
token="${accessToken || "{API_TOKEN}"}",
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
for message in client.chat_completion(
|
|
14
|
+
messages=[{"role": "user", "content": "What is the capital of France?"}],
|
|
15
|
+
max_tokens=500,
|
|
16
|
+
stream=True,
|
|
17
|
+
):
|
|
18
|
+
print(message.choices[0].delta.content, end="")
|
|
19
|
+
`;
|
|
20
|
+
|
|
5
21
|
export const snippetZeroShotClassification = (model: ModelDataMinimal): string =>
|
|
6
22
|
`def query(payload):
|
|
7
23
|
response = requests.post(API_URL, headers=headers, json=payload)
|
|
@@ -107,7 +123,7 @@ output = query({
|
|
|
107
123
|
"inputs": ${getModelInputSnippet(model)},
|
|
108
124
|
})`;
|
|
109
125
|
|
|
110
|
-
export const pythonSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal) => string>> = {
|
|
126
|
+
export const pythonSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal, accessToken: string) => string>> = {
|
|
111
127
|
// Same order as in tasks/src/pipelines.ts
|
|
112
128
|
"text-classification": snippetBasic,
|
|
113
129
|
"token-classification": snippetBasic,
|
|
@@ -138,15 +154,22 @@ export const pythonSnippets: Partial<Record<PipelineType, (model: ModelDataMinim
|
|
|
138
154
|
};
|
|
139
155
|
|
|
140
156
|
export function getPythonInferenceSnippet(model: ModelDataMinimal, accessToken: string): string {
|
|
141
|
-
|
|
142
|
-
|
|
157
|
+
if (model.pipeline_tag === "text-generation" && model.config?.tokenizer_config?.chat_template) {
|
|
158
|
+
// Conversational model detected, so we display a code snippet that features the Messages API
|
|
159
|
+
return snippetConversational(model, accessToken);
|
|
160
|
+
} else {
|
|
161
|
+
const body =
|
|
162
|
+
model.pipeline_tag && model.pipeline_tag in pythonSnippets
|
|
163
|
+
? pythonSnippets[model.pipeline_tag]?.(model, accessToken) ?? ""
|
|
164
|
+
: "";
|
|
143
165
|
|
|
144
|
-
|
|
166
|
+
return `import requests
|
|
145
167
|
|
|
146
168
|
API_URL = "https://api-inference.huggingface.co/models/${model.id}"
|
|
147
169
|
headers = {"Authorization": ${accessToken ? `"Bearer ${accessToken}"` : `f"Bearer {API_TOKEN}"`}}
|
|
148
170
|
|
|
149
171
|
${body}`;
|
|
172
|
+
}
|
|
150
173
|
}
|
|
151
174
|
|
|
152
175
|
export function hasPythonInferenceSnippet(model: ModelDataMinimal): boolean {
|
package/src/snippets/types.ts
CHANGED
|
@@ -5,4 +5,4 @@ import type { ModelData } from "../model-data";
|
|
|
5
5
|
*
|
|
6
6
|
* Add more fields as needed.
|
|
7
7
|
*/
|
|
8
|
-
export type ModelDataMinimal = Pick<ModelData, "id" | "pipeline_tag" | "mask_token" | "library_name">;
|
|
8
|
+
export type ModelDataMinimal = Pick<ModelData, "id" | "pipeline_tag" | "mask_token" | "library_name" | "config">;
|