DontPlanToEnd
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,20 @@ def load_leaderboard_data(csv_file_path):
|
|
19 |
try:
|
20 |
df = pd.read_csv(csv_file_path, na_values=['NA'])
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# Convert date columns to datetime and then to ISO format strings
|
23 |
for col in ['Release Date', 'Test Date']:
|
24 |
df[col] = pd.to_datetime(df[col], format='%m/%d/%Y', errors='coerce')
|
@@ -115,7 +129,6 @@ app.index_string = '''
|
|
115 |
--pinned-bg: #f5f5f5;
|
116 |
--border-color: #ccc;
|
117 |
}
|
118 |
-
|
119 |
@media (prefers-color-scheme: dark) {
|
120 |
:root {
|
121 |
--bg-color: #0d1117;
|
@@ -128,7 +141,6 @@ app.index_string = '''
|
|
128 |
--border-color: #30363d;
|
129 |
}
|
130 |
}
|
131 |
-
|
132 |
body {
|
133 |
font-family: 'Segoe UI', Arial, sans-serif;
|
134 |
margin: 0;
|
@@ -136,7 +148,6 @@ app.index_string = '''
|
|
136 |
background-color: var(--bg-color);
|
137 |
color: var(--text-color);
|
138 |
}
|
139 |
-
|
140 |
/* Header and Title Styles */
|
141 |
.page-title {
|
142 |
text-align: center;
|
@@ -144,7 +155,6 @@ app.index_string = '''
|
|
144 |
font-size: 38px;
|
145 |
color: var(--text-color) !important;
|
146 |
}
|
147 |
-
|
148 |
.page-subtitle {
|
149 |
text-align: center;
|
150 |
margin: 0;
|
@@ -152,7 +162,6 @@ app.index_string = '''
|
|
152 |
font-weight: 600;
|
153 |
color: var(--text-color) !important;
|
154 |
}
|
155 |
-
|
156 |
/* Filter Styles */
|
157 |
.model-type-filter label,
|
158 |
#model-type-filter label,
|
@@ -161,11 +170,9 @@ app.index_string = '''
|
|
161 |
margin-right: 10px;
|
162 |
font-weight: bold;
|
163 |
}
|
164 |
-
|
165 |
.filter-description {
|
166 |
color: var(--secondary-text) !important;
|
167 |
}
|
168 |
-
|
169 |
/* Grid Styles */
|
170 |
.ag-theme-alpine {
|
171 |
--ag-font-family: 'Segoe UI', Arial, sans-serif;
|
@@ -178,29 +185,23 @@ app.index_string = '''
|
|
178 |
--ag-foreground-color: var(--text-color);
|
179 |
--ag-row-border-color: var(--grid-border);
|
180 |
}
|
181 |
-
|
182 |
.ag-floating-top {
|
183 |
border-bottom: 3px solid var(--border-color) !important;
|
184 |
}
|
185 |
-
|
186 |
.ag-floating-top:empty {
|
187 |
border-bottom: none !important;
|
188 |
}
|
189 |
-
|
190 |
.pinned-row {
|
191 |
background-color: var(--pinned-bg) !important;
|
192 |
font-weight: 500;
|
193 |
}
|
194 |
-
|
195 |
/* Text Alignment Classes */
|
196 |
.ag-left-aligned-header {
|
197 |
text-align: left !important;
|
198 |
}
|
199 |
-
|
200 |
.ag-left-aligned-cell {
|
201 |
text-align: left !important;
|
202 |
}
|
203 |
-
|
204 |
.ag-header-cell-text {
|
205 |
white-space: normal !important;
|
206 |
line-height: 1.2em;
|
@@ -211,40 +212,32 @@ app.index_string = '''
|
|
211 |
height: auto !important;
|
212 |
min-height: 48px;
|
213 |
}
|
214 |
-
|
215 |
.wrap-text {
|
216 |
white-space: normal !important;
|
217 |
line-height: 1.2em;
|
218 |
}
|
219 |
-
|
220 |
.no-break {
|
221 |
white-space: nowrap !important;
|
222 |
}
|
223 |
-
|
224 |
/* Border Classes */
|
225 |
.border-left {
|
226 |
border-left: 2px solid var(--grid-border) !important;
|
227 |
}
|
228 |
-
|
229 |
.border-right {
|
230 |
border-right: 2px solid var(--grid-border) !important;
|
231 |
}
|
232 |
-
|
233 |
/* Link Styles */
|
234 |
.model-link {
|
235 |
color: var(--link-color) !important;
|
236 |
text-decoration: none;
|
237 |
}
|
238 |
-
|
239 |
.model-link:hover {
|
240 |
text-decoration: underline;
|
241 |
}
|
242 |
-
|
243 |
.source-link {
|
244 |
color: var(--link-color) !important;
|
245 |
text-decoration: none;
|
246 |
}
|
247 |
-
|
248 |
/* Details/Summary Styles */
|
249 |
.details-summary {
|
250 |
cursor: pointer;
|
@@ -253,41 +246,33 @@ app.index_string = '''
|
|
253 |
margin-top: 20px;
|
254 |
color: var(--text-color) !important;
|
255 |
}
|
256 |
-
|
257 |
.ideology-note {
|
258 |
color: var(--secondary-text) !important;
|
259 |
font-size: 0.9em;
|
260 |
}
|
261 |
-
|
262 |
/* Markdown Content */
|
263 |
.markdown-content {
|
264 |
color: var(--text-color) !important;
|
265 |
}
|
266 |
-
|
267 |
.markdown-content a {
|
268 |
color: var(--link-color) !important;
|
269 |
}
|
270 |
-
|
271 |
/* Ko-fi Button Visibility */
|
272 |
.kofi-light {
|
273 |
display: none;
|
274 |
}
|
275 |
-
|
276 |
.kofi-dark {
|
277 |
display: none;
|
278 |
}
|
279 |
-
|
280 |
@media (prefers-color-scheme: light) {
|
281 |
.kofi-light {
|
282 |
display: block;
|
283 |
}
|
284 |
}
|
285 |
-
|
286 |
@media (prefers-color-scheme: dark) {
|
287 |
.kofi-dark {
|
288 |
display: block;
|
289 |
}
|
290 |
-
|
291 |
/* Dark Theme Specific Overrides */
|
292 |
.ag-theme-alpine {
|
293 |
--ag-background-color: #161b22 !important;
|
@@ -303,15 +288,12 @@ app.index_string = '''
|
|
303 |
--ag-selected-row-background-color: #1c2128 !important;
|
304 |
--ag-row-hover-color: #1c2128 !important;
|
305 |
}
|
306 |
-
|
307 |
.ag-header-cell-filtered {
|
308 |
background-color: rgba(88, 166, 255, 0.1) !important;
|
309 |
}
|
310 |
-
|
311 |
input[type="checkbox"] {
|
312 |
accent-color: var(--link-color);
|
313 |
}
|
314 |
-
|
315 |
/* Ensure text colors in dark mode */
|
316 |
.page-title,
|
317 |
.page-subtitle,
|
@@ -320,7 +302,6 @@ app.index_string = '''
|
|
320 |
#na-model-filter label {
|
321 |
color: #e6e6e6 !important;
|
322 |
}
|
323 |
-
|
324 |
.filter-description,
|
325 |
.ideology-note {
|
326 |
color: #8b949e !important;
|
@@ -333,7 +314,6 @@ app.index_string = '''
|
|
333 |
.markdown-content a:visited {
|
334 |
color: var(--link-color) !important;
|
335 |
}
|
336 |
-
|
337 |
.split-header-container {
|
338 |
display: flex;
|
339 |
flex-direction: column;
|
@@ -433,9 +413,9 @@ columnDefs = [
|
|
433 |
{
|
434 |
"field": "#P",
|
435 |
"width": 115,
|
436 |
-
"filter": "
|
437 |
"filterParams": {
|
438 |
-
"defaultOption": "
|
439 |
"filterOptions": ['equals', 'notEqual', 'greaterThan', 'greaterThanOrEqual', 'lessThan', 'lessThanOrEqual', 'inRange']
|
440 |
},
|
441 |
"headerClass": "ag-left-aligned-header wrap-text",
|
@@ -446,6 +426,21 @@ columnDefs = [
|
|
446 |
"sortingOrder": ['desc', 'asc'],
|
447 |
"pinned": "left"
|
448 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
{
|
450 |
"field": "Model_Display",
|
451 |
"headerName": "Model",
|
@@ -653,39 +648,40 @@ dashGridOptions = {
|
|
653 |
"ensureDomOrder": True,
|
654 |
"suppressRowClickSelection": True,
|
655 |
"suppressCellFocus": True,
|
656 |
-
"getRowId": "
|
657 |
"pinnedTopRowData": [],
|
658 |
"sortingOrder": ['desc', 'asc'],
|
659 |
"suppressMaintainUnsortedOrder": True,
|
660 |
"rowBuffer": 10,
|
661 |
"maxBlocksInCache": 2,
|
662 |
-
"
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
}
|
682 |
-
});
|
683 |
-
}
|
684 |
-
"""
|
685 |
}
|
686 |
|
687 |
# Define the layout
|
688 |
app.layout = html.Div([
|
|
|
|
|
|
|
|
|
|
|
689 |
# Header
|
690 |
html.Div([
|
691 |
html.Div([
|
@@ -736,12 +732,12 @@ app.layout = html.Div([
|
|
736 |
dcc.Checklist(
|
737 |
id='model-type-filter',
|
738 |
options=[
|
|
|
739 |
{'label': 'Finetune', 'value': 'Is Finetuned'},
|
740 |
{'label': 'Merge', 'value': 'Is Merged'},
|
741 |
-
{'label': 'Foundation', 'value': 'Is Foundation'},
|
742 |
{'label': 'Proprietary', 'value': 'proprietary'}
|
743 |
],
|
744 |
-
value=['Is
|
745 |
inline=True,
|
746 |
style={'display': 'inline-block'}
|
747 |
)
|
@@ -795,7 +791,9 @@ app.layout = html.Div([
|
|
795 |
dashGridOptions=dashGridOptions,
|
796 |
dangerously_allow_code=True,
|
797 |
className="ag-theme-alpine",
|
798 |
-
style={"height": "600px", "width": "100%"}
|
|
|
|
|
799 |
)
|
800 |
], style={'marginBottom': '30px'}),
|
801 |
|
@@ -871,41 +869,46 @@ app.layout = html.Div([
|
|
871 |
def debug_callback(value):
|
872 |
print("Model filter value:", value)
|
873 |
return value
|
874 |
-
|
875 |
@app.callback(
|
876 |
[Output('leaderboard-grid', 'rowData'),
|
877 |
-
Output('model-type-filter', 'value')
|
|
|
878 |
[Input('model-type-filter', 'value'),
|
879 |
-
Input('na-model-filter', 'value')
|
|
|
880 |
prevent_initial_call=False
|
881 |
)
|
882 |
-
def
|
883 |
if selected_types is None:
|
884 |
selected_types = []
|
885 |
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
return [], updated_types
|
890 |
-
|
891 |
filtered_df = df.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
892 |
mask = pd.Series(False, index=filtered_df.index)
|
893 |
|
894 |
# Model type filtering
|
895 |
-
if 'Is Finetuned' in
|
896 |
-
if 'Is Merged' in
|
897 |
-
# Show both regular finetuned and merged models
|
898 |
mask |= filtered_df['Is Finetuned']
|
899 |
else:
|
900 |
-
# Show only regular finetuned models (not merged)
|
901 |
mask |= (filtered_df['Is Finetuned'] & ~filtered_df['Is Merged'])
|
902 |
-
elif 'Is Merged' in
|
903 |
-
# Show only merged models
|
904 |
mask |= filtered_df['Is Merged']
|
905 |
|
906 |
-
if 'Is Foundation' in
|
907 |
mask |= (filtered_df['Is Foundation'] & ~filtered_df['Total Parameters'].isna())
|
908 |
-
if 'proprietary' in
|
909 |
mask |= filtered_df['Total Parameters'].isna()
|
910 |
|
911 |
filtered_df = filtered_df[mask]
|
@@ -914,11 +917,15 @@ def filter_models(selected_types, show_na):
|
|
914 |
political_columns = ['Political Lean 📋', 'govt', 'dipl', 'econ', 'scty'] + AXES_COLS_2
|
915 |
has_na = filtered_df[political_columns].isna().any(axis=1)
|
916 |
|
917 |
-
if show_na is None or not show_na:
|
918 |
filtered_df = filtered_df[~has_na]
|
919 |
|
|
|
920 |
filtered_df = filtered_df.sort_values('UGI 🏆', ascending=False)
|
921 |
-
|
|
|
|
|
|
|
922 |
|
923 |
@app.callback(
|
924 |
Output('ideology-descriptions', 'children'),
|
@@ -956,4 +963,30 @@ if __name__ == '__main__':
|
|
956 |
Output('leaderboard-grid', 'rowData'),
|
957 |
Input('leaderboard-grid', 'cellRendererData'),
|
958 |
State('leaderboard-grid', 'rowData')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
959 |
)
|
|
|
19 |
try:
|
20 |
df = pd.read_csv(csv_file_path, na_values=['NA'])
|
21 |
|
22 |
+
# Add type sort value
|
23 |
+
def get_type_sort_value(row):
|
24 |
+
if pd.isna(row['Total Parameters']):
|
25 |
+
return 3 # P
|
26 |
+
if row['Is Foundation'] and not row['Is Merged']:
|
27 |
+
return 0 # B
|
28 |
+
if row['Is Merged']:
|
29 |
+
return 2 # M
|
30 |
+
if row['Is Finetuned'] and not row['Is Merged']:
|
31 |
+
return 1 # F
|
32 |
+
return 4
|
33 |
+
|
34 |
+
df['model_type_sort'] = df.apply(get_type_sort_value, axis=1)
|
35 |
+
|
36 |
# Convert date columns to datetime and then to ISO format strings
|
37 |
for col in ['Release Date', 'Test Date']:
|
38 |
df[col] = pd.to_datetime(df[col], format='%m/%d/%Y', errors='coerce')
|
|
|
129 |
--pinned-bg: #f5f5f5;
|
130 |
--border-color: #ccc;
|
131 |
}
|
|
|
132 |
@media (prefers-color-scheme: dark) {
|
133 |
:root {
|
134 |
--bg-color: #0d1117;
|
|
|
141 |
--border-color: #30363d;
|
142 |
}
|
143 |
}
|
|
|
144 |
body {
|
145 |
font-family: 'Segoe UI', Arial, sans-serif;
|
146 |
margin: 0;
|
|
|
148 |
background-color: var(--bg-color);
|
149 |
color: var(--text-color);
|
150 |
}
|
|
|
151 |
/* Header and Title Styles */
|
152 |
.page-title {
|
153 |
text-align: center;
|
|
|
155 |
font-size: 38px;
|
156 |
color: var(--text-color) !important;
|
157 |
}
|
|
|
158 |
.page-subtitle {
|
159 |
text-align: center;
|
160 |
margin: 0;
|
|
|
162 |
font-weight: 600;
|
163 |
color: var(--text-color) !important;
|
164 |
}
|
|
|
165 |
/* Filter Styles */
|
166 |
.model-type-filter label,
|
167 |
#model-type-filter label,
|
|
|
170 |
margin-right: 10px;
|
171 |
font-weight: bold;
|
172 |
}
|
|
|
173 |
.filter-description {
|
174 |
color: var(--secondary-text) !important;
|
175 |
}
|
|
|
176 |
/* Grid Styles */
|
177 |
.ag-theme-alpine {
|
178 |
--ag-font-family: 'Segoe UI', Arial, sans-serif;
|
|
|
185 |
--ag-foreground-color: var(--text-color);
|
186 |
--ag-row-border-color: var(--grid-border);
|
187 |
}
|
|
|
188 |
.ag-floating-top {
|
189 |
border-bottom: 3px solid var(--border-color) !important;
|
190 |
}
|
|
|
191 |
.ag-floating-top:empty {
|
192 |
border-bottom: none !important;
|
193 |
}
|
|
|
194 |
.pinned-row {
|
195 |
background-color: var(--pinned-bg) !important;
|
196 |
font-weight: 500;
|
197 |
}
|
|
|
198 |
/* Text Alignment Classes */
|
199 |
.ag-left-aligned-header {
|
200 |
text-align: left !important;
|
201 |
}
|
|
|
202 |
.ag-left-aligned-cell {
|
203 |
text-align: left !important;
|
204 |
}
|
|
|
205 |
.ag-header-cell-text {
|
206 |
white-space: normal !important;
|
207 |
line-height: 1.2em;
|
|
|
212 |
height: auto !important;
|
213 |
min-height: 48px;
|
214 |
}
|
|
|
215 |
.wrap-text {
|
216 |
white-space: normal !important;
|
217 |
line-height: 1.2em;
|
218 |
}
|
|
|
219 |
.no-break {
|
220 |
white-space: nowrap !important;
|
221 |
}
|
|
|
222 |
/* Border Classes */
|
223 |
.border-left {
|
224 |
border-left: 2px solid var(--grid-border) !important;
|
225 |
}
|
|
|
226 |
.border-right {
|
227 |
border-right: 2px solid var(--grid-border) !important;
|
228 |
}
|
|
|
229 |
/* Link Styles */
|
230 |
.model-link {
|
231 |
color: var(--link-color) !important;
|
232 |
text-decoration: none;
|
233 |
}
|
|
|
234 |
.model-link:hover {
|
235 |
text-decoration: underline;
|
236 |
}
|
|
|
237 |
.source-link {
|
238 |
color: var(--link-color) !important;
|
239 |
text-decoration: none;
|
240 |
}
|
|
|
241 |
/* Details/Summary Styles */
|
242 |
.details-summary {
|
243 |
cursor: pointer;
|
|
|
246 |
margin-top: 20px;
|
247 |
color: var(--text-color) !important;
|
248 |
}
|
|
|
249 |
.ideology-note {
|
250 |
color: var(--secondary-text) !important;
|
251 |
font-size: 0.9em;
|
252 |
}
|
|
|
253 |
/* Markdown Content */
|
254 |
.markdown-content {
|
255 |
color: var(--text-color) !important;
|
256 |
}
|
|
|
257 |
.markdown-content a {
|
258 |
color: var(--link-color) !important;
|
259 |
}
|
|
|
260 |
/* Ko-fi Button Visibility */
|
261 |
.kofi-light {
|
262 |
display: none;
|
263 |
}
|
|
|
264 |
.kofi-dark {
|
265 |
display: none;
|
266 |
}
|
|
|
267 |
@media (prefers-color-scheme: light) {
|
268 |
.kofi-light {
|
269 |
display: block;
|
270 |
}
|
271 |
}
|
|
|
272 |
@media (prefers-color-scheme: dark) {
|
273 |
.kofi-dark {
|
274 |
display: block;
|
275 |
}
|
|
|
276 |
/* Dark Theme Specific Overrides */
|
277 |
.ag-theme-alpine {
|
278 |
--ag-background-color: #161b22 !important;
|
|
|
288 |
--ag-selected-row-background-color: #1c2128 !important;
|
289 |
--ag-row-hover-color: #1c2128 !important;
|
290 |
}
|
|
|
291 |
.ag-header-cell-filtered {
|
292 |
background-color: rgba(88, 166, 255, 0.1) !important;
|
293 |
}
|
|
|
294 |
input[type="checkbox"] {
|
295 |
accent-color: var(--link-color);
|
296 |
}
|
|
|
297 |
/* Ensure text colors in dark mode */
|
298 |
.page-title,
|
299 |
.page-subtitle,
|
|
|
302 |
#na-model-filter label {
|
303 |
color: #e6e6e6 !important;
|
304 |
}
|
|
|
305 |
.filter-description,
|
306 |
.ideology-note {
|
307 |
color: #8b949e !important;
|
|
|
314 |
.markdown-content a:visited {
|
315 |
color: var(--link-color) !important;
|
316 |
}
|
|
|
317 |
.split-header-container {
|
318 |
display: flex;
|
319 |
flex-direction: column;
|
|
|
413 |
{
|
414 |
"field": "#P",
|
415 |
"width": 115,
|
416 |
+
"filter": "equals",
|
417 |
"filterParams": {
|
418 |
+
"defaultOption": "inRange",
|
419 |
"filterOptions": ['equals', 'notEqual', 'greaterThan', 'greaterThanOrEqual', 'lessThan', 'lessThanOrEqual', 'inRange']
|
420 |
},
|
421 |
"headerClass": "ag-left-aligned-header wrap-text",
|
|
|
426 |
"sortingOrder": ['desc', 'asc'],
|
427 |
"pinned": "left"
|
428 |
},
|
429 |
+
{
|
430 |
+
"field": "model_type_sort",
|
431 |
+
"hide": True
|
432 |
+
},
|
433 |
+
{
|
434 |
+
"headerName": "T",
|
435 |
+
"field": "model_type_sort", # Changed to use the sort field directly
|
436 |
+
"width": 45,
|
437 |
+
"filter": False,
|
438 |
+
"suppressMenu": True,
|
439 |
+
"cellRenderer": "TypeRenderer",
|
440 |
+
"pinned": "left",
|
441 |
+
"sortable": True,
|
442 |
+
"sortingOrder": ['asc', 'desc']
|
443 |
+
},
|
444 |
{
|
445 |
"field": "Model_Display",
|
446 |
"headerName": "Model",
|
|
|
648 |
"ensureDomOrder": True,
|
649 |
"suppressRowClickSelection": True,
|
650 |
"suppressCellFocus": True,
|
651 |
+
"getRowId": "params => params.data.Model_Display",
|
652 |
"pinnedTopRowData": [],
|
653 |
"sortingOrder": ['desc', 'asc'],
|
654 |
"suppressMaintainUnsortedOrder": True,
|
655 |
"rowBuffer": 10,
|
656 |
"maxBlocksInCache": 2,
|
657 |
+
"onGridReady": {
|
658 |
+
"function": """
|
659 |
+
function(params) {
|
660 |
+
console.log('Grid ready');
|
661 |
+
window.gridApi = params.api;
|
662 |
+
}
|
663 |
+
"""
|
664 |
+
},
|
665 |
+
"onRowDataChanged": {
|
666 |
+
"function": """
|
667 |
+
function(params) {
|
668 |
+
console.log('Row data changed event');
|
669 |
+
console.log('Current pinned rows:', params.api.getGridOption('pinnedTopRowData'));
|
670 |
+
console.log('Current main rows:', []);
|
671 |
+
params.api.forEachNode(node => console.log(node.data.Model_Display));
|
672 |
+
}
|
673 |
+
"""
|
674 |
+
},
|
675 |
+
"theme": "ag-theme-alpine-dark" if "prefers-color-scheme: dark" else "ag-theme-alpine"
|
|
|
|
|
|
|
|
|
676 |
}
|
677 |
|
678 |
# Define the layout
|
679 |
app.layout = html.Div([
|
680 |
+
dcc.Store(id='pinned-rows-store', data=[]),
|
681 |
+
dcc.Store(id='pinned-ids-store', data=[]),
|
682 |
+
dcc.Store(id='pinned-models-store', data=[]),
|
683 |
+
dcc.Store(id='filter-change-trigger', data=0),
|
684 |
+
|
685 |
# Header
|
686 |
html.Div([
|
687 |
html.Div([
|
|
|
732 |
dcc.Checklist(
|
733 |
id='model-type-filter',
|
734 |
options=[
|
735 |
+
{'label': 'Base', 'value': 'Is Foundation'},
|
736 |
{'label': 'Finetune', 'value': 'Is Finetuned'},
|
737 |
{'label': 'Merge', 'value': 'Is Merged'},
|
|
|
738 |
{'label': 'Proprietary', 'value': 'proprietary'}
|
739 |
],
|
740 |
+
value=['Is Foundation', 'Is Finetuned', 'Is Merged', 'proprietary'], # All checked by default
|
741 |
inline=True,
|
742 |
style={'display': 'inline-block'}
|
743 |
)
|
|
|
791 |
dashGridOptions=dashGridOptions,
|
792 |
dangerously_allow_code=True,
|
793 |
className="ag-theme-alpine",
|
794 |
+
style={"height": "600px", "width": "100%"},
|
795 |
+
enableEnterpriseModules=False,
|
796 |
+
getRowId="params.data.Model_Display"
|
797 |
)
|
798 |
], style={'marginBottom': '30px'}),
|
799 |
|
|
|
869 |
def debug_callback(value):
|
870 |
print("Model filter value:", value)
|
871 |
return value
|
872 |
+
|
873 |
@app.callback(
|
874 |
[Output('leaderboard-grid', 'rowData'),
|
875 |
+
Output('model-type-filter', 'value'),
|
876 |
+
Output('pinned-models-store', 'data')], # Add this output
|
877 |
[Input('model-type-filter', 'value'),
|
878 |
+
Input('na-model-filter', 'value'),
|
879 |
+
Input('leaderboard-grid', 'pinnedTopRowData')], # Add this input
|
880 |
prevent_initial_call=False
|
881 |
)
|
882 |
+
def update_grid(selected_types, show_na, pinned_rows):
|
883 |
if selected_types is None:
|
884 |
selected_types = []
|
885 |
|
886 |
+
if not selected_types:
|
887 |
+
return [], selected_types, []
|
888 |
+
|
|
|
|
|
889 |
filtered_df = df.copy()
|
890 |
+
|
891 |
+
# Get pinned model IDs
|
892 |
+
pinned_models = []
|
893 |
+
if pinned_rows:
|
894 |
+
pinned_models = [row['Model_Display'] for row in pinned_rows]
|
895 |
+
# Remove pinned models from the dataframe
|
896 |
+
filtered_df = filtered_df[~filtered_df['Model_Display'].isin(pinned_models)]
|
897 |
+
|
898 |
mask = pd.Series(False, index=filtered_df.index)
|
899 |
|
900 |
# Model type filtering
|
901 |
+
if 'Is Finetuned' in selected_types:
|
902 |
+
if 'Is Merged' in selected_types:
|
|
|
903 |
mask |= filtered_df['Is Finetuned']
|
904 |
else:
|
|
|
905 |
mask |= (filtered_df['Is Finetuned'] & ~filtered_df['Is Merged'])
|
906 |
+
elif 'Is Merged' in selected_types:
|
|
|
907 |
mask |= filtered_df['Is Merged']
|
908 |
|
909 |
+
if 'Is Foundation' in selected_types:
|
910 |
mask |= (filtered_df['Is Foundation'] & ~filtered_df['Total Parameters'].isna())
|
911 |
+
if 'proprietary' in selected_types:
|
912 |
mask |= filtered_df['Total Parameters'].isna()
|
913 |
|
914 |
filtered_df = filtered_df[mask]
|
|
|
917 |
political_columns = ['Political Lean 📋', 'govt', 'dipl', 'econ', 'scty'] + AXES_COLS_2
|
918 |
has_na = filtered_df[political_columns].isna().any(axis=1)
|
919 |
|
920 |
+
if show_na is None or not show_na:
|
921 |
filtered_df = filtered_df[~has_na]
|
922 |
|
923 |
+
# Sort by UGI
|
924 |
filtered_df = filtered_df.sort_values('UGI 🏆', ascending=False)
|
925 |
+
|
926 |
+
records = filtered_df.to_dict('records')
|
927 |
+
|
928 |
+
return records, selected_types, pinned_models
|
929 |
|
930 |
@app.callback(
|
931 |
Output('ideology-descriptions', 'children'),
|
|
|
963 |
Output('leaderboard-grid', 'rowData'),
|
964 |
Input('leaderboard-grid', 'cellRendererData'),
|
965 |
State('leaderboard-grid', 'rowData')
|
966 |
+
)
|
967 |
+
app.clientside_callback(
|
968 |
+
"""
|
969 |
+
function(n_clicks) {
|
970 |
+
if (!window.gridApi) return;
|
971 |
+
|
972 |
+
console.log('Filter changed');
|
973 |
+
const pinnedRows = window.gridApi.getGridOption('pinnedTopRowData') || [];
|
974 |
+
console.log('Current pinned rows:', pinnedRows.map(r => r.Model_Display));
|
975 |
+
|
976 |
+
if (pinnedRows.length > 0) {
|
977 |
+
const pinnedIds = new Set(pinnedRows.map(row => row.Model_Display));
|
978 |
+
const currentRows = [];
|
979 |
+
window.gridApi.forEachNode(node => {
|
980 |
+
if (!pinnedIds.has(node.data.Model_Display)) {
|
981 |
+
currentRows.push(node.data);
|
982 |
+
}
|
983 |
+
});
|
984 |
+
console.log('Filtering out pinned rows');
|
985 |
+
window.gridApi.setGridOption('rowData', currentRows);
|
986 |
+
}
|
987 |
+
return window.dash_clientside.no_update;
|
988 |
+
}
|
989 |
+
""",
|
990 |
+
Output('leaderboard-grid', 'rowData'),
|
991 |
+
Input('model-type-filter', 'value')
|
992 |
)
|