import gradio as gr js_predict = """ async function(input){ let result = await sentimentPipe(input); return result }""" def greet(name): return "Hello " + name + "!" with gr.Blocks() as demo: gr.Markdown("""## Sentiment Analysis with Transformer.js""") name = gr.Textbox(label="Input Text") output = gr.JSON(label="Output Result") greet_btn = gr.Button("Greet") greet_btn.click(None, inputs=name, outputs=output, api_name="greet", _js=js_predict) gr.Examples([ "I don't feel well", "What a beautiful day" ], inputs=name, outputs=output) demo.launch(show_api=False)