2023-08-22 19:58:31 -06:00
|
|
|
import requests
|
|
|
|
|
|
|
|
from llm_server import opts
|
2023-09-12 01:04:11 -06:00
|
|
|
|
2023-08-22 19:58:31 -06:00
|
|
|
|
2023-10-27 19:19:22 -06:00
|
|
|
def get_running_model(backend_url: str, mode: str):
|
|
|
|
if mode == 'ooba':
|
2023-08-22 19:58:31 -06:00
|
|
|
try:
|
2023-10-27 19:19:22 -06:00
|
|
|
backend_response = requests.get(f'{backend_url}/api/v1/model', timeout=opts.backend_request_timeout, verify=opts.verify_ssl)
|
2023-09-11 09:51:01 -06:00
|
|
|
r_json = backend_response.json()
|
|
|
|
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-10-27 19:19:22 -06:00
|
|
|
elif mode == 'vllm':
|
2023-09-11 20:47:19 -06:00
|
|
|
try:
|
2023-10-27 19:19:22 -06:00
|
|
|
backend_response = requests.get(f'{backend_url}/model', timeout=opts.backend_request_timeout, verify=opts.verify_ssl)
|
2023-09-11 20:47:19 -06:00
|
|
|
r_json = backend_response.json()
|
2023-09-12 01:04:11 -06:00
|
|
|
return r_json['model'], None
|
2023-09-11 20:47:19 -06:00
|
|
|
except Exception as e:
|
|
|
|
return False, e
|
2023-08-22 19:58:31 -06:00
|
|
|
else:
|
|
|
|
raise Exception
|
2023-10-27 19:19:22 -06:00
|
|
|
|
|
|
|
|
|
|
|
def get_info(backend_url: str, mode: str):
|
|
|
|
if mode == 'ooba':
|
|
|
|
return {}
|
|
|
|
# raise NotImplementedError
|
|
|
|
elif mode == 'vllm':
|
|
|
|
try:
|
|
|
|
r = requests.get(f'{backend_url}/info', verify=opts.verify_ssl, timeout=opts.backend_request_timeout)
|
|
|
|
j = r.json()
|
|
|
|
except Exception as e:
|
|
|
|
return {}
|
|
|
|
return j
|
|
|
|
else:
|
|
|
|
raise Exception
|