File size: 1,465 Bytes
0d2e03d
fc4805a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0d2e03d
 
fc4805a
 
 
 
 
8c35765
fc4805a
 
 
 
 
 
 
 
 
 
 
6ef13aa
fc4805a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
60
import gradio as gr
import pandas as pd

# Function to load data from a given CSV file
def load_data(version):
    file_path = f'versions/{version}.csv'  # Assuming filenames are version1.csv, version2.csv, version3.csv
    return pd.read_csv(file_path)

# Function for searching in the leaderboard
def search_leaderboard(df, query):
    if query == "":
        return df
    else:
        return df[df['Method'].str.contains(query)]

# Function to change the version of the leaderboard
def change_version(version):
    new_df = load_data(version)
    return new_df

# Initialize Gradio app
demo = gr.Blocks()

with demo:
    gr.Markdown("## Radio Leaderboard")

    with gr.Row():
        version_dropdown = gr.Dropdown(
            choices=["llama", "phi", "stable-lm"],
            label="Select Version",
            value="llama",
        )

    with gr.Row():
        search_bar = gr.Textbox(
            placeholder="Search for methods...",
            show_label=False,
        )

    leaderboard_table = gr.components.Dataframe(
        value=load_data("llama"),  # Load initial version (version llama)
        interactive=True,
        visible=True,
    )

    version_dropdown.change(
        change_version,
        inputs=version_dropdown,
        outputs=leaderboard_table
    )

    search_bar.change(
        search_leaderboard,
        inputs=[leaderboard_table, search_bar],
        outputs=leaderboard_table
    )

# Launch the app
demo.launch()