Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,6 @@ import pandas as pd
|
|
| 3 |
# from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
| 4 |
import requests
|
| 5 |
|
| 6 |
-
|
| 7 |
def update_table(category):
|
| 8 |
data_dict = {
|
| 9 |
"Overall": {
|
|
@@ -26,13 +25,13 @@ def update_table(category):
|
|
| 26 |
df = pd.DataFrame(data)
|
| 27 |
return df
|
| 28 |
|
|
|
|
| 29 |
def get_user(profile: gr.OAuthProfile | None) -> str:
|
| 30 |
if profile is None:
|
| 31 |
return ""
|
| 32 |
return profile.username
|
| 33 |
|
| 34 |
|
| 35 |
-
|
| 36 |
def submit_vote(username, category, vote):
|
| 37 |
if not category or not vote:
|
| 38 |
return "All fields are required!"
|
|
@@ -48,6 +47,7 @@ def submit_vote(username, category, vote):
|
|
| 48 |
"username": username
|
| 49 |
}
|
| 50 |
|
|
|
|
| 51 |
response = requests.post(url, json=data)
|
| 52 |
|
| 53 |
if response.status_code == 200:
|
|
@@ -55,6 +55,7 @@ def submit_vote(username, category, vote):
|
|
| 55 |
else:
|
| 56 |
return f"Failed to vote: {response.text}"
|
| 57 |
|
|
|
|
| 58 |
def submit_model(category, model_id):
|
| 59 |
if not category or not model_id:
|
| 60 |
return "All fields are required!"
|
|
@@ -65,6 +66,7 @@ def submit_model(category, model_id):
|
|
| 65 |
"model_id": model_id
|
| 66 |
}
|
| 67 |
|
|
|
|
| 68 |
response = requests.post(url, json=data)
|
| 69 |
|
| 70 |
if response.status_code == 200:
|
|
@@ -73,7 +75,6 @@ def submit_model(category, model_id):
|
|
| 73 |
return f"Failed to submit request: {response.text}"
|
| 74 |
|
| 75 |
|
| 76 |
-
# with gr.Blocks(auth=gr.HuggingfaceOAuth(optional=True)) as app:
|
| 77 |
with gr.Blocks() as app:
|
| 78 |
with gr.Tabs():
|
| 79 |
with gr.TabItem("Table"):
|
|
|
|
| 3 |
# from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
| 4 |
import requests
|
| 5 |
|
|
|
|
| 6 |
def update_table(category):
|
| 7 |
data_dict = {
|
| 8 |
"Overall": {
|
|
|
|
| 25 |
df = pd.DataFrame(data)
|
| 26 |
return df
|
| 27 |
|
| 28 |
+
|
| 29 |
def get_user(profile: gr.OAuthProfile | None) -> str:
|
| 30 |
if profile is None:
|
| 31 |
return ""
|
| 32 |
return profile.username
|
| 33 |
|
| 34 |
|
|
|
|
| 35 |
def submit_vote(username, category, vote):
|
| 36 |
if not category or not vote:
|
| 37 |
return "All fields are required!"
|
|
|
|
| 47 |
"username": username
|
| 48 |
}
|
| 49 |
|
| 50 |
+
print("Submitting vote with payload:", data)
|
| 51 |
response = requests.post(url, json=data)
|
| 52 |
|
| 53 |
if response.status_code == 200:
|
|
|
|
| 55 |
else:
|
| 56 |
return f"Failed to vote: {response.text}"
|
| 57 |
|
| 58 |
+
|
| 59 |
def submit_model(category, model_id):
|
| 60 |
if not category or not model_id:
|
| 61 |
return "All fields are required!"
|
|
|
|
| 66 |
"model_id": model_id
|
| 67 |
}
|
| 68 |
|
| 69 |
+
print("Submitting model with payload:", data)
|
| 70 |
response = requests.post(url, json=data)
|
| 71 |
|
| 72 |
if response.status_code == 200:
|
|
|
|
| 75 |
return f"Failed to submit request: {response.text}"
|
| 76 |
|
| 77 |
|
|
|
|
| 78 |
with gr.Blocks() as app:
|
| 79 |
with gr.Tabs():
|
| 80 |
with gr.TabItem("Table"):
|