import os import gradio as gr # type: ignore[import] from src.content import (INTRODUCTION_TEXT, INTRODUCTION_TITLE, LEADERBOARD_TEXT, LEADERBOARD_TITLE, SUBMISSION_TEXT_FILES, SUBMISSION_TEXT_INTRO, SUBMISSION_TEXT_METADATA, SUBMISSION_TEXT_SUBMIT, SUBMISSION_TEXT_TASK, SUBMISSION_TITLE) from src.get_results_for_task import get_results_for_task_stub from src.submission_uploader import SubmissionUploader from src.tasks import TASKS_DESCRIPTIONS, TASKS_PRETTY, TASKS_PRETTY_REVERSE submission_uploader = SubmissionUploader(os.environ["DATASET_ID"]) with gr.Blocks() as demo: gr.HTML(INTRODUCTION_TITLE) gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text") gr.HTML(LEADERBOARD_TITLE) gr.Markdown(LEADERBOARD_TEXT, elem_classes="markdown-text") with gr.Tabs(): for task in TASKS_PRETTY_REVERSE: with gr.TabItem(task): with gr.Row(): gr.Markdown(TASKS_DESCRIPTIONS[task]) leaderboard_table = gr.components.Dataframe( value=get_results_for_task_stub(task), interactive=False ) gr.HTML(SUBMISSION_TITLE) gr.Markdown(SUBMISSION_TEXT_INTRO, elem_classes="markdown-text") with gr.Accordion("🚀 Submit new results"): gr.Markdown(SUBMISSION_TEXT_TASK, elem_classes="markdown-text") task = gr.Radio(TASKS_PRETTY_REVERSE.keys(), label="Task") gr.Markdown(SUBMISSION_TEXT_METADATA, elem_classes="markdown-text") with gr.Row(): with gr.Column(): model_folder_textbox = gr.Textbox( label="Model Folder", placeholder="How to call a folder related to this submission in our results dataset.", ) model_name_textbox = gr.Textbox( label="Model Name", placeholder="How to display model's name on the leaderboard.", ) model_availability_textbox = gr.Textbox( label="Availability", placeholder="Information about the model's availability and licensing.", ) context_size_textbox = gr.Textbox( label="Context Size", placeholder="Context size (in tokens) used for the submission.", ) with gr.Column(): submitted_by_textbox = gr.Textbox( label="Submitted By", placeholder="Who submitted the model, how it will be displayed on the leaderboard.", ) contact_textbox = gr.Textbox( label="Contact Information", placeholder="How Long Code Arena team can contact you in case of any questions (won't go to public dataset).", ) comment_textbox = gr.Textbox( label="Comment", placeholder="Any comments you have for Long Code Arena team (optional, won't go to public dataset).", ) url_textbox = gr.Textbox( label="Relevant URLs", placeholder="URLs to relevant resources (preprint/blogpost/code/etc.) with " "additional details about your submission.", ) gr.Markdown(SUBMISSION_TEXT_FILES, elem_classes="markdown-text") file_output = gr.File(file_count="multiple") gr.Markdown(SUBMISSION_TEXT_SUBMIT, elem_classes="markdown-text") submit_button = gr.Button("Submit") submission_result = gr.Markdown() submit_button.click( submission_uploader.upload_files, [ task, model_folder_textbox, model_name_textbox, model_availability_textbox, url_textbox, context_size_textbox, submitted_by_textbox, file_output, ], submission_result, ) if __name__ == "__main__": demo.launch()