Ani-404 commited on
Commit
d221d76
·
1 Parent(s): f481ef0

updated app

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -46,7 +46,7 @@ EMOTION_EMOJIS = {
46
  }
47
 
48
  # HuggingFace Inference API Setup
49
- HF_TOKEN = st.secrets.get("HF_TOKEN")
50
 
51
  # HuggingFace Inference API Setup
52
  @st.cache_resource
@@ -71,7 +71,13 @@ emotion_client, finbert_client = get_inference_clients()
71
  @st.cache_resource
72
  def get_runtime_mode():
73
  """Get HF API clients and mode flag."""
74
- HF_TOKEN = st.secrets.get("HF_TOKEN")
 
 
 
 
 
 
75
  try:
76
  emotion_client = InferenceClient(
77
  model="Ani-404/emotion-model",
@@ -81,15 +87,11 @@ def get_runtime_mode():
81
  model="Ani-404/finbert-model",
82
  token=HF_TOKEN
83
  )
84
- # Try to touch API
85
- _ = emotion_client.text_classification("API connectivity test.", wait_for_model=False)
86
- _ = fin_client.text_classification("API test.", wait_for_model=False)
87
  return {"mode": "hf_api", "emotion_client": emotion_client, "fin_client": fin_client}
88
  except Exception as e:
89
  st.sidebar.warning(f"Using local/demo: {e}")
90
  return {"mode": "local", "emotion_client": None, "fin_client": None}
91
 
92
-
93
  @st.cache_resource
94
  @st.cache_resource
95
  def load_models():
 
46
  }
47
 
48
  # HuggingFace Inference API Setup
49
+ HF_TOKEN = st.secrets.get("HF_TOKEN", None)
50
 
51
  # HuggingFace Inference API Setup
52
  @st.cache_resource
 
71
  @st.cache_resource
72
  def get_runtime_mode():
73
  """Get HF API clients and mode flag."""
74
+ HF_TOKEN = st.secrets.get("HF_TOKEN", None)
75
+
76
+ # Skip HF API if no token
77
+ if not HF_TOKEN:
78
+ st.sidebar.info("💡 Running in local/demo mode (no HF_TOKEN found)")
79
+ return {"mode": "local", "emotion_client": None, "fin_client": None}
80
+
81
  try:
82
  emotion_client = InferenceClient(
83
  model="Ani-404/emotion-model",
 
87
  model="Ani-404/finbert-model",
88
  token=HF_TOKEN
89
  )
 
 
 
90
  return {"mode": "hf_api", "emotion_client": emotion_client, "fin_client": fin_client}
91
  except Exception as e:
92
  st.sidebar.warning(f"Using local/demo: {e}")
93
  return {"mode": "local", "emotion_client": None, "fin_client": None}
94
 
 
95
  @st.cache_resource
96
  @st.cache_resource
97
  def load_models():