Spaces:
Sleeping
Sleeping
chenyicheng commited on
Commit ·
dbe035b
1
Parent(s): 33a69ce
update app
Browse files
app.py
CHANGED
|
@@ -812,32 +812,46 @@ def _auto_suggest_datasets(task_description: str, benchmark_description: str) ->
|
|
| 812 |
return [[d] for d in ds_ids]
|
| 813 |
|
| 814 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 815 |
def _add_selected_suggestion(
|
| 816 |
-
current
|
| 817 |
-
suggestions
|
| 818 |
idx: Optional[int],
|
| 819 |
) -> List[List[str]]:
|
| 820 |
-
|
| 821 |
-
|
| 822 |
-
if idx < 0 or idx >= len(
|
| 823 |
-
return
|
| 824 |
-
val = str(
|
| 825 |
if not val:
|
| 826 |
-
return
|
| 827 |
-
existing = [str(r[0]).strip() for r in
|
| 828 |
if val in existing:
|
| 829 |
-
return
|
| 830 |
-
return
|
| 831 |
|
| 832 |
|
| 833 |
def _add_all_suggestions(
|
| 834 |
-
current
|
| 835 |
-
suggestions
|
| 836 |
) -> List[List[str]]:
|
| 837 |
-
|
| 838 |
-
|
| 839 |
-
for
|
| 840 |
-
|
|
|
|
|
|
|
| 841 |
if val and val not in existing:
|
| 842 |
existing.append(val)
|
| 843 |
merged.append([val])
|
|
|
|
| 812 |
return [[d] for d in ds_ids]
|
| 813 |
|
| 814 |
|
| 815 |
+
def _rows(table) -> List[List[str]]:
|
| 816 |
+
"""Normalize Gradio dataframe output (which may be pandas DataFrame) to list of rows."""
|
| 817 |
+
if table is None:
|
| 818 |
+
return []
|
| 819 |
+
if hasattr(table, "to_numpy"):
|
| 820 |
+
try:
|
| 821 |
+
return table.to_numpy().tolist()
|
| 822 |
+
except Exception:
|
| 823 |
+
return []
|
| 824 |
+
return table or []
|
| 825 |
+
|
| 826 |
+
|
| 827 |
def _add_selected_suggestion(
|
| 828 |
+
current,
|
| 829 |
+
suggestions,
|
| 830 |
idx: Optional[int],
|
| 831 |
) -> List[List[str]]:
|
| 832 |
+
rows_current = _rows(current)
|
| 833 |
+
rows_suggestions = _rows(suggestions)
|
| 834 |
+
if idx is None or idx < 0 or idx >= len(rows_suggestions):
|
| 835 |
+
return rows_current
|
| 836 |
+
val = str(rows_suggestions[idx][0]).strip() if rows_suggestions[idx] else ""
|
| 837 |
if not val:
|
| 838 |
+
return rows_current
|
| 839 |
+
existing = [str(r[0]).strip() for r in rows_current if r and len(r) > 0]
|
| 840 |
if val in existing:
|
| 841 |
+
return rows_current
|
| 842 |
+
return rows_current + [[val]]
|
| 843 |
|
| 844 |
|
| 845 |
def _add_all_suggestions(
|
| 846 |
+
current,
|
| 847 |
+
suggestions,
|
| 848 |
) -> List[List[str]]:
|
| 849 |
+
rows_current = _rows(current)
|
| 850 |
+
rows_suggestions = _rows(suggestions)
|
| 851 |
+
existing = [str(r[0]).strip() for r in rows_current if r and len(r) > 0]
|
| 852 |
+
merged = list(rows_current)
|
| 853 |
+
for row in rows_suggestions:
|
| 854 |
+
val = str(row[0]).strip() if row else ""
|
| 855 |
if val and val not in existing:
|
| 856 |
existing.append(val)
|
| 857 |
merged.append([val])
|