Maia Pelletier commited on
Commit
b484ab6
·
1 Parent(s): 85532f2

fix deprecated models + timeout error fallback

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -93,11 +93,11 @@ class RAGChatbot:
93
 
94
  # Default and fallback models (try in order until one is supported by your Inference API providers)
95
  # Check current availability at https://huggingface.co/inference/models
96
- DEFAULT_CHAT_MODEL = "Qwen/Qwen2.5-72B-Instruct"
 
97
  FALLBACK_CHAT_MODELS = [
98
- "meta-llama/Llama-3.3-70B-Instruct",
99
  "google/gemma-4-31B-it",
100
- "meta-llama/Llama-3.1-8B-Instruct",
101
  ]
102
 
103
  # Shown to users when the HF account behind HF_TOKEN has run out of Inference Providers credits (HTTP 402)
@@ -201,6 +201,11 @@ class RAGChatbot:
201
  ):
202
  print(f"[DEBUG] Model {model} not available, trying next fallback.")
203
  continue
 
 
 
 
 
204
  print(f"[DEBUG] _generate_with_chat exception for {model}: {type(e).__name__}: {e}")
205
  import traceback
206
  traceback.print_exc()
 
93
 
94
  # Default and fallback models (try in order until one is supported by your Inference API providers)
95
  # Check current availability at https://huggingface.co/inference/models
96
+ # All ungated (no licence acceptance needed) and non-reasoning
97
+ DEFAULT_CHAT_MODEL = "Qwen/Qwen3-235B-A22B-Instruct-2507"
98
  FALLBACK_CHAT_MODELS = [
 
99
  "google/gemma-4-31B-it",
100
+ "deepseek-ai/DeepSeek-V3-0324",
101
  ]
102
 
103
  # Shown to users when the HF account behind HF_TOKEN has run out of Inference Providers credits (HTTP 402)
 
201
  ):
202
  print(f"[DEBUG] Model {model} not available, trying next fallback.")
203
  continue
204
+ # Provider too slow or temporarily down (e.g. 504 Gateway Time-out): try the next model
205
+ status = getattr(getattr(e, "response", None), "status_code", None)
206
+ if status in (502, 503, 504) or "timed out" in err_str or "time-out" in err_str:
207
+ print(f"[DEBUG] Model {model} timed out or provider unavailable ({status}), trying next fallback.")
208
+ continue
209
  print(f"[DEBUG] _generate_with_chat exception for {model}: {type(e).__name__}: {e}")
210
  import traceback
211
  traceback.print_exc()