Reset components to original state by setting value to None#2044
Conversation
|
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2044-all-demos |
0f1668a to
ba879dd
Compare
There was a problem hiding this comment.
All components can now postprocess None
There was a problem hiding this comment.
To reset the chatbot
There was a problem hiding this comment.
None is no longer filtered out from the config. I think this is fine because the value is always postprocessed if None is not a "valid" value for the component.
There was a problem hiding this comment.
Not sure if it's appropriate to reset these components with None
9c47019 to
f33b0a8
Compare
There was a problem hiding this comment.
Suggest adding something in the docstring to mention the fact that we exclude keys whose name is "value" and the rationale (in case someone is reading the code later wonders why)
|
Nice fix @freddyaboulton! And great tests and demo. You might consider putting the demo in its own separate folder and in a file named |
f33b0a8 to
ffc3d76
Compare
|
Thanks for the review @abidlabs ! |
Description
Fixes #1672
Previously, it was unclear how to reset components to their original state. As stated in the original issue, the "reset" value depended on the component, e.g.
""for textbox and[]for HightlightedText, andNonewould confusingly not do anything.This PR makes it so that
Nonewill always reset the component to its unset state. The reasonNonewould originally work is that thedelete_noneutil method would delete thevaluefield from the update dict if it was None.To test:
python demo/kitchen_sink_random/reset_component_demo.pyand hit theResetbuttonChecklist: