File size: 5,158 Bytes
a33ace4
 
959181f
a33ace4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
959181f
 
 
 
 
 
 
 
 
a33ace4
 
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import gradio as gr
import pandas as pd
# from gradio_huggingfacehub_search import HuggingfaceHubSearch

def update_table(category):
    data_dict = {
        "Overall": {
            "Rank": [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, 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],
            "Model": ["Model A", "Model B", "Model C", "Model D", "Model E", "Model F", "Model G", "Model H", "Model I", "Model J", "Model K", "Model L", "Model M", "Model N", "Model O", "Model P", "Model Q", "Model R", "Model S", "Model T", "Model U", "Model V", "Model W", "Model X", "Model Y", "Model Z", "Model A", "Model B", "Model C", "Model D", "Model E", "Model F", "Model G", "Model H", "Model I", "Model J", "Model K", "Model L", "Model M", "Model N", "Model O", "Model P", "Model Q", "Model R", "Model S", "Model T", "Model U", "Model V", "Model W", "Model X", "Model Y", "Model Z"],
            "Votes": [1250, 200, 3150, 4250, 5200, 6150, 7250, 8200, 9150, 10250, 11200, 12150, 13250, 21250, 200, 3150, 4250, 5200, 6150, 7250, 8200, 9150, 10250, 11200, 12150, 13250, 1250, 200, 3150, 4250, 5200, 6150, 7250, 8200, 9150, 10250, 11200, 12150, 13250, 21250, 200, 3150, 4250, 5200, 6150, 7250, 8200, 9150, 10250, 11200, 12150, 13250],
            "Organization": ["Org A", "Org B", "Org C", "Org D", "Org E", "Org F", "Org G", "Org H", "Org I", "Org J", "Org K", "Org L", "Org M", "Org N", "Org O", "Org P", "Org Q", "Model R", "Model S", "Model T", "Model U", "Model V", "Model W", "Model X", "Model Y", "Model Z", "Org A", "Org B", "Org C", "Org D", "Org E", "Org F", "Org G", "Org H", "Org I", "Org J", "Org K", "Org L", "Org M", "Org N", "Org O", "Org P", "Org Q", "Model R", "Model S", "Model T", "Model U", "Model V", "Model W", "Model X", "Model Y", "Model Z"],
            "License": ["1MIT", "2Apache 2.0", "3GPL", "4MIT", "5Apache 2.0", "6GPL", "7MIT", "8Apache 2.0", "9GPL", "10MIT", "11Apache 2.0", "12GPL", "13MIT", "1MIT", "2Apache 2.0", "3GPL", "4MIT", "5Apache 2.0", "6GPL", "7MIT", "8Apache 2.0", "9GPL", "10MIT", "11Apache 2.0", "12GPL", "13MIT", "1MIT", "2Apache 2.0", "3GPL", "4MIT", "5Apache 2.0", "6GPL", "7MIT", "8Apache 2.0", "9GPL", "10MIT", "11Apache 2.0", "12GPL", "13MIT", "1MIT", "2Apache 2.0", "3GPL", "4MIT", "5Apache 2.0", "6GPL", "7MIT", "8Apache 2.0", "9GPL", "10MIT", "11Apache 2.0", "12GPL", "13MIT"]
        },
        "Biology": {
            "Rank": [1, 2],
            "Model": ["GenePredict", "BioSeq"],
            "Votes": [180, 160],
            "Organization": ["BioTech", "Genomics Inc"],
            "License": ["GPL", "MIT"]
        }
    }
    
    data = data_dict.get(category, {"Rank": [], "Model": [], "Votes": [], "Organization": [], "License": []})
    df = pd.DataFrame(data)
    return df

def submit_vote(vote):
    # code
    return f"Vote '{vote}' submitted successfully!"

def submit_model(model_id):
    if not model_id:
        return "All fields are required!"
    
    url = "https://sdk.nexa4ai.com/task"   # Will have a new endpoint

    data = {
        "model_id": model_id
    }
    
    response = requests.post(url, json=data)
    
    if response.status_code == 200:
        return "Your request has been submitted successfully. We will notify you by email once processing is complete."
    else:
        return f"Failed to submit request: {response.text}"


with gr.Blocks() as app:
    with gr.Tabs():
        with gr.TabItem("Table"):
            dropdown = gr.Dropdown(
                choices=[
                    "Overall", "Biology", "Physics", "Business", "Chemistry",
                    "Economics", "Philosophy", "History", "Culture", "Computer Science",
                    "Math", "Health", "Law", "Engineering", "Other"
                ],
                label="Select Category",
                value="Overall"  
            )
            
            initial_data = update_table("Overall")
            table = gr.Dataframe(
                headers=["Rank", "Model", "Votes", "Organization", "License"],
                datatype=["number", "str", "number", "str", "str"],
                value=initial_data,
                col_count=(5, "fixed"),
                # height=600
            )
            dropdown.change(update_table, inputs=dropdown, outputs=table)
        
        with gr.TabItem("Vote"):
            vote = gr.Radio(choices=["Option 1", "Option 2", "Option 3"], label="Choose your option")
            submit_button = gr.Button("Submit Vote")
            submit_result = gr.Label() 
            submit_button.click(fn=submit_vote, inputs=vote, outputs=submit_result)
        
        # with gr.TabItem("Submit Model"):
        #     model_id = HuggingfaceHubSearch(
        #         label="Hub Model ID",
        #         placeholder="Search for model id on Huggingface",
        #         search_type="model",
        #     )
        #     submit_model_button = gr.Button("Submit Model")
        #     submit_model_result = gr.Label()
        #     submit_model_button.click(fn=submit_model, inputs=[model_id], outputs=submit_model_result)

app.launch()