Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events injecting function instead of called function value for gr.State #10658

Open
1 task done
brycepg opened this issue Feb 23, 2025 · 1 comment
Open
1 task done
Labels
bug Something isn't working

Comments

@brycepg
Copy link
Contributor

brycepg commented Feb 23, 2025

Describe the bug

I've noticed that the render function is injecting the value of gr.State before the state value is called AND after the state value is called. It should only inject the called value not the callable itself if I understand correctly

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

with gr.Blocks() as demo:
    input_text = gr.Textbox(label="input")
    input_state = gr.State(
        lambda: bool()
    )

    @gr.render(inputs=[input_text, input_state])
    def show_split(text, state):
        print(state)
        if len(text) == 0:
            gr.Markdown("## No Input Provided")
        else:
            for letter in text:
                gr.Textbox(letter)

demo.launch()

Logs

Here is the output of the above code from the print statement inside the decorated render function:

<function <lambda> at 0x000001F66D8CCE00>
False

System Info

Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 5.17.1
gradio_client version: 1.7.1

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
anyio: 4.8.0
audioop-lts is not installed.
fastapi: 0.115.8
ffmpy: 0.5.0
gradio-client==1.7.1 is not installed.
httpx: 0.28.1
huggingface-hub: 0.29.0
jinja2: 3.1.5
markupsafe: 2.1.5
numpy: 2.2.3
orjson: 3.10.15
packaging: 24.2
pandas: 2.2.3
pillow: 11.1.0
pydantic: 2.10.6
pydub: 0.25.1
python-multipart: 0.0.20
pyyaml: 6.0.2
ruff: 0.9.6
safehttpx: 0.1.6
semantic-version: 2.10.0
starlette: 0.45.3
tomlkit: 0.13.2
typer: 0.15.1
typing-extensions: 4.12.2
urllib3: 2.3.0
uvicorn: 0.34.0
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2025.2.0
httpx: 0.28.1
huggingface-hub: 0.29.0
packaging: 24.2
typing-extensions: 4.12.2
websockets: 14.2

Severity

I can't work around it

@brycepg brycepg added the bug Something isn't working label Feb 23, 2025
@brycepg
Copy link
Contributor Author

brycepg commented Mar 3, 2025

I've also had this happen for regular .change events on Chatbot. This can potentially break a lot of things.

@brycepg brycepg changed the title render injecting function callable instead of called function value for State events injecting function callable instead of called function value for State Mar 3, 2025
@brycepg brycepg changed the title events injecting function callable instead of called function value for State Events injecting function callable instead of called function value for State Mar 3, 2025
@brycepg brycepg changed the title Events injecting function callable instead of called function value for State Events injecting function instead of called function value for State Mar 3, 2025
@brycepg brycepg changed the title Events injecting function instead of called function value for State Events injecting function instead of called function value for gr.State Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant