dayuian commited on
Commit
a9b5bbd
·
verified ·
1 Parent(s): 35b16c8

Update config.py

Browse files
Files changed (1) hide show
  1. config.py +11 -9
config.py CHANGED
@@ -1,14 +1,16 @@
1
  import os
2
- from dotenv import load_dotenv
3
 
4
- # 載入 .env 檔案(如果存在)
5
- load_dotenv()
6
 
7
- # 讀取 API Key
8
- HF_API_KEY = os.getenv("HF_API_KEY")
9
- if HF_API_KEY is None:
10
- raise ValueError("❌ API Key 未設定,請檢查 Hugging Face Secrets 或 .env 檔案!")
11
 
12
- # Hugging Face API 相關設定
13
- API_URL = "https://api-inference.huggingface.co/models/cardiffnlp/twitter-xlm-roberta-base-sentiment"
14
  HEADERS = {"Authorization": f"Bearer {HF_API_KEY}"}
 
 
 
 
 
 
 
 
 
1
  import os
 
2
 
3
+ HF_API_KEY = os.getenv("HF_API_KEY") # 從環境變數讀取 API Key
 
4
 
5
+ if not HF_API_KEY:
6
+ raise ValueError("❌ API Key 未設定,請在 Hugging Face Spaces `Secrets` 中設置 `HF_API_KEY`")
 
 
7
 
 
 
8
  HEADERS = {"Authorization": f"Bearer {HF_API_KEY}"}
9
+
10
+ MODEL_OPTIONS = {
11
+ "🌎 多語言推特情緒分析 (XLM-RoBERTa)": "cardiffnlp/twitter-xlm-roberta-base-sentiment",
12
+ "📖 多語言情緒分析 (BERT)": "nlptown/bert-base-multilingual-uncased-sentiment",
13
+ "🇬🇧 英語情緒分析 (DistilBERT)": "distilbert-base-uncased-finetuned-sst-2-english"
14
+ }
15
+
16
+ DEFAULT_MODEL = "cardiffnlp/twitter-xlm-roberta-base-sentiment"