Spaces:
Runtime error
Runtime error
Update app.py
Browse files7 unmodified lines8910111213147 unmodified lines222324252627282930313233343536373839404142434445464748495051525354555657587 unmodified linesdef get_available_free(use_cache = False):if use_cache:if os.path.exists(str(os.getcwd())+"/data.csv"):print("Loading data from file...")return pd.read_csv("data.csv").to_dict(orient='list')models_dict = InferenceClient(token=HUGGINGFACE_TOKEN).list_deployed_models("text-generation-inference")models = models_dict['text-generation'] + models_dict['text2text-generation']7 unmodified lines"Chat Completion": [],"Vision": []}for m in list(set(models + models_vision + models_others)):text_available = Falsechat_available = Falsevision_available = Falseif 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!!")if os.path.exists(str(os.getcwd())+"/data.csv"):print("Loading data from file...")return pd.read_csv(str(os.getcwd())+"/data.csv").to_dict(orient='list')return []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!!")if os.path.exists("data.csv"):print("Loading data from file...")return pd.read_csv(str(os.getcwd())+"/data.csv").to_dict(orient='list')return []models_conclusion["Model"].append(m)7 unmodified lines8910111213147 unmodified lines22232425262728293031323334353637383940414243444546474849505152535455565758596061627 unmodified linesdef get_available_free(use_cache = False):if use_cache:if os.path.exists(str(os.getcwd())+"/data.csv"):# print("Loading data from file...")return pd.read_csv("data.csv").to_dict(orient='list')models_dict = InferenceClient(token=HUGGINGFACE_TOKEN).list_deployed_models("text-generation-inference")models = models_dict['text-generation'] + models_dict['text2text-generation']7 unmodified lines"Chat Completion": [],"Vision": []}all_models = list(set(models + models_vision + models_others))print(all_models)for m in all_models:text_available = Falsechat_available = Falsevision_available = Falseif m in models_vision:vision_available = Truepro_sub = Falseprint(m)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!!")if os.path.exists(str(os.getcwd())+"/data.csv"):# print("Loading data from file...")return pd.read_csv(str(os.getcwd())+"/data.csv").to_dict(orient='list')return []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!!")if os.path.exists("data.csv"):# print("Loading data from file...")return pd.read_csv(str(os.getcwd())+"/data.csv").to_dict(orient='list')return []models_conclusion["Model"].append(m)
app.py+12-8