gradio icon indicating copy to clipboard operation
gradio copied to clipboard

Javascript client does not support self-hosting endpoint ( not hugging-face space)

Open nne998 opened this issue 1 year ago • 4 comments

The current version of the Javascript client does not support self-hosting endpoints, unlike the Python client that supports it. Therefore, please update the Javascript client. Thank you.

Reproduction

app.py

import gradio as gr

def predict(text):
  return 'hello ' + text

gr.Interface(fn=predict, inputs="text", outputs="text").launch()

package.json

{
  "name": "gradio_test",
  "type": "module",
  "version": "1.0.0",
  "main": "client.js",
  "dependencies": {
    "@gradio/client": "^0.1.2"
  }
}

client.js

import { client } from "@gradio/client";

async function run() {
  const app = await client("https://localhost:7860/", {
    status_callback: (res) => {
      console.log(res);
    },
  });

  const result = await app.predict("/predict", [
    "Howdy!", // string  in 'text' Textbox component
  ]);

  console.log(result?.data);
}

run();

run app

python ./app.py

run client

node ./client.js

outputs

{
  status: 'error',
  message: 'Could not load this space.',
  load_status: 'error',
  detail: 'NOT_FOUND'
}

dependencies

nne998 avatar Jun 15 '23 10:06 nne998

I thought it did. Will check this and see what the issue is.

pngwn avatar Jun 15 '23 11:06 pngwn

And, if there is an error, the “const app = await client(...)” promise function will wait indefinitely and not return. I think it should throw an exception.

nne998 avatar Jun 16 '23 03:06 nne998

This might be a dumb thing to say, but maybe the issue is with the 's' in 'https'? Instead of "https://localhost:7860/", should it not be "http://localhost:7860/" ?

manu-sapiens avatar Nov 05 '23 03:11 manu-sapiens

@manu-sapiens Not a dumb thing to say at all. It is an excellent question.

pngwn avatar Nov 06 '23 16:11 pngwn

I've just tested this and it looks like this is working on my end. My app was hosted on http://127.0.0.1:7860 so maybe the protocol was the problem here. @nne998 let me know if this issue persists for you!

hannahblair avatar Apr 29 '24 13:04 hannahblair