import gradio as gr import pandas as pd import os from huggingface_hub import snapshot_download from apscheduler.schedulers.background import BackgroundScheduler from src.display.about import ( CITATION_BUTTON_LABEL, CITATION_BUTTON_TEXT, EVALUATION_QUEUE_TEXT, INTRODUCTION_TEXT, LLM_BENCHMARKS_TEXT, TITLE, ) from src.display.css_html_js import custom_css from src.envs import API # clone / pull the lmeh eval data TOKEN = os.environ.get("TOKEN", None) RESULTS_REPO = f"lukecq/SeaExam-results" CACHE_PATH=os.getenv("HF_HOME", ".") EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results") print(EVAL_RESULTS_PATH) snapshot_download( repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", token=TOKEN ) def restart_space(): API.restart_space(repo_id="lukecq/SeaExam_leaderboard", token=TOKEN) # Load the CSV file def load_csv(file_path): data = pd.read_csv(file_path) return data # Example path to your CSV file csv_path = f'{EVAL_RESULTS_PATH}/SeaExam_results_0419.csv' data = load_csv(csv_path) def show_data(): return data # iface = gr.Interface(fn=show_data, inputs = None, outputs="dataframe", title="SeaExam Leaderboard", # description="Leaderboard for the SeaExam competition.") # iface.launch() demo = gr.Blocks(css=custom_css) with demo: gr.HTML(TITLE) gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text") with gr.Tabs(elem_classes="tab-buttons") as tabs: with gr.TabItem("🏅 LLM Benchmark", elem_id="llm-benchmark-tab-table", id=0): leaderboard_table = gr.components.Dataframe( value=data, # value=leaderboard_df[ # [c.name for c in fields(AutoEvalColumn) if c.never_hidden] # + shown_columns.value # + [AutoEvalColumn.dummy.name] # ], # headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value, # datatype=TYPES, # elem_id="leaderboard-table", interactive=False, visible=True, # column_widths=["2%", "33%"] ) demo.launch() scheduler = BackgroundScheduler() scheduler.add_job(restart_space, "interval", seconds=20) scheduler.start() demo.queue(default_concurrency_limit=40).launch()