pandora-s commited on
Commit
5a492b0
·
verified ·
1 Parent(s): a198ad1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -21
app.py CHANGED
@@ -31,26 +31,32 @@ def loop_query_data():
31
  if m in models_vision:
32
  vision_available = True
33
  pro_sub = False
34
- try:
35
- InferenceClient(m, timeout=10, token=HUGGINGFACE_TOKEN).text_generation("Hi.", max_new_tokens=1)
36
- text_available = True
37
- except Exception as e:
38
- # print(e)
39
- if e and "Model requires a Pro subscription" in str(e):
40
- pro_sub = True
41
- if e and "Rate limit reached" in str(e):
42
- print("Rate Limited, waiting 1 hour...")
43
- time.sleep(60*60)
44
- try:
45
- InferenceClient(m, timeout=10).chat_completion(messages=[{'role': 'user', 'content': 'Hi.'}], max_tokens=1)
46
- chat_available = True
47
- except Exception as e:
48
- # print(e)
49
- if e and "Model requires a Pro subscription" in str(e):
50
- pro_sub = True
51
- if e and "Rate limit reached" in str(e):
52
- print("Rate Limited, waiting 1 hour...")
53
- time.sleep(60*60)
 
 
 
 
 
 
54
  models_conclusion["Model"].append(m)
55
  models_conclusion["API"].append("Free" if chat_available or text_available else ("Pro Subscription" if pro_sub else "Not Responding"))
56
  models_conclusion["Chat Completion"].append("---" if (pro_sub or (not chat_available and not text_available)) else ("✓" if chat_available else "⌀"))
@@ -175,7 +181,7 @@ with gr.Blocks() as demo:
175
 
176
  def update_every_two_hours(first_run):
177
  search_models(search_box.value, use_cache = first_run)
178
- Timer(7200, update_every_two_hours, args=(False,)).start()
179
 
180
  Timer(0, update_every_two_hours, args=(first_run,)).start()
181
 
 
31
  if m in models_vision:
32
  vision_available = True
33
  pro_sub = False
34
+ while True:
35
+ try:
36
+ InferenceClient(m, timeout=10, token=HUGGINGFACE_TOKEN).text_generation("Hi.", max_new_tokens=1)
37
+ text_available = True
38
+ except Exception as e:
39
+ # print(e)
40
+ if e and "Model requires a Pro subscription" in str(e):
41
+ pro_sub = True
42
+ if e and "Rate limit reached" in str(e):
43
+ print("Rate Limited, waiting 1 hour...")
44
+ time.sleep(60*60)
45
+ else:
46
+ break
47
+ while True:
48
+ try:
49
+ InferenceClient(m, timeout=10).chat_completion(messages=[{'role': 'user', 'content': 'Hi.'}], max_tokens=1)
50
+ chat_available = True
51
+ except Exception as e:
52
+ # print(e)
53
+ if e and "Model requires a Pro subscription" in str(e):
54
+ pro_sub = True
55
+ if e and "Rate limit reached" in str(e):
56
+ print("Rate Limited, waiting 1 hour...")
57
+ time.sleep(60*60)
58
+ else:
59
+ break
60
  models_conclusion["Model"].append(m)
61
  models_conclusion["API"].append("Free" if chat_available or text_available else ("Pro Subscription" if pro_sub else "Not Responding"))
62
  models_conclusion["Chat Completion"].append("---" if (pro_sub or (not chat_available and not text_available)) else ("✓" if chat_available else "⌀"))
 
181
 
182
  def update_every_two_hours(first_run):
183
  search_models(search_box.value, use_cache = first_run)
184
+ Timer(60, update_every_two_hours, args=(False,)).start()
185
 
186
  Timer(0, update_every_two_hours, args=(first_run,)).start()
187