Spaces:
Runtime error
Runtime error
Update app.py
Browse files6 unmodified lines7891011121316 unmodified lines303132333435363 unmodified lines4041424344454647484910 unmodified lines606162636465666 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")16 unmodified linesvision_available = Truepro_sub = Falsetry:InferenceClient(m, timeout=60, token=HUGGINGFACE_TOKEN).text_generation("Hi.", max_new_tokens=1)text_available = Trueexcept Exception as e:print(e)3 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 []try:InferenceClient(m, timeout=60).chat_completion(messages=[{'role': 'user', 'content': 'Hi.'}], max_tokens=1)chat_available = Trueexcept Exception as e:print(e)10 unmodified linesmodels_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 lines7891011121316 unmodified lines303132333435363 unmodified lines4041424344454647484910 unmodified lines606162636465666 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")16 unmodified linesvision_available = Truepro_sub = Falsetry:InferenceClient(m, timeout=120, token=HUGGINGFACE_TOKEN).text_generation("Hi.", max_new_tokens=1)text_available = Trueexcept Exception as e:print(e)3 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 []try:InferenceClient(m, timeout=120).chat_completion(messages=[{'role': 'user', 'content': 'Hi.'}], max_tokens=1)chat_available = Trueexcept Exception as e:print(e)10 unmodified linesmodels_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):
app.py+5-5