mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-03 01:50:59 +08:00
Fix Dropdown Example component and example processing logic (#6075)
* fix examples * helpers * dropdown
This commit is contained in:
parent
447dfe06bf
commit
6b82a9760f
@ -183,4 +183,9 @@ class Dropdown(FormComponent):
|
||||
return y
|
||||
|
||||
def as_example(self, input_data):
|
||||
if self.multiselect:
|
||||
return [
|
||||
next((c[0] for c in self.choices if c[1] == data), None)
|
||||
for data in input_data
|
||||
]
|
||||
return next((c[0] for c in self.choices if c[1] == input_data), None)
|
||||
|
@ -259,16 +259,14 @@ class Examples:
|
||||
|
||||
async def load_example(example_id):
|
||||
processed_example = self.non_none_processed_examples[example_id]
|
||||
examples = utils.resolve_singleton(processed_example)
|
||||
|
||||
return (
|
||||
update(value=examples, **self.dataset.component_props[0])
|
||||
if not isinstance(examples, list)
|
||||
else [
|
||||
update(value=ex, **self.dataset.component_props[i])
|
||||
for i, ex in enumerate(examples)
|
||||
]
|
||||
)
|
||||
if len(self.inputs_with_examples) == 1:
|
||||
return update(
|
||||
value=processed_example[0], **self.dataset.component_props[0]
|
||||
)
|
||||
return [
|
||||
update(value=processed_example[i], **self.dataset.component_props[i])
|
||||
for i in range(len(self.inputs_with_examples))
|
||||
]
|
||||
|
||||
if Context.root_block:
|
||||
self.load_input_event = self.dataset.click(
|
||||
|
Loading…
Reference in New Issue
Block a user