File size: 2,119 Bytes
0e7f11a
 
 
73ffe91
 
0e7f11a
 
 
 
 
 
 
 
73ffe91
0e7f11a
 
73ffe91
a22edf4
73ffe91
0e7f11a
 
 
 
 
 
 
 
2e61d1f
f8b127b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0e7f11a
 
 
 
 
 
 
 
 
 
 
 
73ffe91
 
 
0e7f11a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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)


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("Public test", elem_id="llm-benchmark-tab-table", id=0):
            leaderboard_df = load_from_hub(fs, RESULTS_REPO, is_private=False)
            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,
                    )

        with gr.TabItem("Private test", elem_id="llm-benchmark-tab-table", id=1):
            leaderboard_df = load_from_hub(fs, RESULTS_REPO, is_private=True)
            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()