import gradio as gr import pandas as pd from pages.summarization_playground import custom_css # Sample data for the leaderboard data = { 'Rank': [1, 2, 3, 4, 5], 'Methods': ['METHOD1_PLACEHOLDER', 'METHOD2_PLACEHOLDER', 'METHOD3_PLACEHOLDER', 'METHOD4_PLACEHOLDER', 'METHOD5_PLACEHOLDER'], 'METRIC1_PLACEHOLDER Score': [1287, 1272, 1267, 1262, 1258], 'METRIC2_PLACEHOLDER Score': [56905, 24913, 42981, 49828, 55567], 'METRIC3_PLACEHOLDER Score': [3423, 3423, 2152, 4353, 2342], 'Authors': ['AUTHOR1_PLACEHOLDER', 'AUTHOR2_PLACEHOLDER', 'AUTHOR3_PLACEHOLDER', 'AUTHOR4_PLACEHOLDER', 'AUTHOR5_PLACEHOLDER'], } df = pd.DataFrame(data) def update_leaderboard(sort_by): # In a real implementation, this would filter the data based on the category sorted_df = df.sort_values(by=sort_by, ascending=False) # Update ranks based on new sorting sorted_df['Rank'] = range(1, len(sorted_df) + 1) # Convert DataFrame to HTML with clickable headers for sorting html = sorted_df.to_html(index=False, escape=False) # Add sorting links to column headers for column in sorted_df.columns: html = html.replace(f'