sentiment-analysis / config.py
dayuian's picture
Create config.py
759966c verified
raw
history blame
458 Bytes
import os
from dotenv import load_dotenv
# 載入 .env 檔案(如果存在)
load_dotenv()
# 讀取 API Key
HF_API_KEY = os.getenv("HF_API_KEY")
if HF_API_KEY is None:
raise ValueError("❌ API Key 未設定,請檢查 Hugging Face Secrets 或 .env 檔案!")
# Hugging Face API 相關設定
API_URL = "https://api-inference.huggingface.co/models/cardiffnlp/twitter-xlm-roberta-base-sentiment"
HEADERS = {"Authorization": f"Bearer {HF_API_KEY}"}