Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -861,14 +861,119 @@ with gr.Blocks(css=css) as demo: | |
| 861 | 
             
                    category_chart = gr.Plot(value=initial_plot)
         | 
| 862 |  | 
| 863 | 
             
                # Make detailed scorecard tab visible by default
         | 
| 864 | 
            -
                # Initialize with StarCoder2 data
         | 
| 865 | 
             
                default_model = "StarCoder2"
         | 
| 866 | 
            -
                 | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 867 |  | 
| 868 | 
             
                with gr.Column(visible=True) as detailed_scorecard_tab:
         | 
| 869 | 
            -
                    model_metadata = gr.HTML(value= | 
| 870 | 
            -
                    all_category_cards = gr.HTML(value= | 
| 871 | 
            -
                    total_score = gr.Markdown(value= | 
| 872 |  | 
| 873 | 
             
                def update_dashboard(tab, selected_models, selected_model, selected_categories):
         | 
| 874 | 
             
                    # Default visibility states
         | 
|  | |
| 861 | 
             
                    category_chart = gr.Plot(value=initial_plot)
         | 
| 862 |  | 
| 863 | 
             
                # Make detailed scorecard tab visible by default
         | 
| 864 | 
            +
                # Initialize with StarCoder2 data - don't use the update_detailed_scorecard function directly for initialization
         | 
| 865 | 
             
                default_model = "StarCoder2"
         | 
| 866 | 
            +
                if default_model in models:
         | 
| 867 | 
            +
                    selected_categories = sort_categories(category_choices)
         | 
| 868 | 
            +
                    metadata_html = create_metadata_card(models[default_model]['metadata'])
         | 
| 869 | 
            +
                    overall_summary_html = create_overall_summary(models[default_model], selected_categories)
         | 
| 870 | 
            +
                    combined_header = metadata_html + overall_summary_html
         | 
| 871 | 
            +
                    
         | 
| 872 | 
            +
                    # Prepare the initial data for the detailed view (similar to update_detailed_scorecard but without gr.update())
         | 
| 873 | 
            +
                    model = default_model
         | 
| 874 | 
            +
                    all_cards_content = "<div class='container'>"
         | 
| 875 | 
            +
                    total_yes = 0
         | 
| 876 | 
            +
                    total_no = 0
         | 
| 877 | 
            +
                    total_na = 0
         | 
| 878 | 
            +
                    has_non_na = False
         | 
| 879 | 
            +
                    
         | 
| 880 | 
            +
                    for category_name in selected_categories:
         | 
| 881 | 
            +
                        if category_name in models[model]['scores']:
         | 
| 882 | 
            +
                            category_data = models[model]['scores'][category_name]
         | 
| 883 | 
            +
                            card_content = f"<div class='card'><div class='card-title'>{category_name}</div>"
         | 
| 884 | 
            +
                            card_content += create_category_summary(category_data)
         | 
| 885 | 
            +
                            
         | 
| 886 | 
            +
                            sorted_sections = sorted(category_data.items(), 
         | 
| 887 | 
            +
                                                  key=lambda x: float(re.match(r'^(\d+\.?\d*)', x[0]).group(1)))
         | 
| 888 | 
            +
                            
         | 
| 889 | 
            +
                            category_yes = 0
         | 
| 890 | 
            +
                            category_no = 0
         | 
| 891 | 
            +
                            category_na = 0
         | 
| 892 | 
            +
                            
         | 
| 893 | 
            +
                            for section, details in sorted_sections:
         | 
| 894 | 
            +
                                status = details['status']
         | 
| 895 | 
            +
                                if status != 'N/A':
         | 
| 896 | 
            +
                                    has_non_na = True
         | 
| 897 | 
            +
                                sources = details.get('sources', [])
         | 
| 898 | 
            +
                                questions = details.get('questions', {})
         | 
| 899 | 
            +
                                
         | 
| 900 | 
            +
                                section_class = "section-na" if status == "N/A" else "section-active"
         | 
| 901 | 
            +
                                status_class = status.lower()
         | 
| 902 | 
            +
                                status_icon = "●" if status == "Yes" else "○" if status == "N/A" else "×"
         | 
| 903 | 
            +
                                
         | 
| 904 | 
            +
                                card_content += f"<div class='section {section_class}'>"
         | 
| 905 | 
            +
                                card_content += f"<div class='section-header'><h3>{section}</h3>"
         | 
| 906 | 
            +
                                card_content += f"<span class='status-badge {status_class}'>{status_icon} {status}</span></div>"
         | 
| 907 | 
            +
                                
         | 
| 908 | 
            +
                                if sources:
         | 
| 909 | 
            +
                                    card_content += create_source_html(sources)
         | 
| 910 | 
            +
                                
         | 
| 911 | 
            +
                                if questions:
         | 
| 912 | 
            +
                                    yes_count = sum(1 for v in questions.values() if v)
         | 
| 913 | 
            +
                                    total_count = len(questions)
         | 
| 914 | 
            +
                                    
         | 
| 915 | 
            +
                                    card_content += "<details class='question-accordion'>"
         | 
| 916 | 
            +
                                    if status == "N/A":
         | 
| 917 | 
            +
                                        card_content += f"<summary>View {total_count} N/A items</summary>"
         | 
| 918 | 
            +
                                    else:
         | 
| 919 | 
            +
                                        card_content += f"<summary>View details ({yes_count}/{total_count} completed)</summary>"
         | 
| 920 | 
            +
                                    
         | 
| 921 | 
            +
                                    card_content += "<div class='questions'>"
         | 
| 922 | 
            +
                                    for question, is_checked in questions.items():
         | 
| 923 | 
            +
                                        if status == "N/A":
         | 
| 924 | 
            +
                                            style_class = "na"
         | 
| 925 | 
            +
                                            icon = "○"
         | 
| 926 | 
            +
                                            category_na += 1
         | 
| 927 | 
            +
                                            total_na += 1
         | 
| 928 | 
            +
                                        else:
         | 
| 929 | 
            +
                                            if is_checked:
         | 
| 930 | 
            +
                                                style_class = "checked"
         | 
| 931 | 
            +
                                                icon = "✓"
         | 
| 932 | 
            +
                                                category_yes += 1
         | 
| 933 | 
            +
                                                total_yes += 1
         | 
| 934 | 
            +
                                            else:
         | 
| 935 | 
            +
                                                style_class = "unchecked"
         | 
| 936 | 
            +
                                                icon = "✗"
         | 
| 937 | 
            +
                                                category_no += 1
         | 
| 938 | 
            +
                                                total_no += 1
         | 
| 939 | 
            +
                                        
         | 
| 940 | 
            +
                                        card_content += f"<div class='question-item {style_class}'>{icon} {question}</div>"
         | 
| 941 | 
            +
                                    card_content += "</div></details>"
         | 
| 942 | 
            +
                                
         | 
| 943 | 
            +
                                card_content += "</div>"
         | 
| 944 | 
            +
                            
         | 
| 945 | 
            +
                            if category_yes + category_no > 0:
         | 
| 946 | 
            +
                                category_score = category_yes / (category_yes + category_no) * 100
         | 
| 947 | 
            +
                                card_content += f"<div class='category-score'>Completion Score Breakdown: {category_score:.2f}% Yes: {category_yes}, No: {category_no}, N/A: {category_na}</div>"
         | 
| 948 | 
            +
                            elif category_na > 0:
         | 
| 949 | 
            +
                                card_content += f"<div class='category-score'>Completion Score Breakdown: N/A (All {category_na} items not applicable)</div>"
         | 
| 950 | 
            +
                            
         | 
| 951 | 
            +
                            card_content += "</div>"
         | 
| 952 | 
            +
                            all_cards_content += card_content
         | 
| 953 | 
            +
             | 
| 954 | 
            +
                    all_cards_content += "</div>"
         | 
| 955 | 
            +
                    
         | 
| 956 | 
            +
                    # Create total score
         | 
| 957 | 
            +
                    if not has_non_na:
         | 
| 958 | 
            +
                        total_score_text = "No applicable scores (all items N/A)"
         | 
| 959 | 
            +
                    elif total_yes + total_no > 0:
         | 
| 960 | 
            +
                        total_score = total_yes / (total_yes + total_no) * 100
         | 
| 961 | 
            +
                        total_score_text = f"Total Score: {total_score:.2f}% (Yes: {total_yes}, No: {total_no}, N/A: {total_na})"
         | 
| 962 | 
            +
                    else:
         | 
| 963 | 
            +
                        total_score_text = "No applicable scores (all items N/A)"
         | 
| 964 | 
            +
                    
         | 
| 965 | 
            +
                    initial_metadata = combined_header
         | 
| 966 | 
            +
                    initial_cards = all_cards_content
         | 
| 967 | 
            +
                    initial_score = total_score_text
         | 
| 968 | 
            +
                else:
         | 
| 969 | 
            +
                    initial_metadata = "Please select a model to view details."
         | 
| 970 | 
            +
                    initial_cards = ""
         | 
| 971 | 
            +
                    initial_score = ""
         | 
| 972 |  | 
| 973 | 
             
                with gr.Column(visible=True) as detailed_scorecard_tab:
         | 
| 974 | 
            +
                    model_metadata = gr.HTML(value=initial_metadata)
         | 
| 975 | 
            +
                    all_category_cards = gr.HTML(value=initial_cards, visible=True if default_model in models else False)
         | 
| 976 | 
            +
                    total_score = gr.Markdown(value=initial_score, visible=True if default_model in models else False)
         | 
| 977 |  | 
| 978 | 
             
                def update_dashboard(tab, selected_models, selected_model, selected_categories):
         | 
| 979 | 
             
                    # Default visibility states
         | 
 
			
