Spaces:
Runtime error
Runtime error
Update app.py
Browse files30 unmodified lines3132333435363738394041424344454647484950515253545556118 unmodified lines17517617717817918018130 unmodified linesif m in models_vision:vision_available = Truepro_sub = Falsetry:InferenceClient(m, timeout=10, token=HUGGINGFACE_TOKEN).text_generation("Hi.", max_new_tokens=1)text_available = Trueexcept Exception as e:# print(e)if e and "Model requires a Pro subscription" in str(e):pro_sub = Trueif e and "Rate limit reached" in str(e):print("Rate Limited, waiting 1 hour...")time.sleep(60*60)try:InferenceClient(m, timeout=10).chat_completion(messages=[{'role': 'user', 'content': 'Hi.'}], max_tokens=1)chat_available = Trueexcept Exception as e:# print(e)if e and "Model requires a Pro subscription" in str(e):pro_sub = Trueif e and "Rate limit reached" in str(e):print("Rate Limited, waiting 1 hour...")time.sleep(60*60)models_conclusion["Model"].append(m)models_conclusion["API"].append("Free" if chat_available or text_available else ("Pro Subscription" if pro_sub else "Not Responding"))models_conclusion["Chat Completion"].append("---" if (pro_sub or (not chat_available and not text_available)) else ("✓" if chat_available else "⌀"))118 unmodified linesdef update_every_two_hours(first_run):search_models(search_box.value, use_cache = first_run)Timer(7200, update_every_two_hours, args=(False,)).start()Timer(0, update_every_two_hours, args=(first_run,)).start()30 unmodified lines3132333435363738394041424344454647484950515253545556575859606162118 unmodified lines18118218318418518618730 unmodified linesif m in models_vision:vision_available = Truepro_sub = Falsewhile True:try:InferenceClient(m, timeout=10, token=HUGGINGFACE_TOKEN).text_generation("Hi.", max_new_tokens=1)text_available = Trueexcept Exception as e:# print(e)if e and "Model requires a Pro subscription" in str(e):pro_sub = Trueif e and "Rate limit reached" in str(e):print("Rate Limited, waiting 1 hour...")time.sleep(60*60)else:breakwhile True:try:InferenceClient(m, timeout=10).chat_completion(messages=[{'role': 'user', 'content': 'Hi.'}], max_tokens=1)chat_available = Trueexcept Exception as e:# print(e)if e and "Model requires a Pro subscription" in str(e):pro_sub = Trueif e and "Rate limit reached" in str(e):print("Rate Limited, waiting 1 hour...")time.sleep(60*60)else:breakmodels_conclusion["Model"].append(m)models_conclusion["API"].append("Free" if chat_available or text_available else ("Pro Subscription" if pro_sub else "Not Responding"))models_conclusion["Chat Completion"].append("---" if (pro_sub or (not chat_available and not text_available)) else ("✓" if chat_available else "⌀"))118 unmodified linesdef update_every_two_hours(first_run):search_models(search_box.value, use_cache = first_run)Timer(60, update_every_two_hours, args=(False,)).start()Timer(0, update_every_two_hours, args=(first_run,)).start()
app.py+27-21