Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,8 +31,10 @@ def loop_query_data():
|
|
| 31 |
if m in models_vision:
|
| 32 |
vision_available = True
|
| 33 |
pro_sub = False
|
| 34 |
-
|
|
|
|
| 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:
|
|
@@ -42,10 +44,11 @@ def loop_query_data():
|
|
| 42 |
if e and "Rate limit reached" in str(e):
|
| 43 |
print("Rate Limited, waiting 1 hour...")
|
| 44 |
time.sleep(60*60)
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
while
|
| 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:
|
|
@@ -55,8 +58,7 @@ def loop_query_data():
|
|
| 55 |
if e and "Rate limit reached" in str(e):
|
| 56 |
print("Rate Limited, waiting 1 hour...")
|
| 57 |
time.sleep(60*60)
|
| 58 |
-
|
| 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 "⌀"))
|
|
|
|
| 31 |
if m in models_vision:
|
| 32 |
vision_available = True
|
| 33 |
pro_sub = False
|
| 34 |
+
run_text = True
|
| 35 |
+
while run_text:
|
| 36 |
try:
|
| 37 |
+
run_text = False
|
| 38 |
InferenceClient(m, timeout=10, token=HUGGINGFACE_TOKEN).text_generation("Hi.", max_new_tokens=1)
|
| 39 |
text_available = True
|
| 40 |
except Exception as e:
|
|
|
|
| 44 |
if e and "Rate limit reached" in str(e):
|
| 45 |
print("Rate Limited, waiting 1 hour...")
|
| 46 |
time.sleep(60*60)
|
| 47 |
+
run_text = True
|
| 48 |
+
run_chat = True
|
| 49 |
+
while run_chat:
|
| 50 |
try:
|
| 51 |
+
run_chat = False
|
| 52 |
InferenceClient(m, timeout=10).chat_completion(messages=[{'role': 'user', 'content': 'Hi.'}], max_tokens=1)
|
| 53 |
chat_available = True
|
| 54 |
except Exception as e:
|
|
|
|
| 58 |
if e and "Rate limit reached" in str(e):
|
| 59 |
print("Rate Limited, waiting 1 hour...")
|
| 60 |
time.sleep(60*60)
|
| 61 |
+
run_chat = True
|
|
|
|
| 62 |
models_conclusion["Model"].append(m)
|
| 63 |
models_conclusion["API"].append("Free" if chat_available or text_available else ("Pro Subscription" if pro_sub else "Not Responding"))
|
| 64 |
models_conclusion["Chat Completion"].append("---" if (pro_sub or (not chat_available and not text_available)) else ("✓" if chat_available else "⌀"))
|