import gradio as gr from df.author_leaderboard_contrib import AuthorLeaderboardContrib def author_resource_leaderboard_tab(): # Initialize the AuthorLeaderboardContrib class leaderboard = AuthorLeaderboardContrib() with gr.Row(): gr.Markdown( """ ## Contributors Leaderboard The leaderboard centers on **artifact creators** who have developed models, datasets, or spaces associated with papers, regardless of whether they authored the original papers. It ranks contributors based on the total number of artifacts they've created that are linked to papers, as well as metrics like likes and downloads. """ ) with gr.Row(): author_search_input = gr.Textbox( label="Search by Contributor Name", placeholder="Enter author name...", lines=1, ) entity_type_filter = gr.Radio( label="Entity Type", choices=['All', 'user', 'org'], value='All', ) with gr.Row(): leaderboard_component = gr.Dataframe( label="Leaderboard", value=leaderboard.df_prettified, datatype=[leaderboard.DATATYPES[column] for column in leaderboard.COLUMNS_ORDER], row_count=(0, "dynamic"), interactive=False, max_height=1000, wrap=True, ) # Define the interaction function def update_leaderboard(author_name, entity_type): return leaderboard.filter(author_name, entity_type) inputs = [author_search_input, entity_type_filter] outputs = [leaderboard_component] # Set up the interactions author_search_input.change( update_leaderboard, inputs=inputs, outputs=outputs, api_name=False, ) entity_type_filter.change( update_leaderboard, inputs=inputs, outputs=outputs, api_name=False, )