MonicaChen0330 commited on
Commit
a56b517
·
verified ·
1 Parent(s): 560e8aa

edited announcement

Browse files
Files changed (1) hide show
  1. app.py +24 -15
app.py CHANGED
@@ -58,23 +58,26 @@ def log_to_google_sheet(question, answer, contexts, scores):
58
  print("寫入 Google Sheet 失敗:", str(e))
59
 
60
  def fetch_announcement_from_sheet():
 
61
  try:
62
  url = os.environ.get("ANNOUNCEMENT_URL")
63
  if not url:
64
- return "📢 尚無公告"
 
 
65
  df = pd.read_csv(url)
66
 
67
- if "Announcement" in df.columns:
68
- content = str(df["Announcement"].iloc[0]).strip()
69
- if not content:
70
- return "📢 尚無公告"
71
- return f"📢 {content}"
72
- else:
73
- print("Error: 無法讀取公告欄位")
74
- return "📢 尚無公告"
75
  except Exception as e:
76
- print(f"Error: 載入公告失敗:{str(e)}")
77
- return "📢 尚無公告"
 
78
 
79
  def validate_openai_key(api_key):
80
  try:
@@ -266,20 +269,26 @@ def check_csv_and_run(file, key):
266
  # Gradio 介面
267
  with gr.Blocks() as demo:
268
  gr.Markdown("""
269
- ## 📐 RAG系統評估工具 (分流A)
270
 
271
- ### 📄 使用說明
272
  請上傳您 RAG 系統產出的結果檔案(需包含欄位:Question、Context、Answer),並填入您的 OpenAI API Key,以進行評估。
273
 
274
- ####完整評估通常需耗時 1 小時以上。若無即時回應,請耐心等候,系統並未當機,謝謝您的理解。
 
 
 
 
275
 
276
- 🚦 注意:本工具部署於 Hugging Face Public Space,若同時有多位使用者使用,系統會將您的評估請求排入佇列。
277
  為避免長時間等待,建議您**先僅送出 1 筆資料進行測試**,若進度條顯示之預估等待時間超過 2 小時(7000 秒以上),可能是其他使用者正在使用。
 
278
  本頁為分流 A,您可以考慮改用其他分流或稍後再試,感謝您的耐心與配合!
279
 
280
  - 🔁 [主頁面 (Main)](https://huggingface.co/spaces/KSLab/RAG_Evaluator)
281
  - 🔁 [分流 B](https://huggingface.co/spaces/KSLab/RAG_Evaluator_B)
282
  - 🔁 [分流 C](https://huggingface.co/spaces/KSLab/RAG_Evaluator_C)
 
 
283
  """)
284
  gr.Markdown(fetch_announcement_from_sheet())
285
 
 
58
  print("寫入 Google Sheet 失敗:", str(e))
59
 
60
  def fetch_announcement_from_sheet():
61
+ DEFAULT_MESSAGE = "尚無公告"
62
  try:
63
  url = os.environ.get("ANNOUNCEMENT_URL")
64
  if not url:
65
+ print("Warning: 環境變數 'ANNOUNCEMENT_URL' 未設定")
66
+ return DEFAULT_MESSAGE
67
+
68
  df = pd.read_csv(url)
69
 
70
+ if "Announcement" not in df.columns:
71
+ print("Error: CSV 檔案中無 'Announcement' 欄位")
72
+ return DEFAULT_MESSAGE
73
+
74
+ content = str(df["Announcement"].iloc[0]).strip()
75
+ return content if content else DEFAULT_MESSAGE
76
+
 
77
  except Exception as e:
78
+ print(f"Error: 載入公告失敗:{e}")
79
+ return DEFAULT_MESSAGE
80
+
81
 
82
  def validate_openai_key(api_key):
83
  try:
 
269
  # Gradio 介面
270
  with gr.Blocks() as demo:
271
  gr.Markdown("""
272
+ # 📐 RAG系統評估工具 (分流A)
273
 
274
+ ## 📄 使用說明
275
  請上傳您 RAG 系統產出的結果檔案(需包含欄位:Question、Context、Answer),並填入您的 OpenAI API Key,以進行評估。
276
 
277
+ ##評估時間說明
278
+ - 完整評估**通常需耗時 1 小時以上**,若無即時回應,請**耐心等候**,系統並未當機,謝謝您的理解。
279
+
280
+ ### 🚦 分流措施
281
+ 本工具部署於 Hugging Face Public Space,若同時有多位使用者使用,系統會將您的評估請求排入佇列。
282
 
 
283
  為避免長時間等待,建議您**先僅送出 1 筆資料進行測試**,若進度條顯示之預估等待時間超過 2 小時(7000 秒以上),可能是其他使用者正在使用。
284
+
285
  本頁為分流 A,您可以考慮改用其他分流或稍後再試,感謝您的耐心與配合!
286
 
287
  - 🔁 [主頁面 (Main)](https://huggingface.co/spaces/KSLab/RAG_Evaluator)
288
  - 🔁 [分流 B](https://huggingface.co/spaces/KSLab/RAG_Evaluator_B)
289
  - 🔁 [分流 C](https://huggingface.co/spaces/KSLab/RAG_Evaluator_C)
290
+
291
+ ### 📢 系統公告
292
  """)
293
  gr.Markdown(fetch_announcement_from_sheet())
294