Spaces:
Runtime error
Runtime error
Create status.js
Browse files
status.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Client } from "@gradio/client";
|
| 2 |
+
|
| 3 |
+
function log_status(status) {
|
| 4 |
+
console.log(
|
| 5 |
+
`The current status for this job is: ${JSON.stringify(status, null, 2)}.`
|
| 6 |
+
);
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
const app = await Client.connect("abidlabs/en2fr", {
|
| 10 |
+
events: ["status", "data"]
|
| 11 |
+
});
|
| 12 |
+
const job = app.submit("/predict", ["Hello"]);
|
| 13 |
+
|
| 14 |
+
for await (const message of job) {
|
| 15 |
+
if (message.type === "status") {
|
| 16 |
+
log_status(message);
|
| 17 |
+
}
|
| 18 |
+
}
|