2023-08-22 19:58:31 -06:00
|
|
|
import requests
|
|
|
|
|
|
|
|
from llm_server import opts
|
|
|
|
|
|
|
|
|
|
|
|
def get_running_model():
|
|
|
|
if opts.mode == 'oobabooga':
|
|
|
|
try:
|
2023-08-23 16:11:32 -06:00
|
|
|
backend_response = requests.get(f'{opts.backend_url}/api/v1/model', timeout=3, verify=opts.verify_ssl)
|
2023-08-22 19:58:31 -06:00
|
|
|
except Exception as e:
|
2023-08-23 16:02:57 -06:00
|
|
|
return False, e
|
2023-08-22 19:58:31 -06:00
|
|
|
try:
|
|
|
|
r_json = backend_response.json()
|
2023-08-23 16:12:25 -06:00
|
|
|
return r_json['result'], None
|
2023-08-22 19:58:31 -06:00
|
|
|
except Exception as e:
|
2023-08-23 16:02:57 -06:00
|
|
|
return False, e
|
2023-08-22 19:58:31 -06:00
|
|
|
elif opts.mode == 'hf-textgen':
|
|
|
|
try:
|
2023-08-23 16:11:32 -06:00
|
|
|
backend_response = requests.get(f'{opts.backend_url}/info', verify=opts.verify_ssl)
|
2023-08-22 19:58:31 -06:00
|
|
|
except Exception as e:
|
2023-08-23 16:02:57 -06:00
|
|
|
return False, e
|
2023-08-22 19:58:31 -06:00
|
|
|
try:
|
|
|
|
r_json = backend_response.json()
|
2023-08-23 16:12:25 -06:00
|
|
|
return r_json['model_id'].replace('/', '_'), None
|
2023-08-22 19:58:31 -06:00
|
|
|
except Exception as e:
|
2023-08-23 16:02:57 -06:00
|
|
|
return False, e
|
2023-08-22 19:58:31 -06:00
|
|
|
else:
|
|
|
|
raise Exception
|