File size: 2,303 Bytes
531e896 835d0a5 3d20d45 835d0a5 3d20d45 835d0a5 531e896 835d0a5 7ce1db7 3d20d45 835d0a5 3d20d45 835d0a5 3d20d45 835d0a5 3d20d45 835d0a5 7ce1db7 27e1d19 835d0a5 4a3bb81 27e1d19 835d0a5 27e1d19 835d0a5 27e1d19 |
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 |
import os
import threading
import time
import gradio as gr
from gradio_space_ci import enable_space_ci
from huggingface_hub import HfApi, HfFileSystem
from functions import commit
enable_space_ci()
BOT_HF_TOKEN = os.getenv("BOT_HF_TOKEN")
api = HfApi()
fs = HfFileSystem()
def refresh(how_much=43200): # default to 12 hour
time.sleep(how_much)
try:
api.restart_space(repo_id="T145/open-llm-leaderboard-results-to-modelcard")
except Exception as e:
print(f"Error while scraping leaderboard, trying again... {e}")
refresh(600) # 10 minutes if any error happens
gradio_title = "Modelcards + Open LLM Leaderboard Results"
gradio_desc = """
## π― What This Tool Does
- This tool adds the [Open LLM Leaderboard](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard) result of your model at the end of your model card.
- This tool also adds evaluation results to your model metadata and showcases the evaluation results as a widget.
## π οΈ Backend
The leaderboard's backend mainly runs on the [Hugging Face Hub API](https://huggingface.co/docs/huggingface_hub/v0.26.3/package_reference/hf_api).
## π€ Acknowledgements
- Special thanks to [YaΔΔ±z ΓalΔ±k (Weyaxi)](https://huggingface.co/Weyaxi) for the original tool.
"""
with gr.Blocks() as demo:
gr.HTML(f"""<h1 align="center" id="space-title">{gradio_title}</h1>""")
gr.HTML(
"""<h1 align="center" id="space-title" style="font-weight: bold; font-size: 40px; color: red;">DON'T SPAM MODELS!</h1>"""
)
gr.HTML(
"""<h1 align="center" id="space-title" style="font-weight: bold; font-size: 25px; color: red;">It won't change anything!</h1>"""
)
gr.Markdown(gradio_desc)
with gr.Row(equal_height=False):
with gr.Column():
model_id = gr.Textbox(label="Model ID or URL", lines=1)
gr.LoginButton()
with gr.Column():
output = gr.Textbox(label="Output", lines=1, show_copy_button=True)
submit_btn = gr.Button("Submit", variant="primary")
def validate_model_id(input_id, oauth_token: gr.OAuthToken):
return commit(input_id, oauth_token=oauth_token.token)
submit_btn.click(validate_model_id, model_id, output)
threading.Thread(target=refresh).start()
demo.launch()
|