Spaces:
Sleeping
Sleeping
File size: 1,650 Bytes
94a0171 dc81690 94a0171 a8372d5 1fd8ba8 94a0171 1fd8ba8 adc17bc 94a0171 4c3e3fa d6b1d9e cb4b734 dc81690 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# config.py
import os
import tempfile
from datetime import datetime
# --- 環境設定 ---
HF_HOME_DIR = "/tmp/huggingface"
os.environ["HF_HOME"] = HF_HOME_DIR
os.makedirs(HF_HOME_DIR, exist_ok=True)
os.environ.setdefault("MPLCONFIGDIR", "/tmp/matplotlib")
# --- LINE Bot 憑證 ---
CHANNEL_ACCESS_TOKEN = os.getenv("CHANNEL_ACCESS_TOKEN")
CHANNEL_SECRET = os.getenv("CHANNEL_SECRET")
# --- Hugging Face Space URL ---
HF_SPACE_URL = os.getenv("SPACEURL")
if not HF_SPACE_URL:
sid = os.getenv("SPACE_ID")
if sid and "/" in sid:
author, name = sid.split("/", 1)
HF_SPACE_URL = f"https://{author.replace('_', '-')}-{name.replace('_', '-')}.hf.space"
else:
HF_SPACE_URL = ""
# --- 靜態檔案目錄 ---
STATIC_DIR = os.getenv("STATIC_DIR", os.path.join(tempfile.gettempdir(), "static"))
os.makedirs(STATIC_DIR, exist_ok=True)
# --- API 端點與金鑰 ---
CWA_API_KEY = os.getenv("CWA_API_KEY")
CWA_ALARM_API = "https://app-2.cwa.gov.tw/api/v1/earthquake/alarm/list"
CWA_SIGNIFICANT_API = "https://opendata.cwa.gov.tw/api/v1/rest/datastore/E-A0015-001"
CWA_LOCAL_EQ_API = "https://opendata.cwa.gov.tw/api/v1/rest/datastore/E-A0016-001" # This line was missing
USGS_API_BASE_URL = "https://earthquake.usgs.gov/fdsnws/event/1/query"
# --- AI 模型設定 ---
HUGGING_FACE_TOKEN = os.getenv("HUGGING_FACE_TOKEN")
LLM_MODEL = os.getenv("LLM_MODEL", "bigscience/bloomz-560m")
LLM_MAX_NEW_TOKENS = int(os.getenv("LLM_MAX_NEW_TOKENS", "120"))
LLM_TOP_K = int(os.getenv("LLM_TOP_K", "50"))
LLM_TEMPERATURE = float(os.getenv("LLM_TEMPERATURE", "0.7"))
# --- 顯示用當年年份 ---
CURRENT_YEAR = datetime.now().year
|