@huggingface/tasks 0.5.0 → 0.5.2
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.d.ts +34 -27
- package/package.json +1 -1
- package/src/snippets/curl.ts +7 -7
- package/src/snippets/inputs.ts +4 -4
- package/src/snippets/js.ts +9 -9
- package/src/snippets/python.ts +12 -12
- package/src/snippets/types.ts +8 -0
- package/src/tokenizer-data.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -500,7 +500,7 @@ interface AddedToken {
|
|
|
500
500
|
single_word?: boolean;
|
|
501
501
|
}
|
|
502
502
|
type SpecialTokensMap = {
|
|
503
|
-
[key in (typeof SPECIAL_TOKENS_ATTRIBUTES)[number]]?: string | AddedToken;
|
|
503
|
+
[key in (typeof SPECIAL_TOKENS_ATTRIBUTES)[number]]?: string | AddedToken | null;
|
|
504
504
|
};
|
|
505
505
|
/**
|
|
506
506
|
* Public interface for tokenizer config
|
|
@@ -3149,7 +3149,14 @@ interface TaskData {
|
|
|
3149
3149
|
}
|
|
3150
3150
|
type TaskDataCustom = Omit<TaskData, "id" | "label" | "libraries">;
|
|
3151
3151
|
|
|
3152
|
-
|
|
3152
|
+
/**
|
|
3153
|
+
* Minimal model data required for snippets.
|
|
3154
|
+
*
|
|
3155
|
+
* Add more fields as needed.
|
|
3156
|
+
*/
|
|
3157
|
+
type ModelDataMinimal = Pick<ModelData, "id" | "pipeline_tag" | "mask_token" | "library_name">;
|
|
3158
|
+
|
|
3159
|
+
declare function getModelInputSnippet(model: ModelDataMinimal, noWrap?: boolean, noQuotes?: boolean): string;
|
|
3153
3160
|
|
|
3154
3161
|
declare const inputs_getModelInputSnippet: typeof getModelInputSnippet;
|
|
3155
3162
|
declare namespace inputs {
|
|
@@ -3158,12 +3165,12 @@ declare namespace inputs {
|
|
|
3158
3165
|
};
|
|
3159
3166
|
}
|
|
3160
3167
|
|
|
3161
|
-
declare const snippetBasic$2: (model:
|
|
3162
|
-
declare const snippetZeroShotClassification$2: (model:
|
|
3163
|
-
declare const snippetFile$2: (model:
|
|
3164
|
-
declare const curlSnippets: Partial<Record<PipelineType, (model:
|
|
3165
|
-
declare function getCurlInferenceSnippet(model:
|
|
3166
|
-
declare function hasCurlInferenceSnippet(model:
|
|
3168
|
+
declare const snippetBasic$2: (model: ModelDataMinimal, accessToken: string) => string;
|
|
3169
|
+
declare const snippetZeroShotClassification$2: (model: ModelDataMinimal, accessToken: string) => string;
|
|
3170
|
+
declare const snippetFile$2: (model: ModelDataMinimal, accessToken: string) => string;
|
|
3171
|
+
declare const curlSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal, accessToken: string) => string>>;
|
|
3172
|
+
declare function getCurlInferenceSnippet(model: ModelDataMinimal, accessToken: string): string;
|
|
3173
|
+
declare function hasCurlInferenceSnippet(model: Pick<ModelDataMinimal, "pipeline_tag">): boolean;
|
|
3167
3174
|
|
|
3168
3175
|
declare const curl_curlSnippets: typeof curlSnippets;
|
|
3169
3176
|
declare const curl_getCurlInferenceSnippet: typeof getCurlInferenceSnippet;
|
|
@@ -3179,17 +3186,17 @@ declare namespace curl {
|
|
|
3179
3186
|
};
|
|
3180
3187
|
}
|
|
3181
3188
|
|
|
3182
|
-
declare const snippetZeroShotClassification$1: (model:
|
|
3183
|
-
declare const snippetZeroShotImageClassification: (model:
|
|
3184
|
-
declare const snippetBasic$1: (model:
|
|
3185
|
-
declare const snippetFile$1: (model:
|
|
3186
|
-
declare const snippetTextToImage$1: (model:
|
|
3187
|
-
declare const snippetTabular: (model:
|
|
3188
|
-
declare const snippetTextToAudio$1: (model:
|
|
3189
|
-
declare const snippetDocumentQuestionAnswering: (model:
|
|
3190
|
-
declare const pythonSnippets: Partial<Record<PipelineType, (model:
|
|
3191
|
-
declare function getPythonInferenceSnippet(model:
|
|
3192
|
-
declare function hasPythonInferenceSnippet(model:
|
|
3189
|
+
declare const snippetZeroShotClassification$1: (model: ModelDataMinimal) => string;
|
|
3190
|
+
declare const snippetZeroShotImageClassification: (model: ModelDataMinimal) => string;
|
|
3191
|
+
declare const snippetBasic$1: (model: ModelDataMinimal) => string;
|
|
3192
|
+
declare const snippetFile$1: (model: ModelDataMinimal) => string;
|
|
3193
|
+
declare const snippetTextToImage$1: (model: ModelDataMinimal) => string;
|
|
3194
|
+
declare const snippetTabular: (model: ModelDataMinimal) => string;
|
|
3195
|
+
declare const snippetTextToAudio$1: (model: ModelDataMinimal) => string;
|
|
3196
|
+
declare const snippetDocumentQuestionAnswering: (model: ModelDataMinimal) => string;
|
|
3197
|
+
declare const pythonSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal) => string>>;
|
|
3198
|
+
declare function getPythonInferenceSnippet(model: ModelDataMinimal, accessToken: string): string;
|
|
3199
|
+
declare function hasPythonInferenceSnippet(model: ModelDataMinimal): boolean;
|
|
3193
3200
|
|
|
3194
3201
|
declare const python_getPythonInferenceSnippet: typeof getPythonInferenceSnippet;
|
|
3195
3202
|
declare const python_hasPythonInferenceSnippet: typeof hasPythonInferenceSnippet;
|
|
@@ -3213,14 +3220,14 @@ declare namespace python {
|
|
|
3213
3220
|
};
|
|
3214
3221
|
}
|
|
3215
3222
|
|
|
3216
|
-
declare const snippetBasic: (model:
|
|
3217
|
-
declare const snippetZeroShotClassification: (model:
|
|
3218
|
-
declare const snippetTextToImage: (model:
|
|
3219
|
-
declare const snippetTextToAudio: (model:
|
|
3220
|
-
declare const snippetFile: (model:
|
|
3221
|
-
declare const jsSnippets: Partial<Record<PipelineType, (model:
|
|
3222
|
-
declare function getJsInferenceSnippet(model:
|
|
3223
|
-
declare function hasJsInferenceSnippet(model:
|
|
3223
|
+
declare const snippetBasic: (model: ModelDataMinimal, accessToken: string) => string;
|
|
3224
|
+
declare const snippetZeroShotClassification: (model: ModelDataMinimal, accessToken: string) => string;
|
|
3225
|
+
declare const snippetTextToImage: (model: ModelDataMinimal, accessToken: string) => string;
|
|
3226
|
+
declare const snippetTextToAudio: (model: ModelDataMinimal, accessToken: string) => string;
|
|
3227
|
+
declare const snippetFile: (model: ModelDataMinimal, accessToken: string) => string;
|
|
3228
|
+
declare const jsSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal, accessToken: string) => string>>;
|
|
3229
|
+
declare function getJsInferenceSnippet(model: ModelDataMinimal, accessToken: string): string;
|
|
3230
|
+
declare function hasJsInferenceSnippet(model: ModelDataMinimal): boolean;
|
|
3224
3231
|
|
|
3225
3232
|
declare const js_getJsInferenceSnippet: typeof getJsInferenceSnippet;
|
|
3226
3233
|
declare const js_hasJsInferenceSnippet: typeof hasJsInferenceSnippet;
|
package/package.json
CHANGED
package/src/snippets/curl.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ModelData } from "../model-data.js";
|
|
2
1
|
import type { PipelineType } from "../pipelines.js";
|
|
3
2
|
import { getModelInputSnippet } from "./inputs.js";
|
|
3
|
+
import type { ModelDataMinimal } from "./types.js";
|
|
4
4
|
|
|
5
|
-
export const snippetBasic = (model:
|
|
5
|
+
export const snippetBasic = (model: ModelDataMinimal, accessToken: string): string =>
|
|
6
6
|
`curl https://api-inference.huggingface.co/models/${model.id} \\
|
|
7
7
|
-X POST \\
|
|
8
8
|
-d '{"inputs": ${getModelInputSnippet(model, true)}}' \\
|
|
@@ -10,7 +10,7 @@ export const snippetBasic = (model: ModelData, accessToken: string): string =>
|
|
|
10
10
|
-H "Authorization: Bearer ${accessToken || `{API_TOKEN}`}"
|
|
11
11
|
`;
|
|
12
12
|
|
|
13
|
-
export const snippetZeroShotClassification = (model:
|
|
13
|
+
export const snippetZeroShotClassification = (model: ModelDataMinimal, accessToken: string): string =>
|
|
14
14
|
`curl https://api-inference.huggingface.co/models/${model.id} \\
|
|
15
15
|
-X POST \\
|
|
16
16
|
-d '{"inputs": ${getModelInputSnippet(model, true)}, "parameters": {"candidate_labels": ["refund", "legal", "faq"]}}' \\
|
|
@@ -18,14 +18,14 @@ export const snippetZeroShotClassification = (model: ModelData, accessToken: str
|
|
|
18
18
|
-H "Authorization: Bearer ${accessToken || `{API_TOKEN}`}"
|
|
19
19
|
`;
|
|
20
20
|
|
|
21
|
-
export const snippetFile = (model:
|
|
21
|
+
export const snippetFile = (model: ModelDataMinimal, accessToken: string): string =>
|
|
22
22
|
`curl https://api-inference.huggingface.co/models/${model.id} \\
|
|
23
23
|
-X POST \\
|
|
24
24
|
--data-binary '@${getModelInputSnippet(model, true, true)}' \\
|
|
25
25
|
-H "Authorization: Bearer ${accessToken || `{API_TOKEN}`}"
|
|
26
26
|
`;
|
|
27
27
|
|
|
28
|
-
export const curlSnippets: Partial<Record<PipelineType, (model:
|
|
28
|
+
export const curlSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal, accessToken: string) => string>> = {
|
|
29
29
|
// Same order as in js/src/lib/interfaces/Types.ts
|
|
30
30
|
"text-classification": snippetBasic,
|
|
31
31
|
"token-classification": snippetBasic,
|
|
@@ -51,12 +51,12 @@ export const curlSnippets: Partial<Record<PipelineType, (model: ModelData, acces
|
|
|
51
51
|
"image-segmentation": snippetFile,
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
export function getCurlInferenceSnippet(model:
|
|
54
|
+
export function getCurlInferenceSnippet(model: ModelDataMinimal, accessToken: string): string {
|
|
55
55
|
return model.pipeline_tag && model.pipeline_tag in curlSnippets
|
|
56
56
|
? curlSnippets[model.pipeline_tag]?.(model, accessToken) ?? ""
|
|
57
57
|
: "";
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export function hasCurlInferenceSnippet(model:
|
|
60
|
+
export function hasCurlInferenceSnippet(model: Pick<ModelDataMinimal, "pipeline_tag">): boolean {
|
|
61
61
|
return !!model.pipeline_tag && model.pipeline_tag in curlSnippets;
|
|
62
62
|
}
|
package/src/snippets/inputs.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ModelData } from "../model-data";
|
|
2
1
|
import type { PipelineType } from "../pipelines";
|
|
2
|
+
import type { ModelDataMinimal } from "./types";
|
|
3
3
|
|
|
4
4
|
const inputsZeroShotClassification = () =>
|
|
5
5
|
`"Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!"`;
|
|
@@ -44,7 +44,7 @@ const inputsTextGeneration = () => `"Can you please let us know more details abo
|
|
|
44
44
|
|
|
45
45
|
const inputsText2TextGeneration = () => `"The answer to the universe is"`;
|
|
46
46
|
|
|
47
|
-
const inputsFillMask = (model:
|
|
47
|
+
const inputsFillMask = (model: ModelDataMinimal) => `"The answer to the universe is ${model.mask_token}."`;
|
|
48
48
|
|
|
49
49
|
const inputsSentenceSimilarity = () =>
|
|
50
50
|
`{
|
|
@@ -84,7 +84,7 @@ const inputsTabularPrediction = () =>
|
|
|
84
84
|
const inputsZeroShotImageClassification = () => `"cats.jpg"`;
|
|
85
85
|
|
|
86
86
|
const modelInputSnippets: {
|
|
87
|
-
[key in PipelineType]?: (model:
|
|
87
|
+
[key in PipelineType]?: (model: ModelDataMinimal) => string;
|
|
88
88
|
} = {
|
|
89
89
|
"audio-to-audio": inputsAudioToAudio,
|
|
90
90
|
"audio-classification": inputsAudioClassification,
|
|
@@ -116,7 +116,7 @@ const modelInputSnippets: {
|
|
|
116
116
|
|
|
117
117
|
// Use noWrap to put the whole snippet on a single line (removing new lines and tabulations)
|
|
118
118
|
// Use noQuotes to strip quotes from start & end (example: "abc" -> abc)
|
|
119
|
-
export function getModelInputSnippet(model:
|
|
119
|
+
export function getModelInputSnippet(model: ModelDataMinimal, noWrap = false, noQuotes = false): string {
|
|
120
120
|
if (model.pipeline_tag) {
|
|
121
121
|
const inputs = modelInputSnippets[model.pipeline_tag];
|
|
122
122
|
if (inputs) {
|
package/src/snippets/js.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ModelData } from "../model-data.js";
|
|
2
1
|
import type { PipelineType } from "../pipelines.js";
|
|
3
2
|
import { getModelInputSnippet } from "./inputs.js";
|
|
3
|
+
import type { ModelDataMinimal } from "./types.js";
|
|
4
4
|
|
|
5
|
-
export const snippetBasic = (model:
|
|
5
|
+
export const snippetBasic = (model: ModelDataMinimal, accessToken: string): string =>
|
|
6
6
|
`async function query(data) {
|
|
7
7
|
const response = await fetch(
|
|
8
8
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
@@ -20,7 +20,7 @@ query({"inputs": ${getModelInputSnippet(model)}}).then((response) => {
|
|
|
20
20
|
console.log(JSON.stringify(response));
|
|
21
21
|
});`;
|
|
22
22
|
|
|
23
|
-
export const snippetZeroShotClassification = (model:
|
|
23
|
+
export const snippetZeroShotClassification = (model: ModelDataMinimal, accessToken: string): string =>
|
|
24
24
|
`async function query(data) {
|
|
25
25
|
const response = await fetch(
|
|
26
26
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
@@ -40,7 +40,7 @@ query({"inputs": ${getModelInputSnippet(
|
|
|
40
40
|
console.log(JSON.stringify(response));
|
|
41
41
|
});`;
|
|
42
42
|
|
|
43
|
-
export const snippetTextToImage = (model:
|
|
43
|
+
export const snippetTextToImage = (model: ModelDataMinimal, accessToken: string): string =>
|
|
44
44
|
`async function query(data) {
|
|
45
45
|
const response = await fetch(
|
|
46
46
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
@@ -57,7 +57,7 @@ query({"inputs": ${getModelInputSnippet(model)}}).then((response) => {
|
|
|
57
57
|
// Use image
|
|
58
58
|
});`;
|
|
59
59
|
|
|
60
|
-
export const snippetTextToAudio = (model:
|
|
60
|
+
export const snippetTextToAudio = (model: ModelDataMinimal, accessToken: string): string => {
|
|
61
61
|
const commonSnippet = `async function query(data) {
|
|
62
62
|
const response = await fetch(
|
|
63
63
|
"https://api-inference.huggingface.co/models/${model.id}",
|
|
@@ -93,7 +93,7 @@ export const snippetTextToAudio = (model: ModelData, accessToken: string): strin
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
export const snippetFile = (model:
|
|
96
|
+
export const snippetFile = (model: ModelDataMinimal, accessToken: string): string =>
|
|
97
97
|
`async function query(filename) {
|
|
98
98
|
const data = fs.readFileSync(filename);
|
|
99
99
|
const response = await fetch(
|
|
@@ -112,7 +112,7 @@ query(${getModelInputSnippet(model)}).then((response) => {
|
|
|
112
112
|
console.log(JSON.stringify(response));
|
|
113
113
|
});`;
|
|
114
114
|
|
|
115
|
-
export const jsSnippets: Partial<Record<PipelineType, (model:
|
|
115
|
+
export const jsSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal, accessToken: string) => string>> = {
|
|
116
116
|
// Same order as in js/src/lib/interfaces/Types.ts
|
|
117
117
|
"text-classification": snippetBasic,
|
|
118
118
|
"token-classification": snippetBasic,
|
|
@@ -138,12 +138,12 @@ export const jsSnippets: Partial<Record<PipelineType, (model: ModelData, accessT
|
|
|
138
138
|
"image-segmentation": snippetFile,
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
export function getJsInferenceSnippet(model:
|
|
141
|
+
export function getJsInferenceSnippet(model: ModelDataMinimal, accessToken: string): string {
|
|
142
142
|
return model.pipeline_tag && model.pipeline_tag in jsSnippets
|
|
143
143
|
? jsSnippets[model.pipeline_tag]?.(model, accessToken) ?? ""
|
|
144
144
|
: "";
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
export function hasJsInferenceSnippet(model:
|
|
147
|
+
export function hasJsInferenceSnippet(model: ModelDataMinimal): boolean {
|
|
148
148
|
return !!model.pipeline_tag && model.pipeline_tag in jsSnippets;
|
|
149
149
|
}
|
package/src/snippets/python.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ModelData } from "../model-data.js";
|
|
2
1
|
import type { PipelineType } from "../pipelines.js";
|
|
3
2
|
import { getModelInputSnippet } from "./inputs.js";
|
|
3
|
+
import type { ModelDataMinimal } from "./types.js";
|
|
4
4
|
|
|
5
|
-
export const snippetZeroShotClassification = (model:
|
|
5
|
+
export const snippetZeroShotClassification = (model: ModelDataMinimal): string =>
|
|
6
6
|
`def query(payload):
|
|
7
7
|
response = requests.post(API_URL, headers=headers, json=payload)
|
|
8
8
|
return response.json()
|
|
@@ -12,7 +12,7 @@ output = query({
|
|
|
12
12
|
"parameters": {"candidate_labels": ["refund", "legal", "faq"]},
|
|
13
13
|
})`;
|
|
14
14
|
|
|
15
|
-
export const snippetZeroShotImageClassification = (model:
|
|
15
|
+
export const snippetZeroShotImageClassification = (model: ModelDataMinimal): string =>
|
|
16
16
|
`def query(data):
|
|
17
17
|
with open(data["image_path"], "rb") as f:
|
|
18
18
|
img = f.read()
|
|
@@ -28,7 +28,7 @@ output = query({
|
|
|
28
28
|
"parameters": {"candidate_labels": ["cat", "dog", "llama"]},
|
|
29
29
|
})`;
|
|
30
30
|
|
|
31
|
-
export const snippetBasic = (model:
|
|
31
|
+
export const snippetBasic = (model: ModelDataMinimal): string =>
|
|
32
32
|
`def query(payload):
|
|
33
33
|
response = requests.post(API_URL, headers=headers, json=payload)
|
|
34
34
|
return response.json()
|
|
@@ -37,7 +37,7 @@ output = query({
|
|
|
37
37
|
"inputs": ${getModelInputSnippet(model)},
|
|
38
38
|
})`;
|
|
39
39
|
|
|
40
|
-
export const snippetFile = (model:
|
|
40
|
+
export const snippetFile = (model: ModelDataMinimal): string =>
|
|
41
41
|
`def query(filename):
|
|
42
42
|
with open(filename, "rb") as f:
|
|
43
43
|
data = f.read()
|
|
@@ -46,7 +46,7 @@ export const snippetFile = (model: ModelData): string =>
|
|
|
46
46
|
|
|
47
47
|
output = query(${getModelInputSnippet(model)})`;
|
|
48
48
|
|
|
49
|
-
export const snippetTextToImage = (model:
|
|
49
|
+
export const snippetTextToImage = (model: ModelDataMinimal): string =>
|
|
50
50
|
`def query(payload):
|
|
51
51
|
response = requests.post(API_URL, headers=headers, json=payload)
|
|
52
52
|
return response.content
|
|
@@ -58,7 +58,7 @@ import io
|
|
|
58
58
|
from PIL import Image
|
|
59
59
|
image = Image.open(io.BytesIO(image_bytes))`;
|
|
60
60
|
|
|
61
|
-
export const snippetTabular = (model:
|
|
61
|
+
export const snippetTabular = (model: ModelDataMinimal): string =>
|
|
62
62
|
`def query(payload):
|
|
63
63
|
response = requests.post(API_URL, headers=headers, json=payload)
|
|
64
64
|
return response.content
|
|
@@ -66,7 +66,7 @@ response = query({
|
|
|
66
66
|
"inputs": {"data": ${getModelInputSnippet(model)}},
|
|
67
67
|
})`;
|
|
68
68
|
|
|
69
|
-
export const snippetTextToAudio = (model:
|
|
69
|
+
export const snippetTextToAudio = (model: ModelDataMinimal): string => {
|
|
70
70
|
// Transformers TTS pipeline and api-inference-community (AIC) pipeline outputs are diverged
|
|
71
71
|
// with the latest update to inference-api (IA).
|
|
72
72
|
// Transformers IA returns a byte object (wav file), whereas AIC returns wav and sampling_rate.
|
|
@@ -95,7 +95,7 @@ Audio(audio, rate=sampling_rate)`;
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
export const snippetDocumentQuestionAnswering = (model:
|
|
98
|
+
export const snippetDocumentQuestionAnswering = (model: ModelDataMinimal): string =>
|
|
99
99
|
`def query(payload):
|
|
100
100
|
with open(payload["image"], "rb") as f:
|
|
101
101
|
img = f.read()
|
|
@@ -107,7 +107,7 @@ output = query({
|
|
|
107
107
|
"inputs": ${getModelInputSnippet(model)},
|
|
108
108
|
})`;
|
|
109
109
|
|
|
110
|
-
export const pythonSnippets: Partial<Record<PipelineType, (model:
|
|
110
|
+
export const pythonSnippets: Partial<Record<PipelineType, (model: ModelDataMinimal) => string>> = {
|
|
111
111
|
// Same order as in tasks/src/pipelines.ts
|
|
112
112
|
"text-classification": snippetBasic,
|
|
113
113
|
"token-classification": snippetBasic,
|
|
@@ -137,7 +137,7 @@ export const pythonSnippets: Partial<Record<PipelineType, (model: ModelData) =>
|
|
|
137
137
|
"zero-shot-image-classification": snippetZeroShotImageClassification,
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
-
export function getPythonInferenceSnippet(model:
|
|
140
|
+
export function getPythonInferenceSnippet(model: ModelDataMinimal, accessToken: string): string {
|
|
141
141
|
const body =
|
|
142
142
|
model.pipeline_tag && model.pipeline_tag in pythonSnippets ? pythonSnippets[model.pipeline_tag]?.(model) ?? "" : "";
|
|
143
143
|
|
|
@@ -149,6 +149,6 @@ headers = {"Authorization": ${accessToken ? `"Bearer ${accessToken}"` : `f"Beare
|
|
|
149
149
|
${body}`;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
export function hasPythonInferenceSnippet(model:
|
|
152
|
+
export function hasPythonInferenceSnippet(model: ModelDataMinimal): boolean {
|
|
153
153
|
return !!model.pipeline_tag && model.pipeline_tag in pythonSnippets;
|
|
154
154
|
}
|
package/src/tokenizer-data.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface AddedToken {
|
|
|
21
21
|
single_word?: boolean;
|
|
22
22
|
}
|
|
23
23
|
export type SpecialTokensMap = {
|
|
24
|
-
[key in (typeof SPECIAL_TOKENS_ATTRIBUTES)[number]]?: string | AddedToken;
|
|
24
|
+
[key in (typeof SPECIAL_TOKENS_ATTRIBUTES)[number]]?: string | AddedToken | null;
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
27
|
* Public interface for tokenizer config
|