import gradio as gr from about import METRIC_INFO_TEXT, TITLE, INTRODUCTION_TEXT, CITATION_BUTTON_TEXT from utils import empty_leaderboard, load_leaderboard, request_model with gr.Blocks() as demo: gr.Markdown(TITLE) gr.Markdown(INTRODUCTION_TEXT) # ---------- Leaderboard Tab ---------- with gr.Tab("Leaderboard"): leaderboard_df = gr.Dataframe( value=empty_leaderboard(), label="Rankings", interactive=False, ) refresh_btn = gr.Button("Refresh") refresh_btn.click(fn=load_leaderboard, outputs=leaderboard_df) gr.Markdown(METRIC_INFO_TEXT) # ---------- Request Evaluation Tab ---------- with gr.Tab("Request Evaluation"): gr.Markdown( "## Request a model evaluation\n\n" "Enter the model ID you would like to see evaluated. " "If it has already been scored, you'll see the results immediately. " "If it has been requested but not yet evaluated, you'll see when it was requested. " "Otherwise, it will be added to the evaluation queue." ) model_id_input = gr.Textbox( label="Model ID", placeholder="e.g., meta-llama/Llama-2-7b-chat-hf", info="The unique identifier for the model you want evaluated.", ) request_btn = gr.Button("Request Evaluation", variant="primary") request_output = gr.Markdown() request_btn.click( fn=request_model, inputs=[model_id_input], outputs=request_output, ) # ---------- About Tab ---------- with gr.Tab("About"): gr.Markdown(CITATION_BUTTON_TEXT) demo.load(fn=load_leaderboard, outputs=leaderboard_df) demo.queue().launch()