Spaces:
Running
Running
Update index.js
Browse files
index.js
CHANGED
@@ -153,20 +153,20 @@ app.all('/stablediff/illusion', async (req, res) => {
|
|
153 |
Authorization: `Key ${process.env.falAIKey}`
|
154 |
}
|
155 |
|
156 |
-
const { detail, response_url } = await fetch('https://54285744-illusion-diffusion.gateway.alpha.fal.ai/fal/queue/submit', {
|
157 |
method: 'POST',
|
158 |
body: JSON.stringify({
|
159 |
prompt, negative_prompt, image_url,
|
160 |
num_inference_steps, controlnet_conditioning_scale
|
161 |
}),
|
162 |
headers
|
163 |
-
})
|
164 |
if (detail) return res.json({ success: false, message: detail })
|
165 |
|
166 |
let retry = 0
|
167 |
while (true) {
|
168 |
await new Promise(resolve => setTimeout(resolve, 2500))
|
169 |
-
const prediction = await fetch(response_url, { headers })
|
170 |
console.log(prediction)
|
171 |
if (retry > 10) return res.json({ success: false, message: prediction.detail || 'Max retry has reached' })
|
172 |
if (prediction.image) return res.json({ success: true, result: prediction })
|
|
|
153 |
Authorization: `Key ${process.env.falAIKey}`
|
154 |
}
|
155 |
|
156 |
+
const { detail, response_url } = await (await fetch('https://54285744-illusion-diffusion.gateway.alpha.fal.ai/fal/queue/submit', {
|
157 |
method: 'POST',
|
158 |
body: JSON.stringify({
|
159 |
prompt, negative_prompt, image_url,
|
160 |
num_inference_steps, controlnet_conditioning_scale
|
161 |
}),
|
162 |
headers
|
163 |
+
})).json()
|
164 |
if (detail) return res.json({ success: false, message: detail })
|
165 |
|
166 |
let retry = 0
|
167 |
while (true) {
|
168 |
await new Promise(resolve => setTimeout(resolve, 2500))
|
169 |
+
const prediction = await (await fetch(response_url, { headers })).json()
|
170 |
console.log(prediction)
|
171 |
if (retry > 10) return res.json({ success: false, message: prediction.detail || 'Max retry has reached' })
|
172 |
if (prediction.image) return res.json({ success: true, result: prediction })
|