陈俊杰
commited on
Commit
•
a266103
1
Parent(s):
d6e3121
cjj:evaluation
Browse files
app.py
CHANGED
@@ -1,5 +1,35 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# CSS样式
|
5 |
st.markdown("""
|
@@ -29,7 +59,39 @@ This leaderboard is used to show the performance of the **automatic evaluation m
|
|
29 |
- Text Expansion (TE).
|
30 |
|
31 |
Details of AEOLLLM can be found at the link: [https://cjj826.github.io/AEOLLM/](https://cjj826.github.io/AEOLLM/)
|
|
|
|
|
32 |
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
# 创建示例数据
|
34 |
SG = {
|
35 |
"methods": ["Model A", "Model B", "Model C"],
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
+
import datetime
|
4 |
+
from huggingface_hub import HfApi
|
5 |
+
import json
|
6 |
+
|
7 |
+
# 定义一些全局变量或参数
|
8 |
+
MAX_SUBMISSIONS_PER_DAY = 3 # 每天的最大提交次数
|
9 |
+
submissions_log = {} # 用于记录用户提交的次数
|
10 |
+
|
11 |
+
# 获取用户的唯一ID(使用Hugging Face的OAuth2身份验证)
|
12 |
+
def get_user_id():
|
13 |
+
api = HfApi()
|
14 |
+
user_info = api.whoami(token=st.secrets["hf_api_token"])
|
15 |
+
return user_info["name"]
|
16 |
+
|
17 |
+
# 检查用户当天的提交次数
|
18 |
+
def check_submission_limit(user_id):
|
19 |
+
today = datetime.date.today()
|
20 |
+
if user_id in submissions_log:
|
21 |
+
if submissions_log[user_id]["date"] == today:
|
22 |
+
return submissions_log[user_id]["count"] < MAX_SUBMISSIONS_PER_DAY
|
23 |
+
else:
|
24 |
+
submissions_log[user_id] = {"date": today, "count": 0}
|
25 |
+
return True
|
26 |
+
else:
|
27 |
+
submissions_log[user_id] = {"date": today, "count": 0}
|
28 |
+
return True
|
29 |
+
|
30 |
+
# 更新用户的提交记录
|
31 |
+
def update_submission_count(user_id):
|
32 |
+
submissions_log[user_id]["count"] += 1
|
33 |
|
34 |
# CSS样式
|
35 |
st.markdown("""
|
|
|
59 |
- Text Expansion (TE).
|
60 |
|
61 |
Details of AEOLLLM can be found at the link: [https://cjj826.github.io/AEOLLM/](https://cjj826.github.io/AEOLLM/)
|
62 |
+
|
63 |
+
Submit your result here (.json):
|
64 |
""", unsafe_allow_html=True)
|
65 |
+
|
66 |
+
user_id = get_user_id()
|
67 |
+
st.write(f"欢迎, {user_id}!")
|
68 |
+
|
69 |
+
# 检查用户的提交限制
|
70 |
+
if check_submission_limit(user_id):
|
71 |
+
st.write(f"您今天还可以提交 {MAX_SUBMISSIONS_PER_DAY - submissions_log[user_id]['count']} 次。")
|
72 |
+
|
73 |
+
# 创建文件上传组件
|
74 |
+
uploaded_file = st.file_uploader("选择一个文件", type=["json"])
|
75 |
+
|
76 |
+
# 创建一个按钮,用户点击后提交文件
|
77 |
+
if st.button("提交文件"):
|
78 |
+
if uploaded_file is not None:
|
79 |
+
# 读取文件内容
|
80 |
+
file_content = uploaded_file.read().decode("utf-8")
|
81 |
+
|
82 |
+
# 如果是JSON文件,解析内容
|
83 |
+
try:
|
84 |
+
json_data = json.loads(file_content)
|
85 |
+
st.success("文件已成功提交!")
|
86 |
+
st.json(json_data) # 显示上传的JSON数据
|
87 |
+
except json.JSONDecodeError:
|
88 |
+
st.error("无法解析JSON文件,请确保文件格式正确。")
|
89 |
+
else:
|
90 |
+
st.warning("请先上传一个文件!")
|
91 |
+
|
92 |
+
else:
|
93 |
+
st.error("您今天的提交次数已达上限。请明天再试。")
|
94 |
+
|
95 |
# 创建示例数据
|
96 |
SG = {
|
97 |
"methods": ["Model A", "Model B", "Model C"],
|