Skip to content

Commit a4b1636

Browse files
committed
fix some JS code
1 parent 782078b commit a4b1636

File tree

12 files changed

+19
-11
lines changed

12 files changed

+19
-11
lines changed

packages/inference/src/snippets/getInferenceSnippets.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,14 @@ function replaceAccessTokenPlaceholder(
471471
`"${ACCESS_TOKEN_PLACEHOLDER}"`,
472472
`process.env.${accessTokenEnvVar}` // e.g. process.env.HF_TOKEN
473473
);
474+
snippet = snippet.replace(
475+
`Authorization: "Bearer ${ACCESS_TOKEN_PLACEHOLDER}",`,
476+
`Authorization: \`Bearer $\{process.env.${accessTokenEnvVar}}\`,` // e.g. Authorization: `Bearer ${process.env.HF_TOKEN}`,
477+
);
478+
snippet = snippet.replace(
479+
`Authorization: "Key ${ACCESS_TOKEN_PLACEHOLDER}",`,
480+
`Authorization: \`Key $\{process.env.${accessTokenEnvVar}}\`,` // e.g. Authorization: `Key ${process.env.FAL_AI_API_TOKEN}`,
481+
);
474482
}
475483
return snippet;
476484
}

packages/tasks-gen/snippets-fixtures/automatic-speech-recognition/js/fetch/0.hf-inference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ async function query(data) {
33
"https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3-turbo",
44
{
55
headers: {
6-
Authorization: "Bearer <ACCESS_TOKEN>",
6+
Authorization: `Bearer ${process.env.HF_TOKEN}`,
77
"Content-Type": "audio/flac",
88
},
99
method: "POST",

packages/tasks-gen/snippets-fixtures/basic-snippet--token-classification/js/fetch/0.hf-inference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ async function query(data) {
33
"https://router.huggingface.co/hf-inference/models/FacebookAI/xlm-roberta-large-finetuned-conll03-english",
44
{
55
headers: {
6-
Authorization: "Bearer <ACCESS_TOKEN>",
6+
Authorization: `Bearer ${process.env.HF_TOKEN}`,
77
"Content-Type": "application/json",
88
},
99
method: "POST",

packages/tasks-gen/snippets-fixtures/feature-extraction/js/fetch/0.hf-inference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ async function query(data) {
33
"https://router.huggingface.co/hf-inference/models/intfloat/multilingual-e5-large-instruct/pipeline/feature-extraction",
44
{
55
headers: {
6-
Authorization: "Bearer <ACCESS_TOKEN>",
6+
Authorization: `Bearer ${process.env.HF_TOKEN}`,
77
"Content-Type": "application/json",
88
},
99
method: "POST",

packages/tasks-gen/snippets-fixtures/image-classification/js/fetch/0.hf-inference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ async function query(data) {
33
"https://router.huggingface.co/hf-inference/models/Falconsai/nsfw_image_detection",
44
{
55
headers: {
6-
Authorization: "Bearer <ACCESS_TOKEN>",
6+
Authorization: `Bearer ${process.env.HF_TOKEN}`,
77
"Content-Type": "image/jpeg",
88
},
99
method: "POST",

packages/tasks-gen/snippets-fixtures/text-classification/js/fetch/0.hf-inference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ async function query(data) {
33
"https://router.huggingface.co/hf-inference/models/distilbert/distilbert-base-uncased-finetuned-sst-2-english",
44
{
55
headers: {
6-
Authorization: "Bearer <ACCESS_TOKEN>",
6+
Authorization: `Bearer ${process.env.HF_TOKEN}`,
77
"Content-Type": "application/json",
88
},
99
method: "POST",

packages/tasks-gen/snippets-fixtures/text-to-audio-transformers/js/fetch/0.hf-inference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ async function query(data) {
33
"https://router.huggingface.co/hf-inference/models/facebook/musicgen-small",
44
{
55
headers: {
6-
Authorization: "Bearer <ACCESS_TOKEN>",
6+
Authorization: `Bearer ${process.env.HF_TOKEN}`,
77
"Content-Type": "application/json",
88
},
99
method: "POST",

packages/tasks-gen/snippets-fixtures/text-to-image--lora/js/fetch/0.fal-ai.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ async function query(data) {
33
"https://fal.run/<fal-ai alias for openfree/flux-chatgpt-ghibli-lora>",
44
{
55
headers: {
6-
Authorization: "Key <ACCESS_TOKEN>",
6+
Authorization: `Key ${process.env.FAL_AI_API_TOKEN}`,
77
"Content-Type": "application/json",
88
},
99
method: "POST",

packages/tasks-gen/snippets-fixtures/text-to-image/js/fetch/0.fal-ai.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ async function query(data) {
33
"https://fal.run/<fal-ai alias for black-forest-labs/FLUX.1-schnell>",
44
{
55
headers: {
6-
Authorization: "Key <ACCESS_TOKEN>",
6+
Authorization: `Key ${process.env.FAL_AI_API_TOKEN}`,
77
"Content-Type": "application/json",
88
},
99
method: "POST",

packages/tasks-gen/snippets-fixtures/text-to-image/js/fetch/0.hf-inference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ async function query(data) {
33
"https://router.huggingface.co/hf-inference/models/black-forest-labs/FLUX.1-schnell",
44
{
55
headers: {
6-
Authorization: "Bearer <ACCESS_TOKEN>",
6+
Authorization: `Bearer ${process.env.HF_TOKEN}`,
77
"Content-Type": "application/json",
88
},
99
method: "POST",

0 commit comments

Comments
 (0)