embed786 commited on
Commit
5e2b486
·
verified ·
1 Parent(s): 7e4cf1d

Update planmate/config.py

Browse files
Files changed (1) hide show
  1. planmate/config.py +17 -0
planmate/config.py CHANGED
@@ -23,6 +23,23 @@ AMADEUS_BASE = "https://test.api.amadeus.com"
23
  OPENWEATHER_BASE = "https://api.openweathermap.org"
24
  OPENTRIPMAP_BASE = "https://api.opentripmap.com/0.1/en"
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  def get_env(key: str) -> str:
27
  val = os.getenv(key)
28
  if not val:
 
23
  OPENWEATHER_BASE = "https://api.openweathermap.org"
24
  OPENTRIPMAP_BASE = "https://api.opentripmap.com/0.1/en"
25
 
26
+ # ---------- Hugging Face Secrets Configuration ----------
27
+ def get_secret(key, default=None):
28
+ """
29
+ Get secret from Hugging Face Spaces environment or fallback to local .env
30
+ """
31
+ # Try to get from environment first (Hugging Face Spaces)
32
+ value = os.getenv(key)
33
+
34
+ if value is None and default is not None:
35
+ return default
36
+ elif value is None:
37
+ st.error(f"Missing required secret: {key}")
38
+ st.info("Please add this secret in your Hugging Face Space settings.")
39
+ st.stop()
40
+
41
+ return value
42
+
43
  def get_env(key: str) -> str:
44
  val = os.getenv(key)
45
  if not val: