Small changes
Browse files
app.py
CHANGED
|
@@ -60,7 +60,7 @@ def send_slack_notification(model_name, user_name, user_affiliation):
|
|
| 60 |
# Insert your Slack webhook URL here
|
| 61 |
webhook_url = os.getenv("WEBHOOK_URL")
|
| 62 |
|
| 63 |
-
# Create the
|
| 64 |
message = {
|
| 65 |
"text": f"New model submission for EVALITA-LLM leaderboard:\n\n"
|
| 66 |
f"**Model Name**: {model_name}\n"
|
|
@@ -81,7 +81,7 @@ def send_slack_notification(model_name, user_name, user_affiliation):
|
|
| 81 |
|
| 82 |
# Funcion to validate the model submission and send the request for processing
|
| 83 |
def validate_and_submit_request(model_name, user_email, user_affiliation):
|
| 84 |
-
# Check if model name is provided and not
|
| 85 |
if not model_name or not model_name.strip():
|
| 86 |
return "β **Error:** Model name is required."
|
| 87 |
|
|
@@ -102,11 +102,10 @@ def validate_and_submit_request(model_name, user_email, user_affiliation):
|
|
| 102 |
if "/" not in model_name:
|
| 103 |
return "β **Error:** Model name must be in format 'organization/model-name' (e.g., 'microsoft/DialoGPT-medium')."
|
| 104 |
|
| 105 |
-
# Check if the model name contains only valid characters
|
| 106 |
if not re.match(r'^[a-zA-Z0-9._/-]+$', model_name):
|
| 107 |
return "β **Error:** Model name contains invalid characters."
|
| 108 |
|
| 109 |
-
# If all validations pass, send the Slack notification
|
| 110 |
slack_response = send_slack_notification(model_name.strip(), user_email.strip(), user_affiliation.strip())
|
| 111 |
|
| 112 |
# Return the Slack response (success or failure message)
|
|
@@ -643,7 +642,7 @@ def create_gradio_interface():
|
|
| 643 |
elem_id="submit-request-button"
|
| 644 |
)
|
| 645 |
|
| 646 |
-
# Result
|
| 647 |
submission_status = gr.Markdown(elem_id="submission-status")
|
| 648 |
|
| 649 |
# Connect button to function
|
|
@@ -672,7 +671,7 @@ def create_gradio_interface():
|
|
| 672 |
""", elem_classes="markdown-text")
|
| 673 |
|
| 674 |
|
| 675 |
-
#
|
| 676 |
with gr.TabItem("β", interactive=False):
|
| 677 |
gr.Markdown("", elem_classes="markdown-text")
|
| 678 |
|
|
@@ -699,7 +698,7 @@ def create_gradio_interface():
|
|
| 699 |
'Best Prompt Id']]
|
| 700 |
)
|
| 701 |
|
| 702 |
-
#
|
| 703 |
with gr.TabItem("β", interactive=False):
|
| 704 |
gr.Markdown("", elem_classes="markdown-text")
|
| 705 |
|
|
|
|
| 60 |
# Insert your Slack webhook URL here
|
| 61 |
webhook_url = os.getenv("WEBHOOK_URL")
|
| 62 |
|
| 63 |
+
# Create the messag to be sent to Slack
|
| 64 |
message = {
|
| 65 |
"text": f"New model submission for EVALITA-LLM leaderboard:\n\n"
|
| 66 |
f"**Model Name**: {model_name}\n"
|
|
|
|
| 81 |
|
| 82 |
# Funcion to validate the model submission and send the request for processing
|
| 83 |
def validate_and_submit_request(model_name, user_email, user_affiliation):
|
| 84 |
+
# Check if model name is provided and not empt
|
| 85 |
if not model_name or not model_name.strip():
|
| 86 |
return "β **Error:** Model name is required."
|
| 87 |
|
|
|
|
| 102 |
if "/" not in model_name:
|
| 103 |
return "β **Error:** Model name must be in format 'organization/model-name' (e.g., 'microsoft/DialoGPT-medium')."
|
| 104 |
|
| 105 |
+
# Check if the model name contains only valid characters
|
| 106 |
if not re.match(r'^[a-zA-Z0-9._/-]+$', model_name):
|
| 107 |
return "β **Error:** Model name contains invalid characters."
|
| 108 |
|
|
|
|
| 109 |
slack_response = send_slack_notification(model_name.strip(), user_email.strip(), user_affiliation.strip())
|
| 110 |
|
| 111 |
# Return the Slack response (success or failure message)
|
|
|
|
| 642 |
elem_id="submit-request-button"
|
| 643 |
)
|
| 644 |
|
| 645 |
+
# Result area
|
| 646 |
submission_status = gr.Markdown(elem_id="submission-status")
|
| 647 |
|
| 648 |
# Connect button to function
|
|
|
|
| 671 |
""", elem_classes="markdown-text")
|
| 672 |
|
| 673 |
|
| 674 |
+
# Separators
|
| 675 |
with gr.TabItem("β", interactive=False):
|
| 676 |
gr.Markdown("", elem_classes="markdown-text")
|
| 677 |
|
|
|
|
| 698 |
'Best Prompt Id']]
|
| 699 |
)
|
| 700 |
|
| 701 |
+
# Separators
|
| 702 |
with gr.TabItem("β", interactive=False):
|
| 703 |
gr.Markdown("", elem_classes="markdown-text")
|
| 704 |
|