Spaces:
Running
Running
fix col selection bug
Browse files- app.py +17 -8
- gen_table.py +8 -9
app.py
CHANGED
@@ -63,26 +63,35 @@ with gr.Blocks(title="Open Agent Leaderboard", head=head_style) as demo:
|
|
63 |
interactive=True,
|
64 |
)
|
65 |
|
66 |
-
|
|
|
|
|
|
|
67 |
data_component = gr.components.DataFrame(
|
68 |
-
value=table[
|
69 |
type='pandas',
|
70 |
-
datatype=[type_map[x] for x in
|
71 |
interactive=False,
|
72 |
wrap=True,
|
73 |
visible=True)
|
74 |
|
75 |
def filter_df(fields, *args):
|
76 |
-
# 获取基础列和选中的列
|
77 |
headers = ['Rank'] + check_box['essential'] + fields
|
78 |
df = table.copy()
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
comp = gr.components.DataFrame(
|
81 |
-
value=
|
82 |
type='pandas',
|
83 |
-
datatype=[type_map[x] for x in
|
84 |
interactive=False,
|
85 |
-
wrap=True,
|
86 |
visible=True)
|
87 |
return comp
|
88 |
|
|
|
63 |
interactive=True,
|
64 |
)
|
65 |
|
66 |
+
# 修改这里:确保初始显示的列都存在于表格中
|
67 |
+
initial_headers = ['Rank'] + check_box['essential'] + checkbox_group.value
|
68 |
+
available_headers = [h for h in initial_headers if h in table.columns]
|
69 |
+
|
70 |
data_component = gr.components.DataFrame(
|
71 |
+
value=table[available_headers], # 只使用可用的列
|
72 |
type='pandas',
|
73 |
+
datatype=[type_map[x] for x in available_headers],
|
74 |
interactive=False,
|
75 |
wrap=True,
|
76 |
visible=True)
|
77 |
|
78 |
def filter_df(fields, *args):
|
|
|
79 |
headers = ['Rank'] + check_box['essential'] + fields
|
80 |
df = table.copy()
|
81 |
+
|
82 |
+
# 确保所有请求的列都存在
|
83 |
+
available_headers = [h for h in headers if h in df.columns]
|
84 |
+
|
85 |
+
# 如果没有可用的列,返回一个带有基本列的空DataFrame
|
86 |
+
if not available_headers:
|
87 |
+
available_headers = ['Rank'] + check_box['essential']
|
88 |
+
|
89 |
comp = gr.components.DataFrame(
|
90 |
+
value=df[available_headers],
|
91 |
type='pandas',
|
92 |
+
datatype=[type_map[x] for x in available_headers],
|
93 |
interactive=False,
|
94 |
+
wrap=True,
|
95 |
visible=True)
|
96 |
return comp
|
97 |
|
gen_table.py
CHANGED
@@ -33,17 +33,17 @@ def nth_large(val, vals):
|
|
33 |
def BUILD_L1_DF(results, fields):
|
34 |
check_box = {}
|
35 |
check_box['essential'] = ['Algorithm', 'LLM', 'Eval Date']
|
36 |
-
#
|
37 |
-
check_box['required'] = ['Avg Score'] +
|
38 |
check_box['avg'] = ['Avg Score']
|
39 |
-
check_box['all'] = check_box['avg'] +
|
|
|
40 |
type_map = defaultdict(lambda: 'number')
|
41 |
type_map['Algorithm'] = 'html'
|
42 |
type_map['LLM'] = type_map['Vision Model'] = 'html'
|
43 |
type_map['Eval Date'] = 'str'
|
44 |
check_box['type_map'] = type_map
|
45 |
|
46 |
-
# df = generate_table(results, fields)
|
47 |
return check_box
|
48 |
|
49 |
|
@@ -85,21 +85,20 @@ def BUILD_L2_DF(results, fields):
|
|
85 |
df['Rank'] = df.groupby('Dataset').cumcount() + 1
|
86 |
|
87 |
# Rearrange column order
|
88 |
-
columns = ['Rank', 'Algorithm', 'Dataset', 'LLM', 'Eval Date', 'Score', 'Pass rate', 'X-shot'
|
89 |
remaining_columns = [col for col in df.columns if col not in columns]
|
90 |
df = df[columns + remaining_columns]
|
91 |
|
92 |
# Set checkbox configuration
|
93 |
check_box = {}
|
94 |
check_box['essential'] = ['Algorithm', 'Dataset', 'LLM', 'Eval Date']
|
95 |
-
check_box['required'] = check_box['essential'] + ['Score', 'Pass rate', 'X-shot', '
|
96 |
-
check_box['all'] = ['Score', 'Pass rate', 'X-shot', '
|
97 |
type_map = defaultdict(lambda: 'number')
|
98 |
type_map['Algorithm'] = 'html'
|
99 |
type_map['LLM'] = type_map['Vision Model'] = 'html'
|
100 |
type_map['Eval Date'] = 'str'
|
101 |
type_map['Dataset'] = 'str'
|
102 |
-
type_map['Parameters'] = 'str'
|
103 |
type_map['All tokens'] = 'number'
|
104 |
type_map['Cost($)'] = 'number'
|
105 |
check_box['type_map'] = type_map
|
@@ -211,7 +210,7 @@ def generate_table_detail(results, fields):
|
|
211 |
df['Rank'] = df.groupby('Dataset').cumcount() + 1
|
212 |
|
213 |
# Rearrange column order
|
214 |
-
columns = ['Rank', 'Dataset', 'Algorithm', 'LLM', 'Eval Date', 'Score', 'Pass rate', 'X-shot'
|
215 |
remaining_columns = [col for col in df.columns if col not in columns]
|
216 |
df = df[columns + remaining_columns]
|
217 |
|
|
|
33 |
def BUILD_L1_DF(results, fields):
|
34 |
check_box = {}
|
35 |
check_box['essential'] = ['Algorithm', 'LLM', 'Eval Date']
|
36 |
+
# 修改这里:确保列名与generate_table函数生成的列名一致
|
37 |
+
check_box['required'] = ['Avg Score'] + [f for field in fields for f in [f'{field}-Score', f'{field}-Cost($)']]
|
38 |
check_box['avg'] = ['Avg Score']
|
39 |
+
check_box['all'] = check_box['avg'] + [f for field in fields for f in [f'{field}-Score', f'{field}-Cost($)']]
|
40 |
+
|
41 |
type_map = defaultdict(lambda: 'number')
|
42 |
type_map['Algorithm'] = 'html'
|
43 |
type_map['LLM'] = type_map['Vision Model'] = 'html'
|
44 |
type_map['Eval Date'] = 'str'
|
45 |
check_box['type_map'] = type_map
|
46 |
|
|
|
47 |
return check_box
|
48 |
|
49 |
|
|
|
85 |
df['Rank'] = df.groupby('Dataset').cumcount() + 1
|
86 |
|
87 |
# Rearrange column order
|
88 |
+
columns = ['Rank', 'Algorithm', 'Dataset', 'LLM', 'Eval Date', 'Score', 'Pass rate', 'X-shot']
|
89 |
remaining_columns = [col for col in df.columns if col not in columns]
|
90 |
df = df[columns + remaining_columns]
|
91 |
|
92 |
# Set checkbox configuration
|
93 |
check_box = {}
|
94 |
check_box['essential'] = ['Algorithm', 'Dataset', 'LLM', 'Eval Date']
|
95 |
+
check_box['required'] = check_box['essential'] + ['Score', 'Pass rate', 'X-shot', 'Samples', 'All tokens', 'Cost($)']
|
96 |
+
check_box['all'] = ['Score', 'Pass rate', 'X-shot', 'Samples', 'Total input tokens', 'Average input tokens', 'Total output tokens', 'Average output tokens', 'All tokens', 'Cost($)']
|
97 |
type_map = defaultdict(lambda: 'number')
|
98 |
type_map['Algorithm'] = 'html'
|
99 |
type_map['LLM'] = type_map['Vision Model'] = 'html'
|
100 |
type_map['Eval Date'] = 'str'
|
101 |
type_map['Dataset'] = 'str'
|
|
|
102 |
type_map['All tokens'] = 'number'
|
103 |
type_map['Cost($)'] = 'number'
|
104 |
check_box['type_map'] = type_map
|
|
|
210 |
df['Rank'] = df.groupby('Dataset').cumcount() + 1
|
211 |
|
212 |
# Rearrange column order
|
213 |
+
columns = ['Rank', 'Dataset', 'Algorithm', 'LLM', 'Eval Date', 'Score', 'Pass rate', 'X-shot']
|
214 |
remaining_columns = [col for col in df.columns if col not in columns]
|
215 |
df = df[columns + remaining_columns]
|
216 |
|