29 lines
868 B
Python
29 lines
868 B
Python
import requests
|
|
|
|
from llm_server import opts
|
|
|
|
|
|
def get_running_model():
|
|
if opts.mode == 'oobabooga':
|
|
try:
|
|
backend_response = requests.get(f'{opts.backend_url}/api/v1/model', timeout=3, verify=opts.verify_ssl)
|
|
except Exception as e:
|
|
return False, e
|
|
try:
|
|
r_json = backend_response.json()
|
|
return r_json['result'], None
|
|
except Exception as e:
|
|
return False, e
|
|
elif opts.mode == 'hf-textgen':
|
|
try:
|
|
backend_response = requests.get(f'{opts.backend_url}/info', verify=opts.verify_ssl)
|
|
except Exception as e:
|
|
return False, e
|
|
try:
|
|
r_json = backend_response.json()
|
|
return r_json['model_id'].replace('/', '_'), None
|
|
except Exception as e:
|
|
return False, e
|
|
else:
|
|
raise Exception
|