from flask import jsonify from llm_server.custom_redis import flask_cache from . import bp from .generate_stats import generate_stats from ..auth import requires_auth from ...cluster.backend import get_backends from ...cluster.cluster_config import cluster_config from ...helpers import jsonify_pretty @bp.route('/stats', methods=['GET']) @flask_cache.cached(timeout=5, query_string=True) def get_stats(): return jsonify_pretty(generate_stats()) @bp.route('/backends', methods=['GET']) @requires_auth def get_backend(): online, offline = get_backends() result = {} for i in online + offline: info = cluster_config.get_backend(i) result[info['hash']] = info return jsonify(result), 200