Removed Token words
Browse files
_api.js
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
const
|
2 |
-
|
3 |
-
async function query(chooseModel,
|
4 |
-
try {
|
5 |
-
const response = await fetch(
|
6 |
-
`https://api-inference.huggingface.co/models/${chooseModel}`,
|
7 |
-
{
|
8 |
-
headers: {
|
9 |
-
Authorization: `Bearer ${
|
10 |
-
"Content-Type": "application/json",
|
11 |
-
},
|
12 |
-
method: "POST",
|
13 |
-
body: JSON.stringify({ inputs: text.value }),
|
14 |
-
}
|
15 |
-
);
|
16 |
-
|
17 |
-
if (!response.ok) {
|
18 |
-
throw new Error(`Error: ${response.status} ${response.statusText}`);
|
19 |
-
}
|
20 |
-
|
21 |
-
const result = await response.blob();
|
22 |
-
return result;
|
23 |
-
} catch (error) {
|
24 |
-
notificationInstance.show(
|
25 |
-
"error",
|
26 |
-
"Error fetching the image. Please try again later."
|
27 |
-
);
|
28 |
-
throw error; // Re-throw the error to handle it in the click event listener
|
29 |
-
}
|
30 |
-
}
|
|
|
1 |
+
const TKN = "";
|
2 |
+
|
3 |
+
async function query(chooseModel, yourKy = TKN) {
|
4 |
+
try {
|
5 |
+
const response = await fetch(
|
6 |
+
`https://api-inference.huggingface.co/models/${chooseModel}`,
|
7 |
+
{
|
8 |
+
headers: {
|
9 |
+
Authorization: `Bearer ${yourKy}`,
|
10 |
+
"Content-Type": "application/json",
|
11 |
+
},
|
12 |
+
method: "POST",
|
13 |
+
body: JSON.stringify({ inputs: text.value }),
|
14 |
+
}
|
15 |
+
);
|
16 |
+
|
17 |
+
if (!response.ok) {
|
18 |
+
throw new Error(`Error: ${response.status} ${response.statusText}`);
|
19 |
+
}
|
20 |
+
|
21 |
+
const result = await response.blob();
|
22 |
+
return result;
|
23 |
+
} catch (error) {
|
24 |
+
notificationInstance.show(
|
25 |
+
"error",
|
26 |
+
"Error fetching the image. Please try again later."
|
27 |
+
);
|
28 |
+
throw error; // Re-throw the error to handle it in the click event listener
|
29 |
+
}
|
30 |
+
}
|