wenyi commited on
Commit
1622555
·
verified ·
1 Parent(s): 7014db6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py CHANGED
@@ -14,6 +14,45 @@ HF_TOKEN = os.environ.get("HF_TOKEN")
14
 
15
  global data_component, filter_component
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  def download_csv():
19
  # pull the results and return this file!
 
14
 
15
  global data_component, filter_component
16
 
17
+ # --------------------------
18
+ # Restored clickable helpers
19
+ # --------------------------
20
+
21
+ def make_clickable_model(model_name: str, model_link: str) -> str:
22
+ """
23
+ 将模型名转换为可点击的 Markdown 链接。
24
+ """
25
+ if not model_link or model_link.strip() == "":
26
+ return model_name
27
+ return f"[{model_name}]({model_link})"
28
+
29
+
30
+ def make_clickable_user(user_name: str) -> str:
31
+ """
32
+ 将提交者名变为可点击的 HuggingFace 链接。
33
+ 如果你未来添加 Submitter 列(通常来自 CSV),就能使用。
34
+ """
35
+ if not user_name or user_name.strip() == "":
36
+ return user_name
37
+ return f"[{user_name}](https://huggingface.co/{user_name})"
38
+
39
+
40
+ def get_submissions() -> pd.DataFrame:
41
+ """
42
+ 从 HuggingFace Dataset 拉取 leaderboard 数据。
43
+ 封装了 repo 初始化、pull 和 CSV 加载。
44
+ """
45
+ submission_repo = Repository(
46
+ local_dir=SUBMISSION_NAME,
47
+ clone_from=SUBMISSION_URL,
48
+ use_auth_token=HF_TOKEN,
49
+ repo_type="dataset"
50
+ )
51
+ submission_repo.git_pull()
52
+ df = pd.read_csv(CSV_DIR)
53
+ return df
54
+
55
+
56
 
57
  def download_csv():
58
  # pull the results and return this file!