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
33.92k stars 2.57k forks source link

Examples are not rendered inside `@gr.render()` #9808

Open abidlabs opened 3 weeks ago

abidlabs commented 3 weeks ago

If you create examples in an Interface that is rendered dynamically in a @gr.render() function, they will not show up:

import gradio as gr

with gr.Blocks() as demo:
    @gr.render()
    def test():
        gr.Interface(lambda x:x, "textbox", "textbox", examples=["abc", "def"])

demo.launch()
image
ugotsoul commented 1 day ago

Also seeing the same behavior in a regular block: the inputs labels are correct but no examples in the list will display.

with gradio: version 5.3.0

@gr.render(...)def model_parameters():
   prompt_style = gr.Textbox(label="a picture of", key="prompt_style")
   prompt_1 = gr.Textbox(label="Prompt 1", key="prompt_1")
   prompt_2 = gr.Textbox(label="Prompt 2", key="prompt_2")

   with gr.Row() as examples:
          gr.Examples(
                examples=[["a watercolor painting of", "a prince", "a frog"]],
                inputs=[prompt_style, prompt_1, prompt_2],
                elem_id="examples",
        )

The error in the browser console is:

Index.svelte:107 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'get')
    at Index.svelte:107:42
    at Array.map (<anonymous>)
    at Index.svelte:104:19
    at Array.map (<anonymous>)
    at qe (Index.svelte:101:22)
    at Ue.s.$$.update (Index.svelte:116:20)
    at update (svelte.js:2157:6)
    at flush (svelte.js:2121:5)