Spaces:
Sleeping
Sleeping
T1ckbase
commited on
Commit
·
bd93fe5
1
Parent(s):
3fded0a
- gradio-api/flux.ts +8 -3
gradio-api/flux.ts
CHANGED
|
@@ -44,10 +44,15 @@ export async function generateImage(params: OpenAI.ImageGenerateParams): Promise
|
|
| 44 |
const data = JSON.parse(event.data);
|
| 45 |
if (eventId !== data.event_id) return;
|
| 46 |
if (data.msg === 'process_completed') {
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
}
|
|
|
|
| 51 |
};
|
| 52 |
|
| 53 |
eventSource.onerror = (event) => {
|
|
|
|
| 44 |
const data = JSON.parse(event.data);
|
| 45 |
if (eventId !== data.event_id) return;
|
| 46 |
if (data.msg === 'process_completed') {
|
| 47 |
+
try {
|
| 48 |
+
const url: string = data.output.data[0].url;
|
| 49 |
+
eventSource.close();
|
| 50 |
+
resolve(url);
|
| 51 |
+
} catch (e) {
|
| 52 |
+
reject(e);
|
| 53 |
+
}
|
| 54 |
}
|
| 55 |
+
if (data.msg === 'close_stream') reject('close_stream');
|
| 56 |
};
|
| 57 |
|
| 58 |
eventSource.onerror = (event) => {
|