gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
29.84k stars 2.22k forks source link

Unable to reference TextBox when loading HF Space with gr.load. #8295

Open s-chyi opened 2 weeks ago

s-chyi commented 2 weeks ago

Describe the bug

When I create an app based on chatinterface in HF Space, I can call it normally on HF. However, when I import it with gr.load("ch-yi/demo_chatinterface", src="spaces") in another HF Space or in any Python environment, errors occur. The biggest issue is that the TextBox always returns None.

https://huggingface.co/spaces/ch-yi/demo_chatinterface

import gradio as gr
demo = gr.load("ch-yi/demo_chatinterface", src="spaces").launch()

image

Here is the code on HF Space.

import gradio as gr

def slow_echo(message, history, additional_1, additional_2, additional_3, additional_4):
    for i in range(len(message)):
        yield "You typed: " + message[: i+1] + f"\nAdditional: {additional_1}, {additional_2}, {additional_3}, {additional_4}" 

with gr.Blocks() as app:
    number = gr.Number(100)
    text = gr.Textbox(value="test")
    gr.ChatInterface(fn=slow_echo, additional_inputs=[number, text]).queue()

app.launch()

The extra output is due to my discovery that the additional parameters after gr.load start displaying from the fifth index, rather than the original third index.

Have you searched existing issues? 🔎

Reproduction

import gradio as gr
demo = gr.load("ch-yi/demo_chatinterface", src="spaces").launch()

Screenshot

No response

Logs

No response

System Info

gradio version: 4.29.0

Severity

Blocking usage of gradio