print fetch model error message
This commit is contained in:
parent
6589b8ac07
commit
1f5e2da637
|
@ -8,21 +8,21 @@ def get_running_model():
|
||||||
try:
|
try:
|
||||||
backend_response = requests.get(f'{opts.backend_url}/api/v1/model')
|
backend_response = requests.get(f'{opts.backend_url}/api/v1/model')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False
|
return False, e
|
||||||
try:
|
try:
|
||||||
r_json = backend_response.json()
|
r_json = backend_response.json()
|
||||||
return r_json['result']
|
return r_json['result']
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False
|
return False, e
|
||||||
elif opts.mode == 'hf-textgen':
|
elif opts.mode == 'hf-textgen':
|
||||||
try:
|
try:
|
||||||
backend_response = requests.get(f'{opts.backend_url}/info')
|
backend_response = requests.get(f'{opts.backend_url}/info')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False
|
return False, e
|
||||||
try:
|
try:
|
||||||
r_json = backend_response.json()
|
r_json = backend_response.json()
|
||||||
return r_json['model_id'].replace('/', '_')
|
return r_json['model_id'].replace('/', '_')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False
|
return False, e
|
||||||
else:
|
else:
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
|
@ -22,11 +22,12 @@ from ..cache import cache
|
||||||
@bp.route('/model', methods=['GET'])
|
@bp.route('/model', methods=['GET'])
|
||||||
@cache.cached(timeout=60, query_string=True)
|
@cache.cached(timeout=60, query_string=True)
|
||||||
def get_model():
|
def get_model():
|
||||||
model = get_running_model()
|
model, error = get_running_model()
|
||||||
if not model:
|
if not model:
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'code': 500,
|
'code': 500,
|
||||||
'error': 'failed to reach backend'
|
'error': 'failed to reach backend',
|
||||||
|
'msg': error
|
||||||
}), 500
|
}), 500
|
||||||
else:
|
else:
|
||||||
return jsonify({
|
return jsonify({
|
||||||
|
|
Reference in New Issue