DontPlanToEnd commited on
Commit
6726d45
·
verified ·
1 Parent(s): 4132cb8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -24
app.py CHANGED
@@ -580,6 +580,31 @@ political_columns = [
580
  }
581
  ]
582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
583
  # Add axes columns with different widths
584
  for i, col in enumerate(AXES_COLS_1):
585
  col_def = {
@@ -815,20 +840,32 @@ app.layout = html.Div([
815
 
816
  # Additional Columns Filter
817
  html.Div([
818
- html.Label("Show Additional Columns:",
819
- className="model-type-filter"), # Use same class for consistent styling
820
- dcc.Checklist(
821
- id='additional-columns-filter',
822
- options=[
823
- {'label': 'UGI Categories', 'value': 'ugi_categories'},
824
- {'label': 'W/10 Types', 'value': 'w10_types'},
825
- {'label': 'Political Test Axes', 'value': 'political_axes'}
826
- ],
827
- value=[],
828
- inline=True,
829
- style={'display': 'inline-block'},
830
- labelStyle={'fontWeight': 'normal', 'marginRight': '15px'}
831
- )
 
 
 
 
 
 
 
 
 
 
 
 
832
  ], style={'marginBottom': '13px', 'padding': '0 20px', 'overflow': 'hidden'}),
833
 
834
  # Grid
@@ -1044,33 +1081,35 @@ def update_grid(selected_types, show_na, pinned_rows):
1044
 
1045
  @app.callback(
1046
  Output('leaderboard-grid', 'columnDefs'),
1047
- [Input('additional-columns-filter', 'value')]
 
1048
  )
1049
- def update_columns(additional_columns):
1050
  # Start with base columns up to UGI column
1051
- current_columns = columnDefs[:7] # Include up to UGI column
 
 
 
 
 
 
 
1052
 
1053
- # Add UGI category columns if selected
1054
  if 'ugi_categories' in additional_columns:
1055
  current_columns.extend(ugi_category_columns)
1056
 
1057
- # Add W/10 column
1058
- current_columns.extend(columnDefs[7:8]) # Add just the W/10 column
1059
 
1060
- # Add W/10 type columns if selected
1061
  if 'w10_types' in additional_columns:
1062
  current_columns.extend(w10_type_columns)
1063
 
1064
- # Add remaining base columns (NatInt, Coding, Political Lean)
1065
  current_columns.extend(columnDefs[8:11])
1066
 
1067
- # Add political columns if selected
1068
  if 'political_axes' in additional_columns:
1069
  current_columns.extend(political_columns)
1070
  current_columns.extend([col for col in columnDefs if col['field'] in AXES_COLS_1])
1071
  current_columns.extend([col for col in columnDefs if col['field'] in AXES_COLS_2])
1072
 
1073
- # Always add date columns at the end
1074
  current_columns.extend([col for col in columnDefs if col['field'] in ['Release Date', 'Test Date']])
1075
 
1076
  return current_columns
 
580
  }
581
  ]
582
 
583
+ template_column = {
584
+ "field": "Prompt Template",
585
+ "headerName": "Template",
586
+ "width": 150,
587
+ "filter": "agTextColumnFilter",
588
+ "filterParams": {
589
+ "defaultOption": "contains",
590
+ "filterOptions": ['contains', 'notContains', 'startsWith', 'endsWith']
591
+ },
592
+ "headerClass": "ag-left-aligned-header wrap-text",
593
+ "cellClass": "ag-left-aligned-cell",
594
+ "wrapHeaderText": True,
595
+ "autoHeaderHeight": True,
596
+ "comparator": {
597
+ "function": """
598
+ function(valueA, valueB) {
599
+ if (!valueA && !valueB) return 0;
600
+ if (!valueA) return 1;
601
+ if (!valueB) return -1;
602
+ return valueA.toLowerCase().localeCompare(valueB.toLowerCase());
603
+ }
604
+ """
605
+ }
606
+ }
607
+
608
  # Add axes columns with different widths
609
  for i, col in enumerate(AXES_COLS_1):
610
  col_def = {
 
840
 
841
  # Additional Columns Filter
842
  html.Div([
843
+ html.Div([
844
+ html.Label("Show Additional Columns:",
845
+ className="model-type-filter"),
846
+ dcc.Checklist(
847
+ id='additional-columns-filter',
848
+ options=[
849
+ {'label': 'UGI Categories', 'value': 'ugi_categories'},
850
+ {'label': 'W/10 Types', 'value': 'w10_types'},
851
+ {'label': 'Political Test Axes', 'value': 'political_axes'}
852
+ ],
853
+ value=[],
854
+ inline=True,
855
+ style={'display': 'inline-block'},
856
+ labelStyle={'fontWeight': 'normal', 'marginRight': '15px'}
857
+ )
858
+ ], style={'float': 'left'}),
859
+ html.Div([
860
+ dcc.Checklist(
861
+ id='template-filter',
862
+ options=[{'label': 'Template', 'value': 'template'}],
863
+ value=[],
864
+ inline=True,
865
+ style={'display': 'inline-block'},
866
+ labelStyle={'fontWeight': 'normal'}
867
+ )
868
+ ], style={'float': 'right'})
869
  ], style={'marginBottom': '13px', 'padding': '0 20px', 'overflow': 'hidden'}),
870
 
871
  # Grid
 
1081
 
1082
  @app.callback(
1083
  Output('leaderboard-grid', 'columnDefs'),
1084
+ [Input('additional-columns-filter', 'value'),
1085
+ Input('template-filter', 'value')]
1086
  )
1087
+ def update_columns(additional_columns, template_filter):
1088
  # Start with base columns up to UGI column
1089
+ current_columns = columnDefs[:6] # Include up to Model column
1090
+
1091
+ # Add Template column if selected
1092
+ if template_filter and 'template' in template_filter:
1093
+ current_columns.append(template_column)
1094
+
1095
+ # Rest of the function remains the same...
1096
+ current_columns.extend(columnDefs[6:7])
1097
 
 
1098
  if 'ugi_categories' in additional_columns:
1099
  current_columns.extend(ugi_category_columns)
1100
 
1101
+ current_columns.extend(columnDefs[7:8])
 
1102
 
 
1103
  if 'w10_types' in additional_columns:
1104
  current_columns.extend(w10_type_columns)
1105
 
 
1106
  current_columns.extend(columnDefs[8:11])
1107
 
 
1108
  if 'political_axes' in additional_columns:
1109
  current_columns.extend(political_columns)
1110
  current_columns.extend([col for col in columnDefs if col['field'] in AXES_COLS_1])
1111
  current_columns.extend([col for col in columnDefs if col['field'] in AXES_COLS_2])
1112
 
 
1113
  current_columns.extend([col for col in columnDefs if col['field'] in ['Release Date', 'Test Date']])
1114
 
1115
  return current_columns