Spaces:
Running
Running
Update script.js
Browse files
script.js
CHANGED
|
@@ -16,6 +16,24 @@ const modelLinks = ["https://api-inference.huggingface.co/models/Shakker-Labs/FL
|
|
| 16 |
"https://api-inference.huggingface.co/models/Jovie/Midjourney"]
|
| 17 |
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
async function query(data) {
|
| 20 |
const response = await fetch(modelLinks[2], {
|
| 21 |
headers: {
|
|
@@ -26,15 +44,13 @@ async function query(data) {
|
|
| 26 |
body: JSON.stringify(data),
|
| 27 |
});
|
| 28 |
|
| 29 |
-
|
| 30 |
-
const err = await response.text();
|
| 31 |
-
throw new Error(err);
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
return await response.blob();
|
| 35 |
-
}
|
| 36 |
|
|
|
|
|
|
|
| 37 |
|
|
|
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
|
|
|
|
| 16 |
"https://api-inference.huggingface.co/models/Jovie/Midjourney"]
|
| 17 |
|
| 18 |
|
| 19 |
+
// async function query(data) {
|
| 20 |
+
// const response = await fetch(modelLinks[2], {
|
| 21 |
+
// headers: {
|
| 22 |
+
// Authorization: `Bearer ${token}`,
|
| 23 |
+
// "Content-Type": "application/json",
|
| 24 |
+
// },
|
| 25 |
+
// method: "POST",
|
| 26 |
+
// body: JSON.stringify(data),
|
| 27 |
+
// });
|
| 28 |
+
|
| 29 |
+
// if (!response.ok) {
|
| 30 |
+
// const err = await response.text();
|
| 31 |
+
// throw new Error(err);
|
| 32 |
+
// }
|
| 33 |
+
|
| 34 |
+
// return await response.blob();
|
| 35 |
+
// }
|
| 36 |
+
|
| 37 |
async function query(data) {
|
| 38 |
const response = await fetch(modelLinks[2], {
|
| 39 |
headers: {
|
|
|
|
| 44 |
body: JSON.stringify(data),
|
| 45 |
});
|
| 46 |
|
| 47 |
+
console.log("Status:", response.status);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
const text = await response.text();
|
| 50 |
+
console.log("Response:", text);
|
| 51 |
|
| 52 |
+
return new Blob([text]);
|
| 53 |
+
}
|
| 54 |
|
| 55 |
|
| 56 |
|