cstr commited on
Commit
2db2154
·
verified ·
1 Parent(s): 3dc43a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -208,8 +208,10 @@ def update_category_models(category):
208
  for cat in MODELS:
209
  if cat["category"] == category:
210
  model_names = [model[0] for model in cat["models"]]
211
- return model_names, model_names[0]
212
- return [], ""
 
 
213
 
214
  def encode_image_to_base64(image_path):
215
  """Encode an image file to base64 string"""
@@ -697,7 +699,8 @@ def create_app():
697
  [model[0] for model in ALL_MODELS],
698
  value=ALL_MODELS[0][0],
699
  label="Model",
700
- elem_id="model-choice" # Add elem_id for debugging
 
701
  )
702
  context_display = gr.Textbox(
703
  value=update_context_display(ALL_MODELS[0][0]),
@@ -717,7 +720,8 @@ def create_app():
717
  category_models = gr.Dropdown(
718
  [model[0] for model in MODELS[0]["models"]],
719
  label="Models in Category",
720
- value=MODELS[0]["models"][0][0]
 
721
  )
722
 
723
  with gr.Accordion("Generation Parameters", open=False):
@@ -893,7 +897,7 @@ def create_app():
893
  model_search.change(
894
  fn=filter_models,
895
  inputs=model_search,
896
- outputs=[model_choice, model_choice]
897
  )
898
 
899
  # Update context display when model changes
@@ -914,12 +918,12 @@ def create_app():
914
  model_categories.change(
915
  fn=update_category_models,
916
  inputs=model_categories,
917
- outputs=[category_models, category_models]
918
  )
919
 
920
  # Update main model choice when category model is selected
921
  category_models.change(
922
- fn=lambda x: x,
923
  inputs=category_models,
924
  outputs=model_choice
925
  )
 
208
  for cat in MODELS:
209
  if cat["category"] == category:
210
  model_names = [model[0] for model in cat["models"]]
211
+ if model_names:
212
+ return gr.Dropdown.update(choices=model_names, value=model_names[0])
213
+ return gr.Dropdown.update(choices=[], value=None)
214
+ return gr.Dropdown.update(choices=[], value=None)
215
 
216
  def encode_image_to_base64(image_path):
217
  """Encode an image file to base64 string"""
 
699
  [model[0] for model in ALL_MODELS],
700
  value=ALL_MODELS[0][0],
701
  label="Model",
702
+ elem_id="model-choice",
703
+ allow_custom_value=True # allow custom values
704
  )
705
  context_display = gr.Textbox(
706
  value=update_context_display(ALL_MODELS[0][0]),
 
720
  category_models = gr.Dropdown(
721
  [model[0] for model in MODELS[0]["models"]],
722
  label="Models in Category",
723
+ value=MODELS[0]["models"][0][0],
724
+ allow_custom_value=True # allow custom values
725
  )
726
 
727
  with gr.Accordion("Generation Parameters", open=False):
 
897
  model_search.change(
898
  fn=filter_models,
899
  inputs=model_search,
900
+ outputs=[model_choice, model_choice] # update both values
901
  )
902
 
903
  # Update context display when model changes
 
918
  model_categories.change(
919
  fn=update_category_models,
920
  inputs=model_categories,
921
+ outputs=category_models
922
  )
923
 
924
  # Update main model choice when category model is selected
925
  category_models.change(
926
+ fn=lambda x: x, # Simply pass the value through
927
  inputs=category_models,
928
  outputs=model_choice
929
  )