riazmo Claude Opus 4.6 commited on
Commit
007d8c8
·
1 Parent(s): fb452ae

fix: DataFrame truthiness check in apply_selected_upgrades

Browse files

Gradio 6 passes Pandas DataFrame for Dataframe component values.
Bare 'if dataframe:' raises ValueError. Now normalizes to list-of-lists
before iteration, handling both DataFrame and list inputs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -2753,10 +2753,23 @@ def apply_selected_upgrades(type_choice: str, spacing_choice: str, apply_ramps:
2753
  # Process accepted color recommendations
2754
  accepted_color_changes = []
2755
  rejected_count = 0
2756
- if color_recs_table:
 
 
 
 
 
 
 
 
 
 
 
 
 
2757
  state.log("")
2758
  state.log(" 🎨 LLM Color Recommendations:")
2759
- for row in color_recs_table:
2760
  if len(row) >= 5:
2761
  accept = row[0] # Boolean checkbox
2762
  role = row[1] # Role name
 
2753
  # Process accepted color recommendations
2754
  accepted_color_changes = []
2755
  rejected_count = 0
2756
+ # Normalize color_recs_table: Gradio 6 may pass a DataFrame or list-of-lists
2757
+ _color_rows = []
2758
+ if color_recs_table is not None:
2759
+ try:
2760
+ import pandas as pd
2761
+ if isinstance(color_recs_table, pd.DataFrame) and not color_recs_table.empty:
2762
+ _color_rows = color_recs_table.values.tolist()
2763
+ elif isinstance(color_recs_table, (list, tuple)) and len(color_recs_table) > 0:
2764
+ _color_rows = list(color_recs_table)
2765
+ except Exception:
2766
+ if isinstance(color_recs_table, (list, tuple)):
2767
+ _color_rows = list(color_recs_table)
2768
+
2769
+ if _color_rows:
2770
  state.log("")
2771
  state.log(" 🎨 LLM Color Recommendations:")
2772
+ for row in _color_rows:
2773
  if len(row) >= 5:
2774
  accept = row[0] # Boolean checkbox
2775
  role = row[1] # Role name