Skip to content

Commit

Permalink
BUG: refresh related fields when format changes (xorbitsai#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
UranusSeven authored Jul 28, 2023
1 parent dce9b5d commit 38a5290
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions xinference/core/gradio.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,30 +225,44 @@ def select_model_name(model_name: str):
{spec.model_format for spec in model_family.model_specs}
)
formats.sort()
return gr.Dropdown.update(
choices=formats,
interactive=True,
return (
gr.Dropdown.update(
choices=formats, interactive=True, value=None
),
gr.Dropdown.update(choices=[], interactive=False, value=None),
gr.Dropdown.update(choices=[], interactive=False, value=None),
)
else:
return gr.Dropdown.update()
return (
gr.Dropdown.update(),
gr.Dropdown.update(),
gr.Dropdown.update(),
)

def select_model_format(model_name: str, model_format: str):
if model_name:
model_family = MODEL_TO_FAMILIES[model_name]
sizes = list(
{
str(spec.model_size_in_billions)
spec.model_size_in_billions
for spec in model_family.model_specs
if spec.model_format == model_format
}
)
sizes.sort()
return gr.Dropdown.update(
choices=sizes,
interactive=True,
return (
gr.Dropdown.update(
choices=list(map(lambda s: str(s), sizes)),
interactive=True,
value=None,
),
gr.Dropdown.update(choices=[], interactive=False, value=None),
)
else:
return gr.Dropdown.update()
return (
gr.Dropdown.update(),
gr.Dropdown.update(),
)

def select_model_size(
model_name: str, model_format: str, model_size_in_billions: str
Expand Down Expand Up @@ -276,12 +290,12 @@ def select_model_size(
model_name.change(
select_model_name,
inputs=[model_name],
outputs=[model_format],
outputs=[model_format, model_size_in_billions, quantization],
)
model_format.change(
select_model_format,
inputs=[model_name, model_format],
outputs=[model_size_in_billions],
outputs=[model_size_in_billions, quantization],
)
model_size_in_billions.change(
select_model_size,
Expand Down

0 comments on commit 38a5290

Please sign in to comment.