pandora-s commited on
Commit
027a488
1 Parent(s): 7821572

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -7,8 +7,9 @@ from threading import Timer
7
  HUGGINGFACE_TOKEN = os.environ.get("HUGGINGFACE_TOKEN")
8
  def get_available_free():
9
  models_dict = InferenceClient(token=HUGGINGFACE_TOKEN).list_deployed_models("text-generation-inference")
10
- models = models_dict['text-generation'] + models_dict['text2text-generation'] #token=HUGGINGFACE_TOKEN
11
  models_vision = models_dict['image-text-to-text']
 
12
 
13
  models_conclusion = {
14
  "Model": [],
@@ -17,7 +18,7 @@ def get_available_free():
17
  "Chat Completion": [],
18
  "Vision": []
19
  }
20
- for m in models + models_vision:
21
  text_available = False
22
  chat_available = False
23
  vision_available = False
@@ -25,7 +26,7 @@ def get_available_free():
25
  vision_available = True
26
  pro_sub = False
27
  try:
28
- InferenceClient(m, timeout=10, token=HUGGINGFACE_TOKEN).text_generation("Hi.", max_new_tokens=1)
29
  text_available = True
30
  except Exception as e:
31
  print(e)
@@ -38,7 +39,7 @@ def get_available_free():
38
  return pd.read_csv("data.csv").to_dict(orient='list')
39
  return []
40
  try:
41
- InferenceClient(m, timeout=10).chat_completion(messages=[{'role': 'user', 'content': 'Hi.'}], max_tokens=1) #token=HUGGINGFACE_TOKEN
42
  chat_available = True
43
  except Exception as e:
44
  print(e)
 
7
  HUGGINGFACE_TOKEN = os.environ.get("HUGGINGFACE_TOKEN")
8
  def get_available_free():
9
  models_dict = InferenceClient(token=HUGGINGFACE_TOKEN).list_deployed_models("text-generation-inference")
10
+ models = models_dict['text-generation'] + models_dict['text2text-generation']
11
  models_vision = models_dict['image-text-to-text']
12
+ models_others = InferenceClient(token=HUGGINGFACE_TOKEN).list_deployed_models("text-generation")
13
 
14
  models_conclusion = {
15
  "Model": [],
 
18
  "Chat Completion": [],
19
  "Vision": []
20
  }
21
+ for m in list(set(models + models_vision + models_others)):
22
  text_available = False
23
  chat_available = False
24
  vision_available = False
 
26
  vision_available = True
27
  pro_sub = False
28
  try:
29
+ InferenceClient(m, timeout=60, token=HUGGINGFACE_TOKEN).text_generation("Hi.", max_new_tokens=1)
30
  text_available = True
31
  except Exception as e:
32
  print(e)
 
39
  return pd.read_csv("data.csv").to_dict(orient='list')
40
  return []
41
  try:
42
+ InferenceClient(m, timeout=60).chat_completion(messages=[{'role': 'user', 'content': 'Hi.'}], max_tokens=1)
43
  chat_available = True
44
  except Exception as e:
45
  print(e)