Spaces:
Sleeping
Sleeping
Claude commited on
Commit ·
ce7f3f9
1
Parent(s): 896b58a
fix: Gracefully handle invalid HF tokens without crashing startup
Browse files
app.py
CHANGED
|
@@ -69,7 +69,11 @@ DEFAULT_PERSPECTIVES = ["newton", "empathy", "philosophy", "quantum"]
|
|
| 69 |
# HF Inference API setup
|
| 70 |
HF_TOKEN = os.environ.get("HF_TOKEN", "")
|
| 71 |
if HF_TOKEN:
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
try:
|
| 74 |
client = InferenceClient("meta-llama/Llama-3.1-8B-Instruct")
|
| 75 |
HAS_LLM = True
|
|
|
|
| 69 |
# HF Inference API setup
|
| 70 |
HF_TOKEN = os.environ.get("HF_TOKEN", "")
|
| 71 |
if HF_TOKEN:
|
| 72 |
+
try:
|
| 73 |
+
login(token=HF_TOKEN)
|
| 74 |
+
except Exception as e:
|
| 75 |
+
print(f"Warning: HF token invalid or expired ({e.__class__.__name__}). Will attempt without auth.")
|
| 76 |
+
HF_TOKEN = ""
|
| 77 |
try:
|
| 78 |
client = InferenceClient("meta-llama/Llama-3.1-8B-Instruct")
|
| 79 |
HAS_LLM = True
|