local-llm-server/llm_server/routes/v1/info.py

36 lines
779 B
Python
Raw Normal View History

2023-08-21 21:28:52 -06:00
import time
from flask import jsonify
from . import bp
2023-08-21 22:49:44 -06:00
from ..helpers.http import cache_control
from ... import opts
from ...llm.info import get_running_model
2023-08-21 21:28:52 -06:00
from ..cache import cache
# cache = Cache(bp, config={'CACHE_TYPE': 'simple'})
# @bp.route('/info', methods=['GET'])
# # @cache.cached(timeout=3600, query_string=True)
# def get_info():
# # requests.get()
# return 'yes'
@bp.route('/model', methods=['GET'])
@cache.cached(timeout=60, query_string=True)
def get_model():
model = get_running_model()
if not model:
return jsonify({
'code': 500,
'error': 'failed to reach backend'
}), 500
2023-08-21 22:49:44 -06:00
else:
return jsonify({
'result': model,
'timestamp': int(time.time())
}), 200