Prav51 commited on
Commit
8d6ff28
1 Parent(s): 9ee81ef

Removed Token words

Browse files
Files changed (1) hide show
  1. _api.js +30 -30
_api.js CHANGED
@@ -1,30 +1,30 @@
1
- const TOKEN = ""; // Replace with your actual token
2
-
3
- async function query(chooseModel, token = TOKEN) {
4
- try {
5
- const response = await fetch(
6
- `https://api-inference.huggingface.co/models/${chooseModel}`,
7
- {
8
- headers: {
9
- Authorization: `Bearer ${token}`,
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
+ }