Spaces:
Runtime error
Runtime error
Update app.py
Browse files6 unmodified lines7891011121324 unmodified lines3839404142434445466 unmodified lines53545556575859606162636465666 unmodified linesHUGGINGFACE_TOKEN = os.environ.get("HUGGINGFACE_TOKEN")def get_available_free(use_cache = False):if use_cache:if os.path.exists("./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")24 unmodified linespro_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("./data.csv").to_dict(orient='list')return []try:InferenceClient(m, timeout=10).chat_completion(messages=[{'role': 'user', 'content': 'Hi.'}], max_tokens=1)6 unmodified linesprint("Rate Limited!!")if os.path.exists("data.csv"):print("Loading data from file...")return pd.read_csv("data.csv").to_dict(orient='list')return []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 "β"))models_conclusion["Text Completion"].append("---" if (pro_sub or (not chat_available and not text_available)) else ("β" if text_available else "β"))models_conclusion["Vision"].append("β" if vision_available else "β")pd.DataFrame(models_conclusion).to_csv("./data.csv", index=False)return models_conclusiondef update_data(use_cache = False):6 unmodified lines7891011121324 unmodified lines3839404142434445466 unmodified lines53545556575859606162636465666 unmodified linesHUGGINGFACE_TOKEN = os.environ.get("HUGGINGFACE_TOKEN")def 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")24 unmodified linespro_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)6 unmodified linesprint("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)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 "β"))models_conclusion["Text Completion"].append("---" if (pro_sub or (not chat_available and not text_available)) else ("β" if text_available else "β"))models_conclusion["Vision"].append("β" if vision_available else "β")pd.DataFrame(models_conclusion).to_csv(str(os.getcwd())+"/data.csv", index=False)return models_conclusiondef update_data(use_cache = False):
app.py+5-5