VectorV17 commited on
Commit
d13d161
·
verified ·
1 Parent(s): b4033eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -38,13 +38,19 @@ retriever = vectorstore.as_retriever(search_type="similarity", search_kwargs={"k
38
  # 2. Setup Robust LLM Interface via OpenAI-Compatible Endpoint
39
  # -------------------------------------------------------------------------
40
  print("Configuring LLM Interface...")
 
 
 
 
 
41
  chatModel = ChatOpenAI(
42
  model="Qwen/Qwen2.5-1.5B-Instruct",
43
  base_url="https://api-inference.huggingface.co/models/Qwen/Qwen2.5-1.5B-Instruct/v1/",
44
  api_key=hf_token,
45
  max_tokens=400,
46
  temperature=0.3,
47
- max_retries=2 # Helps prevent timeout crashes during model wake-up
 
48
  )
49
 
50
  system_prompt = (
 
38
  # 2. Setup Robust LLM Interface via OpenAI-Compatible Endpoint
39
  # -------------------------------------------------------------------------
40
  print("Configuring LLM Interface...")
41
+
42
+ # Safety check to ensure the token is actually being loaded
43
+ if not hf_token:
44
+ print("WARNING: HF_TOKEN is missing. Please check your environment variables.")
45
+
46
  chatModel = ChatOpenAI(
47
  model="Qwen/Qwen2.5-1.5B-Instruct",
48
  base_url="https://api-inference.huggingface.co/models/Qwen/Qwen2.5-1.5B-Instruct/v1/",
49
  api_key=hf_token,
50
  max_tokens=400,
51
  temperature=0.3,
52
+ max_retries=4, # Increased from 2 to give the API more chances to connect
53
+ timeout=120.0 # FIX: Extended timeout to 2 minutes to survive cold starts
54
  )
55
 
56
  system_prompt = (