print fetch model error message

This commit is contained in:
Cyberes 2023-08-23 16:02:57 -06:00
parent 6589b8ac07
commit 1f5e2da637
2 changed files with 7 additions and 6 deletions

View File

@ -8,21 +8,21 @@ def get_running_model():
try:
backend_response = requests.get(f'{opts.backend_url}/api/v1/model')
except Exception as e:
return False
return False, e
try:
r_json = backend_response.json()
return r_json['result']
except Exception as e:
return False
return False, e
elif opts.mode == 'hf-textgen':
try:
backend_response = requests.get(f'{opts.backend_url}/info')
except Exception as e:
return False
return False, e
try:
r_json = backend_response.json()
return r_json['model_id'].replace('/', '_')
except Exception as e:
return False
return False, e
else:
raise Exception

View File

@ -22,11 +22,12 @@ from ..cache import cache
@bp.route('/model', methods=['GET'])
@cache.cached(timeout=60, query_string=True)
def get_model():
model = get_running_model()
model, error = get_running_model()
if not model:
return jsonify({
'code': 500,
'error': 'failed to reach backend'
'error': 'failed to reach backend',
'msg': error
}), 500
else:
return jsonify({