Spaces:
Running
Running
feat:add link header (#15)
Browse files- feat - add link header (5f8dbda8769060dfb1af2ad0ab934654e536f866)
Co-authored-by: Y <[email protected]>
- app/backend/data_page.py +188 -382
- app/backend/multi_header_util.py +212 -0
- requirements.txt +2 -2
app/backend/data_page.py
CHANGED
|
@@ -6,8 +6,11 @@
|
|
| 6 |
import io
|
| 7 |
|
| 8 |
from st_aggrid import AgGrid, JsCode, ColumnsAutoSizeMode
|
|
|
|
| 9 |
import streamlit as st
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
from utils.st_copy_to_clipboard import st_copy_to_clipboard
|
| 12 |
from streamlit_theme import st_theme
|
| 13 |
|
|
@@ -20,9 +23,8 @@ COLUMNS = ['model_name', 'vendor',
|
|
| 20 |
'query_instruct', 'corpus_instruct', 'reference'
|
| 21 |
|
| 22 |
]
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
CELL_STYLE = {'fontSize': '14px'}
|
| 26 |
|
| 27 |
|
| 28 |
def is_section(group_name):
|
|
@@ -35,7 +37,7 @@ def is_section(group_name):
|
|
| 35 |
|
| 36 |
|
| 37 |
def get_closed_dataset():
|
| 38 |
-
data_engine = st.session_state
|
| 39 |
closed_list = []
|
| 40 |
results = data_engine.results
|
| 41 |
for result in results:
|
|
@@ -44,23 +46,6 @@ def get_closed_dataset():
|
|
| 44 |
return closed_list
|
| 45 |
|
| 46 |
|
| 47 |
-
def get_dataset_url_name(field_name):
|
| 48 |
-
"""Convert field name to proper URL format for closed datasets"""
|
| 49 |
-
# Handle field names like "ClosedDataset 2 (German Legal Sentences)"
|
| 50 |
-
if field_name.startswith("ClosedDataset "):
|
| 51 |
-
# Extract the number and format it as ClosedDataset_X
|
| 52 |
-
if "(" in field_name:
|
| 53 |
-
# Extract number from "ClosedDataset 2 (description)" -> "2"
|
| 54 |
-
number_part = field_name.split("ClosedDataset ")[1].split(" ")[0]
|
| 55 |
-
return f"ClosedDataset_{number_part}"
|
| 56 |
-
else:
|
| 57 |
-
# Handle cases where it might already be in the right format or no parentheses
|
| 58 |
-
return field_name.replace(" ", "_")
|
| 59 |
-
|
| 60 |
-
# Return original field_name for open datasets
|
| 61 |
-
return field_name
|
| 62 |
-
|
| 63 |
-
|
| 64 |
def convert_df_to_csv(df):
|
| 65 |
output = io.StringIO()
|
| 66 |
df.to_csv(output, index=False)
|
|
@@ -73,168 +58,23 @@ def get_column_state():
|
|
| 73 |
"""
|
| 74 |
query_params = st.query_params.get("grid_state", None)
|
| 75 |
sider_bar_hidden = st.query_params.get("sider_bar_hidden", "False")
|
|
|
|
| 76 |
if query_params:
|
| 77 |
grid_state = decompress_msgpack(query_params)
|
| 78 |
st.session_state.grid_state = grid_state
|
| 79 |
if sider_bar_hidden.upper() == 'FALSE':
|
| 80 |
st.session_state.sider_bar_hidden = False
|
|
|
|
|
|
|
| 81 |
return None
|
| 82 |
|
| 83 |
|
| 84 |
-
def
|
| 85 |
-
"""
|
| 86 |
-
dataset_columns = [col for col in column_list if col not in (avg_column, "Closed average", "Open average")]
|
| 87 |
-
|
| 88 |
-
# For individual dataset pages (not sections), group datasets by open/closed
|
| 89 |
-
if not is_section(group_name) and dataset_columns:
|
| 90 |
-
# Separate open and closed datasets
|
| 91 |
-
open_datasets = [d for d in dataset_columns if not d.startswith('_') and not d.startswith('ClosedDataset ')]
|
| 92 |
-
closed_datasets = [d for d in dataset_columns if d.startswith('_') or d.startswith('ClosedDataset ')]
|
| 93 |
-
|
| 94 |
-
grouped_columns = []
|
| 95 |
-
|
| 96 |
-
# Add Open Datasets group
|
| 97 |
-
if open_datasets:
|
| 98 |
-
grouped_columns.append({
|
| 99 |
-
'headerName': 'Open Datasets',
|
| 100 |
-
'headerStyle': LARGER_HEADER_STYLE,
|
| 101 |
-
'headerClass': 'group-header',
|
| 102 |
-
'marryChildren': True,
|
| 103 |
-
'openByDefault': True,
|
| 104 |
-
'children': [
|
| 105 |
-
{
|
| 106 |
-
'headerName': column,
|
| 107 |
-
'field': column,
|
| 108 |
-
'headerStyle': HEADER_STYLE,
|
| 109 |
-
'cellStyle': CELL_STYLE,
|
| 110 |
-
"headerTooltip": column,
|
| 111 |
-
'headerComponent': JsCode(f"""
|
| 112 |
-
class DatasetHeaderRenderer {{
|
| 113 |
-
init(params) {{
|
| 114 |
-
this.eGui = document.createElement('div');
|
| 115 |
-
const columnName = params.displayName;
|
| 116 |
-
const fieldName = params.column.colId;
|
| 117 |
-
|
| 118 |
-
const link = document.createElement('a');
|
| 119 |
-
link.href = 'https://huggingface.co/datasets/embedding-benchmark/' + fieldName;
|
| 120 |
-
link.target = '_blank';
|
| 121 |
-
link.style.color = 'white';
|
| 122 |
-
link.style.textDecoration = 'underline';
|
| 123 |
-
link.style.cursor = 'pointer';
|
| 124 |
-
link.textContent = columnName;
|
| 125 |
-
|
| 126 |
-
link.addEventListener('click', function(e) {{
|
| 127 |
-
e.stopPropagation();
|
| 128 |
-
}});
|
| 129 |
-
|
| 130 |
-
this.eGui.appendChild(link);
|
| 131 |
-
}}
|
| 132 |
-
|
| 133 |
-
getGui() {{
|
| 134 |
-
return this.eGui;
|
| 135 |
-
}}
|
| 136 |
-
}}
|
| 137 |
-
""")
|
| 138 |
-
} for column in open_datasets
|
| 139 |
-
]
|
| 140 |
-
})
|
| 141 |
-
|
| 142 |
-
# Add Closed Datasets group
|
| 143 |
-
if closed_datasets:
|
| 144 |
-
grouped_columns.append({
|
| 145 |
-
'headerName': 'Closed Datasets',
|
| 146 |
-
'headerStyle': LARGER_HEADER_STYLE,
|
| 147 |
-
'headerClass': 'group-header',
|
| 148 |
-
'marryChildren': True,
|
| 149 |
-
'openByDefault': True,
|
| 150 |
-
'children': [
|
| 151 |
-
{
|
| 152 |
-
'headerName': column,
|
| 153 |
-
'field': column,
|
| 154 |
-
'headerStyle': HEADER_STYLE,
|
| 155 |
-
'cellStyle': CELL_STYLE,
|
| 156 |
-
"headerTooltip": column,
|
| 157 |
-
'headerComponent': JsCode(f"""
|
| 158 |
-
class DatasetHeaderRenderer {{
|
| 159 |
-
init(params) {{
|
| 160 |
-
this.eGui = document.createElement('div');
|
| 161 |
-
const columnName = params.displayName;
|
| 162 |
-
const fieldName = params.column.colId;
|
| 163 |
-
|
| 164 |
-
const link = document.createElement('a');
|
| 165 |
-
link.href = 'https://huggingface.co/datasets/embedding-benchmark/' + '{get_dataset_url_name(column)}';
|
| 166 |
-
link.target = '_blank';
|
| 167 |
-
link.style.color = 'white';
|
| 168 |
-
link.style.textDecoration = 'underline';
|
| 169 |
-
link.style.cursor = 'pointer';
|
| 170 |
-
link.textContent = '{column}';
|
| 171 |
-
|
| 172 |
-
link.addEventListener('click', function(e) {{
|
| 173 |
-
e.stopPropagation();
|
| 174 |
-
}});
|
| 175 |
-
|
| 176 |
-
this.eGui.appendChild(link);
|
| 177 |
-
}}
|
| 178 |
-
|
| 179 |
-
getGui() {{
|
| 180 |
-
return this.eGui;
|
| 181 |
-
}}
|
| 182 |
-
}}
|
| 183 |
-
""")
|
| 184 |
-
} for column in closed_datasets
|
| 185 |
-
]
|
| 186 |
-
})
|
| 187 |
-
|
| 188 |
-
return grouped_columns
|
| 189 |
-
else:
|
| 190 |
-
# For section pages, return columns without grouping (original behavior)
|
| 191 |
-
return [{'headerName': column if column.startswith('_') and "Average" not in column else (column if "Average" not in column else column.replace("Average", "").strip().capitalize()),
|
| 192 |
-
'field': column,
|
| 193 |
-
'headerStyle': HEADER_STYLE,
|
| 194 |
-
'cellStyle': CELL_STYLE,
|
| 195 |
-
"headerTooltip": column if column.startswith('_') and "Average" not in column else (column if "Average" not in column else column.replace("Average",
|
| 196 |
-
"").strip().capitalize()),
|
| 197 |
-
'headerComponent': JsCode(f"""
|
| 198 |
-
class DatasetHeaderRenderer {{
|
| 199 |
-
init(params) {{
|
| 200 |
-
this.eGui = document.createElement('div');
|
| 201 |
-
const columnName = params.displayName;
|
| 202 |
-
const fieldName = params.column.colId;
|
| 203 |
-
|
| 204 |
-
if (fieldName.includes('Average')) {{
|
| 205 |
-
this.eGui.textContent = columnName;
|
| 206 |
-
}} else {{
|
| 207 |
-
const link = document.createElement('a');
|
| 208 |
-
link.href = 'https://huggingface.co/datasets/embedding-benchmark/' + '{get_dataset_url_name(column)}';
|
| 209 |
-
link.target = '_blank';
|
| 210 |
-
link.style.color = 'white';
|
| 211 |
-
link.style.textDecoration = 'underline';
|
| 212 |
-
link.style.cursor = 'pointer';
|
| 213 |
-
|
| 214 |
-
link.textContent = '{column}';
|
| 215 |
-
|
| 216 |
-
link.addEventListener('click', function(e) {{
|
| 217 |
-
e.stopPropagation();
|
| 218 |
-
}});
|
| 219 |
-
|
| 220 |
-
this.eGui.appendChild(link);
|
| 221 |
-
}}
|
| 222 |
-
}}
|
| 223 |
-
|
| 224 |
-
getGui() {{
|
| 225 |
-
return this.eGui;
|
| 226 |
-
}}
|
| 227 |
-
}}
|
| 228 |
-
""")
|
| 229 |
-
} for column in dataset_columns]
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
def render_page(group_name):
|
| 233 |
-
grid_state = st.session_state.get("grid_state", {})
|
| 234 |
-
st.session_state.sider_bar_hidden = True
|
| 235 |
-
get_column_state()
|
| 236 |
|
| 237 |
-
|
|
|
|
|
|
|
| 238 |
st.markdown("""
|
| 239 |
<style>
|
| 240 |
[data-testid="stSidebar"] {
|
|
@@ -255,91 +95,51 @@ def render_page(group_name):
|
|
| 255 |
</style>
|
| 256 |
""", unsafe_allow_html=True)
|
| 257 |
|
| 258 |
-
# Add theme color and grid styles
|
| 259 |
-
st.title("Retrieval Embedding Benchmark (RTEB)")
|
| 260 |
-
st.markdown("""
|
| 261 |
-
<style>
|
| 262 |
-
:root {
|
| 263 |
-
--theme-color: rgb(129, 150, 64);
|
| 264 |
-
--theme-color-light: rgba(129, 150, 64, 0.2);
|
| 265 |
-
}
|
| 266 |
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
--ag-selected-tab-color: var(--theme-color) !important;
|
| 272 |
-
--ag-range-selection-border-color: var(--theme-color) !important;
|
| 273 |
-
--ag-range-selection-background-color: var(--theme-color-light) !important;
|
| 274 |
-
}
|
| 275 |
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
|
|
|
|
|
|
|
|
|
| 279 |
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
|
| 288 |
-
|
| 289 |
-
border-color: var(--theme-color) !important;
|
| 290 |
-
}
|
| 291 |
|
| 292 |
-
|
| 293 |
-
.center-text {
|
| 294 |
-
text-align: center;
|
| 295 |
-
color: var(--theme-color);
|
| 296 |
-
}
|
| 297 |
-
.center-image {
|
| 298 |
-
display: block;
|
| 299 |
-
margin-left: auto;
|
| 300 |
-
margin-right: auto;
|
| 301 |
-
}
|
| 302 |
-
h2 {
|
| 303 |
-
color: var(--theme-color) !important;
|
| 304 |
-
}
|
| 305 |
-
.ag-header-cell {
|
| 306 |
-
background-color: var(--theme-color) !important;
|
| 307 |
-
color: white !important;
|
| 308 |
-
}
|
| 309 |
-
a {
|
| 310 |
-
color: var(--theme-color) !important;
|
| 311 |
-
}
|
| 312 |
-
a:hover {
|
| 313 |
-
color: rgba(129, 150, 64, 0.8) !important;
|
| 314 |
-
}
|
| 315 |
-
/* Download Button */
|
| 316 |
-
button[data-testid="stBaseButton-secondary"] {
|
| 317 |
-
float: right;
|
| 318 |
-
|
| 319 |
-
}
|
| 320 |
-
/* Toast On The Top*/
|
| 321 |
-
div[data-testid="stToastContainer"] {
|
| 322 |
-
position: fixed !important;
|
| 323 |
-
z-index: 2147483647 !important;
|
| 324 |
-
}
|
| 325 |
-
</style>
|
| 326 |
-
|
| 327 |
-
""", unsafe_allow_html=True)
|
| 328 |
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
if is_section(group_name):
|
| 333 |
-
title = f'<h2 class="center-text">{LEADERBOARD_ICON_MAP.get(group_name.capitalize() + " Leaderboard", "")} {group_name.capitalize() + " Leaderboard"}</h2>'
|
| 334 |
-
# title
|
| 335 |
-
st.markdown(title, unsafe_allow_html=True)
|
| 336 |
|
| 337 |
-
data_engine = st.session_state["data_engine"]
|
| 338 |
|
| 339 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 340 |
|
| 341 |
-
|
| 342 |
-
|
|
|
|
|
|
|
| 343 |
|
| 344 |
# get columns
|
| 345 |
column_list = []
|
|
@@ -370,10 +170,6 @@ def render_page(group_name):
|
|
| 370 |
if dataset_dict["name"] == group_name:
|
| 371 |
dataset_list = dataset_dict["datasets"]
|
| 372 |
if not is_section(group_name):
|
| 373 |
-
# Sort datasets: open first, then closed
|
| 374 |
-
open_datasets = [d for d in dataset_list if not d.startswith('_')]
|
| 375 |
-
closed_datasets = [d for d in dataset_list if d.startswith('_')]
|
| 376 |
-
dataset_list = open_datasets + closed_datasets
|
| 377 |
column_list.extend(dataset_list)
|
| 378 |
closed_list = get_closed_dataset()
|
| 379 |
close_avg_list = list(set(dataset_list) & set(closed_list))
|
|
@@ -393,132 +189,13 @@ def render_page(group_name):
|
|
| 393 |
column_list.remove(avg_column)
|
| 394 |
avg_column = new_column
|
| 395 |
|
| 396 |
-
# setting column config
|
| 397 |
-
grid_options = {
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
'field': 'model_name',
|
| 402 |
-
'pinned': 'left',
|
| 403 |
-
'sortable': False,
|
| 404 |
-
'headerStyle': HEADER_STYLE,
|
| 405 |
-
'cellStyle': CELL_STYLE,
|
| 406 |
-
"tooltipValueGetter": JsCode(
|
| 407 |
-
"""function(p) {return p.value}"""
|
| 408 |
-
),
|
| 409 |
-
"width": 250,
|
| 410 |
-
'cellRenderer': JsCode("""class CustomHTML {
|
| 411 |
-
init(params) {
|
| 412 |
-
const link = params.data.reference;
|
| 413 |
-
this.eGui = document.createElement('div');
|
| 414 |
-
this.eGui.innerHTML = link ?
|
| 415 |
-
`<a href="${link}" class="a-cell" target="_blank">${params.value} </a>` :
|
| 416 |
-
params.value;
|
| 417 |
-
}
|
| 418 |
-
|
| 419 |
-
getGui() {
|
| 420 |
-
return this.eGui;
|
| 421 |
-
}
|
| 422 |
-
}"""),
|
| 423 |
-
'suppressSizeToFit': True
|
| 424 |
-
|
| 425 |
-
},
|
| 426 |
-
{'headerName': "Vendor",
|
| 427 |
-
'field': 'vendor',
|
| 428 |
-
'headerStyle': HEADER_STYLE,
|
| 429 |
-
'cellStyle': CELL_STYLE,
|
| 430 |
-
# 'suppressSizeToFit': True
|
| 431 |
-
},
|
| 432 |
-
{'headerName': "Overall Score",
|
| 433 |
-
'field': avg_column,
|
| 434 |
-
'headerStyle': HEADER_STYLE,
|
| 435 |
-
'cellStyle': CELL_STYLE,
|
| 436 |
-
# 'suppressSizeToFit': True
|
| 437 |
-
},
|
| 438 |
-
|
| 439 |
-
# Add Open average column definition
|
| 440 |
-
{'headerName': 'Open Average',
|
| 441 |
-
'field': 'Open average',
|
| 442 |
-
'headerStyle': HEADER_STYLE,
|
| 443 |
-
'cellStyle': CELL_STYLE,
|
| 444 |
-
# 'suppressSizeToFit': True
|
| 445 |
-
},
|
| 446 |
-
|
| 447 |
-
{'headerName': 'Closed Average',
|
| 448 |
-
'field': 'Closed average',
|
| 449 |
-
'headerStyle': HEADER_STYLE,
|
| 450 |
-
'cellStyle': CELL_STYLE,
|
| 451 |
-
# 'suppressSizeToFit': True
|
| 452 |
-
},
|
| 453 |
-
|
| 454 |
-
{
|
| 455 |
-
'headerName': 'Embd Dtype',
|
| 456 |
-
'field': 'embd_dtype',
|
| 457 |
-
'headerStyle': HEADER_STYLE,
|
| 458 |
-
'cellStyle': CELL_STYLE,
|
| 459 |
-
# 'suppressSizeToFit': True,
|
| 460 |
-
},
|
| 461 |
-
{
|
| 462 |
-
'headerName': 'Embd Dim',
|
| 463 |
-
'field': 'embd_dim',
|
| 464 |
-
'headerStyle': HEADER_STYLE,
|
| 465 |
-
'cellStyle': CELL_STYLE,
|
| 466 |
-
# 'suppressSizeToFit': True,
|
| 467 |
-
},
|
| 468 |
-
{
|
| 469 |
-
'headerName': 'Number of Parameters',
|
| 470 |
-
'field': 'num_params',
|
| 471 |
-
'cellDataType': 'number',
|
| 472 |
-
"colId": "num_params",
|
| 473 |
-
'headerStyle': HEADER_STYLE,
|
| 474 |
-
'cellStyle': CELL_STYLE,
|
| 475 |
-
'valueFormatter': JsCode(
|
| 476 |
-
"""function(params) {
|
| 477 |
-
const num = params.value;
|
| 478 |
-
if (num >= 1e9) return (num / 1e9).toFixed(2) + "B";
|
| 479 |
-
if (num >= 1e6) return (num / 1e6).toFixed(2) + "M";
|
| 480 |
-
if (num >= 1e3) return (num / 1e3).toFixed(2) + "K";
|
| 481 |
-
return num;
|
| 482 |
-
}"""
|
| 483 |
-
),
|
| 484 |
-
"width": 120,
|
| 485 |
-
# 'suppressSizeToFit': True,
|
| 486 |
-
},
|
| 487 |
-
{
|
| 488 |
-
'headerName': 'Context Length',
|
| 489 |
-
'field': 'max_tokens',
|
| 490 |
-
'headerStyle': HEADER_STYLE,
|
| 491 |
-
'cellStyle': CELL_STYLE,
|
| 492 |
-
'valueFormatter': JsCode(
|
| 493 |
-
"""function(params) {
|
| 494 |
-
const num = params.value;
|
| 495 |
-
if (typeof num === 'number' && num >= 10000) {
|
| 496 |
-
return num.toLocaleString();
|
| 497 |
-
}
|
| 498 |
-
return num;
|
| 499 |
-
}"""
|
| 500 |
-
),
|
| 501 |
-
# 'suppressSizeToFit': True,
|
| 502 |
-
},
|
| 503 |
-
|
| 504 |
-
*(_get_dataset_columns(group_name, column_list, avg_column))
|
| 505 |
-
],
|
| 506 |
-
'defaultColDef': {
|
| 507 |
-
'filter': True,
|
| 508 |
-
'sortable': True,
|
| 509 |
-
'resizable': True,
|
| 510 |
-
'headerClass': "multi-line-header",
|
| 511 |
-
'autoHeaderHeight': True,
|
| 512 |
-
'width': 105
|
| 513 |
-
},
|
| 514 |
|
| 515 |
-
|
| 516 |
-
"type": 'fitCellContents',
|
| 517 |
-
"colIds": [column for column in column_list if column not in (avg_column, "Closed average", "Open average")]
|
| 518 |
-
},
|
| 519 |
-
"tooltipShowDelay": 500,
|
| 520 |
-
"initialState": grid_state,
|
| 521 |
-
}
|
| 522 |
|
| 523 |
custom_css = {
|
| 524 |
# Model Name Cell
|
|
@@ -541,8 +218,23 @@ def render_page(group_name):
|
|
| 541 |
"font-weight": "bold",
|
| 542 |
"padding": "10px",
|
| 543 |
"text-align": "left",
|
| 544 |
-
}
|
| 545 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 546 |
# Filter Options and Input
|
| 547 |
".ag-theme-streamlit .ag-popup": {
|
| 548 |
"font-family": 'Arial',
|
|
@@ -570,9 +262,109 @@ def render_page(group_name):
|
|
| 570 |
columns_auto_size_mode=ColumnsAutoSizeMode.FIT_ALL_COLUMNS_TO_VIEW,
|
| 571 |
theme="streamlit",
|
| 572 |
custom_css=custom_css,
|
| 573 |
-
update_on=["
|
| 574 |
)
|
| 575 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 576 |
@st.dialog("URL")
|
| 577 |
def share_url():
|
| 578 |
state = grid.grid_state
|
|
@@ -604,3 +396,17 @@ def render_page(group_name):
|
|
| 604 |
|
| 605 |
if share_btn:
|
| 606 |
share_url()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
import io
|
| 7 |
|
| 8 |
from st_aggrid import AgGrid, JsCode, ColumnsAutoSizeMode
|
| 9 |
+
|
| 10 |
import streamlit as st
|
| 11 |
+
|
| 12 |
+
from app.backend.data_engine import DataEngine
|
| 13 |
+
from app.backend.multi_header_util import get_header_options
|
| 14 |
from utils.st_copy_to_clipboard import st_copy_to_clipboard
|
| 15 |
from streamlit_theme import st_theme
|
| 16 |
|
|
|
|
| 23 |
'query_instruct', 'corpus_instruct', 'reference'
|
| 24 |
|
| 25 |
]
|
| 26 |
+
HEADER_STYLE = {'fontSize': '18px'}
|
| 27 |
+
CELL_STYLE = {'fontSize': '18px'}
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
def is_section(group_name):
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
def get_closed_dataset():
|
| 40 |
+
data_engine = st.session_state.get("data_engine", DataEngine())
|
| 41 |
closed_list = []
|
| 42 |
results = data_engine.results
|
| 43 |
for result in results:
|
|
|
|
| 46 |
return closed_list
|
| 47 |
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
def convert_df_to_csv(df):
|
| 50 |
output = io.StringIO()
|
| 51 |
df.to_csv(output, index=False)
|
|
|
|
| 58 |
"""
|
| 59 |
query_params = st.query_params.get("grid_state", None)
|
| 60 |
sider_bar_hidden = st.query_params.get("sider_bar_hidden", "False")
|
| 61 |
+
table_only = st.query_params.get("table_only", "False")
|
| 62 |
if query_params:
|
| 63 |
grid_state = decompress_msgpack(query_params)
|
| 64 |
st.session_state.grid_state = grid_state
|
| 65 |
if sider_bar_hidden.upper() == 'FALSE':
|
| 66 |
st.session_state.sider_bar_hidden = False
|
| 67 |
+
if table_only.upper() == 'FALSE':
|
| 68 |
+
st.session_state.table_only = False
|
| 69 |
return None
|
| 70 |
|
| 71 |
|
| 72 |
+
def sidebar_css():
|
| 73 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
+
:return:
|
| 76 |
+
"""
|
| 77 |
+
if st.session_state.get("sider_bar_hidden"):
|
| 78 |
st.markdown("""
|
| 79 |
<style>
|
| 80 |
[data-testid="stSidebar"] {
|
|
|
|
| 95 |
</style>
|
| 96 |
""", unsafe_allow_html=True)
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
+
def table_only_css():
|
| 100 |
+
if st.session_state.get("table_only"):
|
| 101 |
+
st.markdown("""
|
| 102 |
+
<style>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
+
[data-testid="stMainBlockContainer"] {
|
| 105 |
+
padding-top: 0px;
|
| 106 |
+
padding-left: 0px;
|
| 107 |
+
padding-bottom: 0px;
|
| 108 |
+
padding-right: 0px;
|
| 109 |
+
}
|
| 110 |
|
| 111 |
+
[data-testid="stHeader"] {
|
| 112 |
+
height: 0px;
|
| 113 |
+
}
|
| 114 |
|
| 115 |
+
[data-testid="stApp"] {
|
| 116 |
+
height: 456px;
|
| 117 |
+
}
|
| 118 |
|
| 119 |
+
.st-emotion-cache-1dp5vir {
|
|
|
|
|
|
|
| 120 |
|
| 121 |
+
height: 0px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
+
}
|
| 124 |
+
</style>
|
| 125 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
|
|
|
| 127 |
|
| 128 |
+
def table_area(group_name, grid_state, data_engine=None, df=None):
|
| 129 |
+
"""
|
| 130 |
+
table_area
|
| 131 |
+
:param group_name:
|
| 132 |
+
:param grid_state:
|
| 133 |
+
:param data_engine:
|
| 134 |
+
:param df:
|
| 135 |
+
:return:
|
| 136 |
+
"""
|
| 137 |
+
table_only_css()
|
| 138 |
|
| 139 |
+
if data_engine is None:
|
| 140 |
+
data_engine = st.session_state.get("data_engine", DataEngine())
|
| 141 |
+
if df is None:
|
| 142 |
+
df = data_engine.jsons_to_df().copy()
|
| 143 |
|
| 144 |
# get columns
|
| 145 |
column_list = []
|
|
|
|
| 170 |
if dataset_dict["name"] == group_name:
|
| 171 |
dataset_list = dataset_dict["datasets"]
|
| 172 |
if not is_section(group_name):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
column_list.extend(dataset_list)
|
| 174 |
closed_list = get_closed_dataset()
|
| 175 |
close_avg_list = list(set(dataset_list) & set(closed_list))
|
|
|
|
| 189 |
column_list.remove(avg_column)
|
| 190 |
avg_column = new_column
|
| 191 |
|
| 192 |
+
# setting column config - 优化缓存机制,减少不必要的session_state更新
|
| 193 |
+
grid_options = st.session_state.get(f"{group_name}_grid_options")
|
| 194 |
+
if grid_options is None:
|
| 195 |
+
grid_options = get_header_options(column_list, avg_column, is_section(group_name))
|
| 196 |
+
st.session_state[f"{group_name}_grid_options"] = grid_options
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
+
grid_options["initialState"] = grid_state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
custom_css = {
|
| 201 |
# Model Name Cell
|
|
|
|
| 218 |
"font-weight": "bold",
|
| 219 |
"padding": "10px",
|
| 220 |
"text-align": "left",
|
| 221 |
+
},
|
| 222 |
+
# Custom header and cell styles to replace headerStyle and cellStyle
|
| 223 |
+
".custom-header-style": {
|
| 224 |
+
"text-overflow": "clip",
|
| 225 |
+
"overflow": "visible",
|
| 226 |
+
"white-space": "normal",
|
| 227 |
+
"height": "auto",
|
| 228 |
+
"font-family": 'Arial',
|
| 229 |
+
"font-size": "14px",
|
| 230 |
+
"font-weight": "bold",
|
| 231 |
+
"padding": "10px",
|
| 232 |
+
"text-align": "left",
|
| 233 |
+
},
|
| 234 |
+
".custom-cell-style": {
|
| 235 |
+
"font-size": "14px",
|
| 236 |
+
"color": "inherit",
|
| 237 |
+
},
|
| 238 |
# Filter Options and Input
|
| 239 |
".ag-theme-streamlit .ag-popup": {
|
| 240 |
"font-family": 'Arial',
|
|
|
|
| 262 |
columns_auto_size_mode=ColumnsAutoSizeMode.FIT_ALL_COLUMNS_TO_VIEW,
|
| 263 |
theme="streamlit",
|
| 264 |
custom_css=custom_css,
|
| 265 |
+
update_on=["selectionChanged", "filterChanged"], # 减少WebSocket触发频率,只在重要变化时触发
|
| 266 |
)
|
| 267 |
|
| 268 |
+
return grid
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
def main_page(group_name, grid_state):
|
| 272 |
+
"""
|
| 273 |
+
main_page
|
| 274 |
+
:param group_name:
|
| 275 |
+
:param grid_state:
|
| 276 |
+
:return:
|
| 277 |
+
"""
|
| 278 |
+
|
| 279 |
+
# Add theme color and grid styles
|
| 280 |
+
st.title("Retrieval Embedding Benchmark (RTEB)")
|
| 281 |
+
st.markdown("""
|
| 282 |
+
<style>
|
| 283 |
+
:root {
|
| 284 |
+
--theme-color: rgb(129, 150, 64);
|
| 285 |
+
--theme-color-light: rgba(129, 150, 64, 0.2);
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
/* AG Grid specific overrides */
|
| 289 |
+
.ag-theme-alpine {
|
| 290 |
+
--ag-selected-row-background-color: var(--theme-color-light) !important;
|
| 291 |
+
--ag-row-hover-color: var(--theme-color-light) !important;
|
| 292 |
+
--ag-selected-tab-color: var(--theme-color) !important;
|
| 293 |
+
--ag-range-selection-border-color: var(--theme-color) !important;
|
| 294 |
+
--ag-range-selection-background-color: var(--theme-color-light) !important;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
.ag-row-hover {
|
| 298 |
+
background-color: var(--theme-color-light) !important;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
.ag-row-selected {
|
| 302 |
+
background-color: var(--theme-color-light) !important;
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
.ag-row-focus {
|
| 306 |
+
background-color: var(--theme-color-light) !important;
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
.ag-cell-focus {
|
| 310 |
+
border-color: var(--theme-color) !important;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
/* Keep existing styles */
|
| 314 |
+
.center-text {
|
| 315 |
+
text-align: center;
|
| 316 |
+
color: var(--theme-color);
|
| 317 |
+
}
|
| 318 |
+
.center-image {
|
| 319 |
+
display: block;
|
| 320 |
+
margin-left: auto;
|
| 321 |
+
margin-right: auto;
|
| 322 |
+
}
|
| 323 |
+
h2 {
|
| 324 |
+
color: var(--theme-color) !important;
|
| 325 |
+
}
|
| 326 |
+
.ag-header-cell {
|
| 327 |
+
background-color: var(--theme-color) !important;
|
| 328 |
+
color: white !important;
|
| 329 |
+
}
|
| 330 |
+
a {
|
| 331 |
+
color: var(--theme-color) !important;
|
| 332 |
+
}
|
| 333 |
+
a:hover {
|
| 334 |
+
color: rgba(129, 150, 64, 0.8) !important;
|
| 335 |
+
}
|
| 336 |
+
/* Download Button */
|
| 337 |
+
button[data-testid="stBaseButton-secondary"] {
|
| 338 |
+
float: right;
|
| 339 |
+
|
| 340 |
+
}
|
| 341 |
+
/* Toast On The Top*/
|
| 342 |
+
div[data-testid="stToastContainer"] {
|
| 343 |
+
position: fixed !important;
|
| 344 |
+
z-index: 2147483647 !important;
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
</style>
|
| 348 |
+
|
| 349 |
+
""", unsafe_allow_html=True)
|
| 350 |
+
|
| 351 |
+
# logo
|
| 352 |
+
# st.markdown('<img src="https://www.voyageai.com/logo.svg" class="center-image" width="200">', unsafe_allow_html=True)
|
| 353 |
+
title = f'<h2 class="center-text">{LEADERBOARD_ICON_MAP.get(group_name.capitalize(), "")} {group_name.capitalize()}</h2>'
|
| 354 |
+
if is_section(group_name):
|
| 355 |
+
title = f'<h2 class="center-text">{LEADERBOARD_ICON_MAP.get(group_name.capitalize() + " Leaderboard", "")} {group_name.capitalize() + " Leaderboard"}</h2>'
|
| 356 |
+
# title
|
| 357 |
+
st.markdown(title, unsafe_allow_html=True)
|
| 358 |
+
|
| 359 |
+
data_engine = st.session_state.get("data_engine", DataEngine())
|
| 360 |
+
|
| 361 |
+
df = data_engine.jsons_to_df().copy()
|
| 362 |
+
|
| 363 |
+
csv = convert_df_to_csv(df)
|
| 364 |
+
file_name = f"{group_name.capitalize()} Leaderboard" if is_section(group_name) else group_name.capitalize()
|
| 365 |
+
|
| 366 |
+
grid = table_area(group_name, grid_state, data_engine, df)
|
| 367 |
+
|
| 368 |
@st.dialog("URL")
|
| 369 |
def share_url():
|
| 370 |
state = grid.grid_state
|
|
|
|
| 396 |
|
| 397 |
if share_btn:
|
| 398 |
share_url()
|
| 399 |
+
|
| 400 |
+
|
| 401 |
+
def render_page(group_name):
|
| 402 |
+
grid_state = st.session_state.get("grid_state", {})
|
| 403 |
+
st.session_state.sider_bar_hidden = True
|
| 404 |
+
st.session_state.table_only = True
|
| 405 |
+
get_column_state()
|
| 406 |
+
|
| 407 |
+
sidebar_css()
|
| 408 |
+
|
| 409 |
+
if st.session_state.get("table_only"):
|
| 410 |
+
table_area(group_name, grid_state)
|
| 411 |
+
else:
|
| 412 |
+
main_page(group_name, grid_state)
|
app/backend/multi_header_util.py
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
handle multi_header options
|
| 3 |
+
"""
|
| 4 |
+
from st_aggrid import JsCode
|
| 5 |
+
from streamlit_theme import st_theme
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
HEADER_STYLE = {'fontSize': '18px'}
|
| 9 |
+
CELL_STYLE = {'fontSize': '18px'}
|
| 10 |
+
LINK = ' https://huggingface.co/datasets/embedding-benchmark/'
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def mutil_header_options(column_list: list, avg_column: str, is_section: bool):
|
| 14 |
+
"""
|
| 15 |
+
get mutil_header_options - 优化版本,减少组件实例化
|
| 16 |
+
:param column_list:
|
| 17 |
+
:param avg_column:
|
| 18 |
+
:param is_section:
|
| 19 |
+
:return:
|
| 20 |
+
"""
|
| 21 |
+
if is_section:
|
| 22 |
+
column_def_list = [
|
| 23 |
+
{'headerName': column if "Average" not in column else column.replace("Average", "").strip().capitalize(),
|
| 24 |
+
'field': column,
|
| 25 |
+
'headerClass': 'custom-header-style',
|
| 26 |
+
'cellClass': 'custom-cell-style',
|
| 27 |
+
'headerTooltip': column if "Average" not in column else column.replace("Average",
|
| 28 |
+
"").strip().capitalize()
|
| 29 |
+
# 'suppressSizeToFit': True
|
| 30 |
+
} for column in column_list if
|
| 31 |
+
column not in (avg_column, "Closed average", "Open average")]
|
| 32 |
+
|
| 33 |
+
return column_def_list
|
| 34 |
+
|
| 35 |
+
mutil_column_list = [column for column in column_list if
|
| 36 |
+
column not in (avg_column, "Closed average", "Open average")]
|
| 37 |
+
close_group_list = list(filter(lambda x: x.startswith('_'), mutil_column_list))
|
| 38 |
+
open_group_list = list(filter(lambda x: not x.startswith('_'), mutil_column_list))
|
| 39 |
+
|
| 40 |
+
theme = st_theme(key="st_theme_1")
|
| 41 |
+
if theme:
|
| 42 |
+
current_theme = theme.get("base", "light")
|
| 43 |
+
else:
|
| 44 |
+
current_theme = "light"
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
close_group_def = {
|
| 49 |
+
'headerName': 'CLOSED DATASETS',
|
| 50 |
+
'children': [
|
| 51 |
+
{'headerName': column.replace('_', ''),
|
| 52 |
+
'field': column,
|
| 53 |
+
|
| 54 |
+
"headerComponentParams": {
|
| 55 |
+
"innerHeaderComponent": "linkHeaderComponent",
|
| 56 |
+
"url": LINK + column.replace('_', ''),
|
| 57 |
+
"headerName": column
|
| 58 |
+
},
|
| 59 |
+
|
| 60 |
+
'headerClass': 'custom-header-style',
|
| 61 |
+
'cellClass': 'custom-cell-style',
|
| 62 |
+
'sortable': True,
|
| 63 |
+
'width': 150,
|
| 64 |
+
# "suppressColumnVirtualisation": True,
|
| 65 |
+
|
| 66 |
+
} for column in close_group_list
|
| 67 |
+
],
|
| 68 |
+
|
| 69 |
+
}
|
| 70 |
+
open_group_def = {
|
| 71 |
+
'headerName': 'OPEN DATASETS',
|
| 72 |
+
'children': [
|
| 73 |
+
{'headerName': column,
|
| 74 |
+
'field': column,
|
| 75 |
+
"headerComponentParams": {
|
| 76 |
+
"innerHeaderComponent": "linkHeaderComponent",
|
| 77 |
+
"url": LINK + column.replace('_', ''),
|
| 78 |
+
"headerName": column
|
| 79 |
+
},
|
| 80 |
+
'headerClass': 'custom-header-style',
|
| 81 |
+
'cellClass': 'custom-cell-style',
|
| 82 |
+
'sortable': True,
|
| 83 |
+
'width': 150,
|
| 84 |
+
"suppressColumnVirtualisation": True,
|
| 85 |
+
|
| 86 |
+
} for column in open_group_list
|
| 87 |
+
],
|
| 88 |
+
|
| 89 |
+
}
|
| 90 |
+
return [close_group_def, open_group_def]
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def get_header_options(column_list: list, avg_column: str, is_section: bool):
|
| 94 |
+
grid_options = {
|
| 95 |
+
'columnDefs': [
|
| 96 |
+
{
|
| 97 |
+
'headerName': 'Model Name',
|
| 98 |
+
'field': 'model_name',
|
| 99 |
+
'pinned': 'left',
|
| 100 |
+
'sortable': False,
|
| 101 |
+
'headerClass': 'custom-header-style',
|
| 102 |
+
'cellClass': 'custom-cell-style',
|
| 103 |
+
'autoHeaderHeight': True,
|
| 104 |
+
"tooltipValueGetter": JsCode(
|
| 105 |
+
"""function(p) {return p.value}"""
|
| 106 |
+
),
|
| 107 |
+
"width": 250,
|
| 108 |
+
'cellRenderer': JsCode("""class CustomHTML {
|
| 109 |
+
init(params) {
|
| 110 |
+
const link = params.data.reference;
|
| 111 |
+
this.eGui = document.createElement('div');
|
| 112 |
+
this.eGui.innerHTML = link ?
|
| 113 |
+
`<a href="${link}" class="a-cell" target="_blank">${params.value} </a>` :
|
| 114 |
+
params.value;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
getGui() {
|
| 118 |
+
return this.eGui;
|
| 119 |
+
}
|
| 120 |
+
}"""),
|
| 121 |
+
'suppressSizeToFit': True
|
| 122 |
+
|
| 123 |
+
},
|
| 124 |
+
{'headerName': "Vendor",
|
| 125 |
+
'field': 'vendor',
|
| 126 |
+
'headerStyle': HEADER_STYLE,
|
| 127 |
+
'cellStyle': CELL_STYLE,
|
| 128 |
+
# 'suppressSizeToFit': True
|
| 129 |
+
},
|
| 130 |
+
{'headerName': "Overall Score",
|
| 131 |
+
'field': avg_column,
|
| 132 |
+
'headerClass': 'custom-header-style',
|
| 133 |
+
'cellClass': 'custom-cell-style',
|
| 134 |
+
# 'suppressSizeToFit': True
|
| 135 |
+
},
|
| 136 |
+
|
| 137 |
+
# Add Open average column definition
|
| 138 |
+
{'headerName': 'Open Average',
|
| 139 |
+
'field': 'Open average',
|
| 140 |
+
'headerClass': 'custom-header-style',
|
| 141 |
+
'cellClass': 'custom-cell-style',
|
| 142 |
+
# 'suppressSizeToFit': True
|
| 143 |
+
},
|
| 144 |
+
|
| 145 |
+
{'headerName': 'Closed Average',
|
| 146 |
+
'field': 'Closed average',
|
| 147 |
+
'headerClass': 'custom-header-style',
|
| 148 |
+
'cellClass': 'custom-cell-style',
|
| 149 |
+
# 'suppressSizeToFit': True
|
| 150 |
+
},
|
| 151 |
+
|
| 152 |
+
{
|
| 153 |
+
'headerName': 'Embd Dtype',
|
| 154 |
+
'field': 'embd_dtype',
|
| 155 |
+
'headerClass': 'custom-header-style',
|
| 156 |
+
'cellClass': 'custom-cell-style',
|
| 157 |
+
# 'suppressSizeToFit': True,
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
'headerName': 'Embd Dim',
|
| 161 |
+
'field': 'embd_dim',
|
| 162 |
+
'headerClass': 'custom-header-style',
|
| 163 |
+
'cellClass': 'custom-cell-style',
|
| 164 |
+
# 'suppressSizeToFit': True,
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
'headerName': 'Number of Parameters',
|
| 168 |
+
'field': 'num_params',
|
| 169 |
+
'cellDataType': 'number',
|
| 170 |
+
"colId": "num_params",
|
| 171 |
+
'headerClass': 'custom-header-style',
|
| 172 |
+
'cellClass': 'custom-cell-style',
|
| 173 |
+
'valueFormatter': JsCode(
|
| 174 |
+
"""function(params) {
|
| 175 |
+
const num = params.value;
|
| 176 |
+
if (num >= 1e9) return (num / 1e9).toFixed(2) + "B";
|
| 177 |
+
if (num >= 1e6) return (num / 1e6).toFixed(2) + "M";
|
| 178 |
+
if (num >= 1e3) return (num / 1e3).toFixed(2) + "K";
|
| 179 |
+
return num;
|
| 180 |
+
}"""
|
| 181 |
+
),
|
| 182 |
+
"width": 120,
|
| 183 |
+
# 'suppressSizeToFit': True,
|
| 184 |
+
},
|
| 185 |
+
{
|
| 186 |
+
'headerName': 'Context Length',
|
| 187 |
+
'field': 'max_tokens',
|
| 188 |
+
'headerClass': 'custom-header-style',
|
| 189 |
+
'cellClass': 'custom-cell-style',
|
| 190 |
+
# 'suppressSizeToFit': True,
|
| 191 |
+
},
|
| 192 |
+
|
| 193 |
+
*mutil_header_options(column_list, avg_column, is_section)
|
| 194 |
+
],
|
| 195 |
+
'defaultColDef': {
|
| 196 |
+
'filter': True,
|
| 197 |
+
'sortable': True,
|
| 198 |
+
'resizable': True,
|
| 199 |
+
'headerClass': "multi-line-header",
|
| 200 |
+
'autoHeaderHeight': True,
|
| 201 |
+
'width': 105
|
| 202 |
+
},
|
| 203 |
+
|
| 204 |
+
"autoSizeStrategy": {
|
| 205 |
+
"type": 'fitCellContents',
|
| 206 |
+
"colIds": [column for column in column_list if column not in (avg_column, "Closed average", "Open average")]
|
| 207 |
+
},
|
| 208 |
+
"tooltipShowDelay": 500,
|
| 209 |
+
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
return grid_options
|
requirements.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
streamlit==1.47.1
|
| 2 |
-
streamlit-aggrid==1.1.7
|
| 3 |
st-pages==1.0.1
|
| 4 |
msgpack==1.1.0
|
| 5 |
zstandard==0.23.0
|
| 6 |
-
st-theme==1.2.3
|
|
|
|
|
|
| 1 |
streamlit==1.47.1
|
|
|
|
| 2 |
st-pages==1.0.1
|
| 3 |
msgpack==1.1.0
|
| 4 |
zstandard==0.23.0
|
| 5 |
+
st-theme==1.2.3
|
| 6 |
+
https://github.com/q275343119/streamlit-aggrid-link_header/releases/download/v0.0.2/streamlit_aggrid-1.1.7-py3-none-any.whl
|