import gradio as gr import pandas as pd import numpy as np import json import requests # Read URLs from a file, one per line with open('file_urls.txt', 'r') as f: file_urls = [line.strip() for line in f.readlines()] dataframes = [] for url in file_urls: # Derive column names from the URLs column_name = url.split('/')[-1].split('_')[0] # Load data from URL response = requests.get(url) data = response.json() # Convert data into a DataFrame df = pd.DataFrame(data['results']).T # Rename 'acc' column to respective file names df = df.rename(columns={'acc': column_name}) # Remove 'hendrycksTest-' from the index df.index = df.index.str.replace('hendrycksTest-', '') dataframes.append(df[[column_name]]) # keep only the column of interest # Merge the dataframes on index data = pd.concat(dataframes, axis=1) # Transpose the dataframe to swap rows and columns data = data.transpose() # Select only columns 'moral_scenarios' and 'moral_disputes' data = data[['moral_scenarios', 'moral_disputes']] def show_leaderboard(): # Convert dataframe to html so that it can be displayed properly in Gradio return data.to_html() iface = gr.Interface(fn=show_leaderboard, inputs=[], outputs="html") # Run the interface. # Note: you don't need to use .launch() in Hugging Face Spaces, this is for local testing. iface.launch()