import os import gradio as gr from apscheduler.schedulers.background import BackgroundScheduler from huggingface_hub import HfFileSystem, HfApi from src.assets.text_content import INTRODUCTION_TEXT, TITLE from src.load_from_hub import load_from_hub RESULTS_REPO = os.environ.get("RESULTS_REPO", "datasets/vlsp-2023-vllm/vllms-leaderboard") HIDDEN_TOKEN = os.environ.get("HIDDEN_TOKEN") api = HfApi(token=HIDDEN_TOKEN) fs = HfFileSystem(token=HIDDEN_TOKEN) def restart_space(): api.restart_space(repo_id="vlsp-2023-vllm/VLLMs-Leaderboard", token=HIDDEN_TOKEN) leaderboard_df = load_from_hub(fs, RESULTS_REPO) demo = gr.Blocks() 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("VLLMs Benchmark", elem_id="llm-benchmark-tab-table", id=0): with gr.Column(): with gr.Row(): search_bar = gr.Textbox( placeholder=" 🔍 Search for your model and press ENTER...", show_label=False, elem_id="search-bar", ) with gr.Row(): leaderboard_table = gr.components.Dataframe( value=leaderboard_df, ) scheduler = BackgroundScheduler() scheduler.add_job(restart_space, "interval", seconds=1800) scheduler.start() demo.launch()