Spaces:
Running
Running
Update index.mjs
Browse files
index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import express from "express";
|
|
| 2 |
import 'dotenv/config.js'
|
| 3 |
import { createServer } from "http";
|
| 4 |
import { Server } from "socket.io";
|
| 5 |
-
import {
|
| 6 |
import { createRequire } from 'node:module'
|
| 7 |
const require = createRequire(import.meta.url);
|
| 8 |
global.EventSource = require('eventsource');
|
|
@@ -24,30 +24,14 @@ io.on("connection", (socket) => {
|
|
| 24 |
|
| 25 |
});
|
| 26 |
|
| 27 |
-
async function test_servers(){
|
| 28 |
-
try{
|
| 29 |
-
const grapi_test = await client("https://gradio-hello-world.hf.space");
|
| 30 |
-
const apitest_result = await grapi_test.predict("/predict", [
|
| 31 |
-
"John",
|
| 32 |
-
]);
|
| 33 |
-
console.log(apitest_result);
|
| 34 |
-
}
|
| 35 |
-
catch(e){
|
| 36 |
-
console.log(e)
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
//test_servers()
|
| 42 |
-
|
| 43 |
async function asyncAPICall(data, socket) {
|
| 44 |
|
| 45 |
-
const grapi = await
|
| 46 |
try{
|
| 47 |
-
const api_result = await grapi.predict("/infer",
|
| 48 |
data[0], // blob in 'image' Image component
|
| 49 |
data[1], // string in 'Question' Textbox component
|
| 50 |
-
|
| 51 |
console.log(api_result)
|
| 52 |
socket.emit("api_response", (api_result.data))
|
| 53 |
}
|
|
|
|
| 2 |
import 'dotenv/config.js'
|
| 3 |
import { createServer } from "http";
|
| 4 |
import { Server } from "socket.io";
|
| 5 |
+
import { Client } from "@gradio/client";
|
| 6 |
import { createRequire } from 'node:module'
|
| 7 |
const require = createRequire(import.meta.url);
|
| 8 |
global.EventSource = require('eventsource');
|
|
|
|
| 24 |
|
| 25 |
});
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
async function asyncAPICall(data, socket) {
|
| 28 |
|
| 29 |
+
const grapi = await Client.connect("fffiloni/mndrm-call");
|
| 30 |
try{
|
| 31 |
+
const api_result = await grapi.predict("/infer", {
|
| 32 |
data[0], // blob in 'image' Image component
|
| 33 |
data[1], // string in 'Question' Textbox component
|
| 34 |
+
});
|
| 35 |
console.log(api_result)
|
| 36 |
socket.emit("api_response", (api_result.data))
|
| 37 |
}
|