Spaces:
Sleeping
Sleeping
Commit
Β·
b74c038
1
Parent(s):
2e79a3c
aliveness calculation fixes
Browse files- app_config.py +3 -3
- pages/model_loader.py +9 -9
- utils/app_utils.py +7 -1
app_config.py
CHANGED
@@ -20,11 +20,11 @@ ENDPOINT_NAMES = {
|
|
20 |
# "CTL_llama2": "texter_simulator",
|
21 |
"CTL_llama3": {
|
22 |
"name": "texter_simulator_llm",
|
23 |
-
"model_type": "
|
24 |
},
|
25 |
# "CTL_llama3": {
|
26 |
# "name": "databricks-meta-llama-3-1-70b-instruct",
|
27 |
-
# "model_type": "
|
28 |
# },
|
29 |
# 'CTL_llama2': "llama2_convo_sim",
|
30 |
# "CTL_mistral": "convo_sim_mistral",
|
@@ -38,7 +38,7 @@ ENDPOINT_NAMES = {
|
|
38 |
},
|
39 |
"training_adherence": {
|
40 |
"name": "training_adherence",
|
41 |
-
"model_type": "
|
42 |
},
|
43 |
}
|
44 |
|
|
|
20 |
# "CTL_llama2": "texter_simulator",
|
21 |
"CTL_llama3": {
|
22 |
"name": "texter_simulator_llm",
|
23 |
+
"model_type": "text-generation"
|
24 |
},
|
25 |
# "CTL_llama3": {
|
26 |
# "name": "databricks-meta-llama-3-1-70b-instruct",
|
27 |
+
# "model_type": "text-generation"
|
28 |
# },
|
29 |
# 'CTL_llama2': "llama2_convo_sim",
|
30 |
# "CTL_mistral": "convo_sim_mistral",
|
|
|
38 |
},
|
39 |
"training_adherence": {
|
40 |
"name": "training_adherence",
|
41 |
+
"model_type": "text-completion"
|
42 |
},
|
43 |
}
|
44 |
|
pages/model_loader.py
CHANGED
@@ -18,16 +18,16 @@ MODELS2LOAD = {
|
|
18 |
"training_adherence": {"model_name": "Training Adherence", "loaded":None},
|
19 |
}
|
20 |
|
21 |
-
def write_model_status(writer, model_name, loaded, fail=
|
22 |
-
if loaded:
|
23 |
writer.write(f"β
- {model_name} Loaded")
|
24 |
-
|
25 |
-
if
|
26 |
writer.write(f"β - {model_name} Failed to Load, Contact ifbarrerarincon@crisistextline.org")
|
27 |
-
elif
|
28 |
writer.write(f"β - {model_name} Still loading, please try in a couple of minutes")
|
29 |
-
|
30 |
-
|
31 |
|
32 |
with st.status("Loading Models Please Wait...(this may take up to 5 min)", expanded=True) as status:
|
33 |
|
@@ -37,9 +37,9 @@ with st.status("Loading Models Please Wait...(this may take up to 5 min)", expan
|
|
37 |
while not models_alive:
|
38 |
time.sleep(2)
|
39 |
for name, config in MODELS2LOAD.items():
|
40 |
-
config["loaded"] = is_model_alive(ENDPOINT_NAMES[name])
|
41 |
|
42 |
-
models_alive = all([x['loaded'] for x in MODELS2LOAD.values()])
|
43 |
|
44 |
for _, config in MODELS2LOAD.items():
|
45 |
write_model_status(**config)
|
|
|
18 |
"training_adherence": {"model_name": "Training Adherence", "loaded":None},
|
19 |
}
|
20 |
|
21 |
+
def write_model_status(writer, model_name, loaded, fail=False):
|
22 |
+
if loaded == "200":
|
23 |
writer.write(f"β
- {model_name} Loaded")
|
24 |
+
if fail:
|
25 |
+
if loaded in ["400", "500"]:
|
26 |
writer.write(f"β - {model_name} Failed to Load, Contact ifbarrerarincon@crisistextline.org")
|
27 |
+
elif loaded == "404":
|
28 |
writer.write(f"β - {model_name} Still loading, please try in a couple of minutes")
|
29 |
+
else:
|
30 |
+
writer.write(f"π - {model_name} Loading")
|
31 |
|
32 |
with st.status("Loading Models Please Wait...(this may take up to 5 min)", expanded=True) as status:
|
33 |
|
|
|
37 |
while not models_alive:
|
38 |
time.sleep(2)
|
39 |
for name, config in MODELS2LOAD.items():
|
40 |
+
config["loaded"] = is_model_alive(**ENDPOINT_NAMES[name])
|
41 |
|
42 |
+
models_alive = all([x['loaded']=="200" for x in MODELS2LOAD.values()])
|
43 |
|
44 |
for _, config in MODELS2LOAD.items():
|
45 |
write_model_status(**config)
|
utils/app_utils.py
CHANGED
@@ -72,12 +72,18 @@ def is_model_alive(name, timeout=2, model_type="classificator"):
|
|
72 |
body_request = {
|
73 |
"inputs": [""]
|
74 |
}
|
75 |
-
elif model_type == "
|
76 |
body_request = {
|
77 |
"prompt": "",
|
78 |
"temperature": 0,
|
79 |
"max_tokens": 1,
|
80 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
else:
|
83 |
raise Exception(f"Model Type {model_type} not supported")
|
|
|
72 |
body_request = {
|
73 |
"inputs": [""]
|
74 |
}
|
75 |
+
elif model_type == "text-completion":
|
76 |
body_request = {
|
77 |
"prompt": "",
|
78 |
"temperature": 0,
|
79 |
"max_tokens": 1,
|
80 |
}
|
81 |
+
elif model_type == "text-generation":
|
82 |
+
body_request = {
|
83 |
+
"messages": [{"role":"user","content":""}],
|
84 |
+
"max_tokens": 1,
|
85 |
+
"temperature": 0
|
86 |
+
}
|
87 |
|
88 |
else:
|
89 |
raise Exception(f"Model Type {model_type} not supported")
|