Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
print(
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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(
|
| 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 |
|