2023-10-01 14:15:01 -06:00
|
|
|
from flask import jsonify
|
|
|
|
|
|
|
|
from llm_server.custom_redis import flask_cache
|
2023-08-21 21:28:52 -06:00
|
|
|
from . import bp
|
2023-08-23 23:11:12 -06:00
|
|
|
from .generate_stats import generate_stats
|
2023-10-01 14:15:01 -06:00
|
|
|
from ..auth import requires_auth
|
|
|
|
from ...cluster.backend import get_backends
|
|
|
|
from ...cluster.cluster_config import cluster_config
|
2023-09-16 17:37:43 -06:00
|
|
|
from ...helpers import jsonify_pretty
|
2023-08-21 21:28:52 -06:00
|
|
|
|
|
|
|
|
|
|
|
@bp.route('/stats', methods=['GET'])
|
2023-09-26 22:09:11 -06:00
|
|
|
@flask_cache.cached(timeout=5, query_string=True)
|
2023-08-21 21:28:52 -06:00
|
|
|
def get_stats():
|
2023-09-16 17:37:43 -06:00
|
|
|
return jsonify_pretty(generate_stats())
|
2023-10-01 14:15:01 -06:00
|
|
|
|
|
|
|
|
|
|
|
@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
|