AliInamdar commited on
Commit
28079b9
·
verified ·
1 Parent(s): 0f1277a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -6,6 +6,25 @@ import re
6
  import io
7
  import os
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  # ✅ READ API KEY from Hugging Face Secret
10
  TOGETHER_API_KEY = os.environ.get("TOGETHER_API_KEY")
11
  if not TOGETHER_API_KEY:
 
6
  import io
7
  import os
8
 
9
+ def get_together_api_key():
10
+ """
11
+ Retrieves Together API key from Hugging Face Secrets (hosted) or fallback to local key (dev).
12
+ """
13
+ key = os.environ.get("TOGETHER_API_KEY")
14
+
15
+ if key:
16
+ print("✅ TOGETHER_API_KEY loaded from Hugging Face secret.")
17
+ return key
18
+
19
+ # For local dev fallback
20
+ local_key = "your-local-api-key-here" # 👈 REPLACE with your actual key
21
+ if local_key:
22
+ print("⚠️ Using local fallback API key.")
23
+ return local_key
24
+
25
+ raise RuntimeError("❌ TOGETHER_API_KEY is missing. Set it in Hugging Face Secrets or update the fallback.")
26
+
27
+
28
  # ✅ READ API KEY from Hugging Face Secret
29
  TOGETHER_API_KEY = os.environ.get("TOGETHER_API_KEY")
30
  if not TOGETHER_API_KEY: