-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Follow internal representation in gradio.components.dropdown.Dropdown when updating instruction template choices #5197
Follow internal representation in gradio.components.dropdown.Dropdown when updating instruction template choices #5197
Conversation
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
You are likely not using the gradio version specified in the requirements. It works fine for me. |
According to requirements_amd.txt, the gradio version is specified to be gradio==3.50.* and I have 3.50.2 installed. |
Okay, I reproduced it now after selecting and loading some templates a few times and then trying to refresh.
so I don't know why doing |
One possibility could be to replace the return statement in template_list = ['Select template to load...'] + sorted(set((k.stem for k in paths)), key=natural_keys)
return list(zip(template_list, template_list)) But in this case a comment should probably be added to explain why this is being done, e.g.: |
Can you check if this alternative solution fixes the problem? c4e005e |
That unfortunately doesn't work. Do you happen to know why for k, v in args.items():
setattr(refresh_component, k, v) also fixes the issue. PS: |
No idea, I just copied and pasted this refresh component. Can you modify this PR to remove those lines? I don't think they are necessary. |
… in `create_refresh_button`
I see. The latest commit 5303fdc I have pushed only removes the two lines and rolls back the original changes I made. |
Thank you for fixing this! |
My pleasure 🤝 |
The problem
When
gradio.components.dropdown.Dropdown
is instantiated with thechoices
parameter set to a list (as returned bymodules.utils.get_available_instruction_templates
), the following code on lines 86-92 ingradio/components/dropdown.py
converts the list to a list of tuples before assigning it to theself.choices
member variable:When the refresh button is clicked to update the available choices in the dropdown, the
choices
member variable is updated to be a list of strings:However, the
Dropdown
instance still expectschoices
to be a list of tuples, so it fails the next timegradio.components.dropdown.Dropdown._warn_if_invalid_choice
is called.The fix
Update the
choices
member variable with a list of tuples, not a list of strings.Fixes #5118 and #4313
Checklist: