diff --git a/frontend_multi_user/src/admin_routes.py b/frontend_multi_user/src/admin_routes.py index b5f8d0f2..0bdb9fc3 100644 --- a/frontend_multi_user/src/admin_routes.py +++ b/frontend_multi_user/src/admin_routes.py @@ -370,40 +370,50 @@ def admin_database_backup(): return jsonify({"error": str(e)}), 502 -@admin_routes_bp.route("/ping/stream") +@admin_routes_bp.route("/ping/list") @login_required -def ping_stream(): +def ping_list(): worker_plan_url = current_app.config["WORKER_PLAN_URL"] + url = f"{worker_plan_url}/llm-list" + try: + resp = requests.get(url, timeout=(5, 30)) + except Exception as exc: + logger.error("LLM ping list proxy exception: %s", exc) + return jsonify({"error": str(exc)}), 502 + if resp.status_code != 200: + return jsonify({"error": f"worker_plan responded with {resp.status_code}"}), 502 + return jsonify(resp.json()) - def generate(): - url = f"{worker_plan_url}/llm-ping" - logger.info("Proxying LLM ping stream from %s", url) - try: - with requests.get( - url, - stream=True, - timeout=(5, 300), - headers={"Accept": "text/event-stream"}, - ) as resp: - if resp.status_code != 200: - msg = f"worker_plan responded with {resp.status_code}" - logger.error("LLM ping proxy error: %s", msg) - yield f"data: {json.dumps({'name': 'worker_plan', 'status': 'error', 'response_time': 0, 'response': msg})}\n\n" - yield f"data: {json.dumps({'name': 'server', 'status': 'done', 'response_time': 0, 'response': ''})}\n\n" - return - for line in resp.iter_lines(decode_unicode=True): - if line is None or line.strip() == "": - continue - yield f"{line}\n\n" - except Exception as exc: - logger.error("LLM ping proxy exception: %s", exc) - error_payload = {"name": "worker_plan", "status": "error", "response_time": 0, "response": str(exc)} - yield f"data: {json.dumps(error_payload)}\n\n" - yield f"data: {json.dumps({'name': 'server', 'status': 'done', 'response_time': 0, 'response': ''})}\n\n" - - response = Response(generate(), mimetype="text/event-stream") - response.headers["X-Accel-Buffering"] = "no" - return response + +@admin_routes_bp.route("/ping/one") +@login_required +def ping_one(): + worker_plan_url = current_app.config["WORKER_PLAN_URL"] + profile = request.args.get("profile", "") + llm_name = request.args.get("llm_name", "") + url = f"{worker_plan_url}/llm-ping-one" + try: + resp = requests.get( + url, + params={"profile": profile, "llm_name": llm_name}, + timeout=(5, 300), + ) + except Exception as exc: + logger.error("LLM ping-one proxy exception: %s", exc) + return jsonify({ + "name": f"{profile}:{llm_name}", + "status": "error", + "response_time": 0, + "response": str(exc), + }), 502 + if resp.status_code != 200: + return jsonify({ + "name": f"{profile}:{llm_name}", + "status": "error", + "response_time": 0, + "response": f"worker_plan responded with {resp.status_code}", + }), 502 + return jsonify(resp.json()) @admin_routes_bp.route("/admin/demo_run") diff --git a/frontend_multi_user/templates/ping.html b/frontend_multi_user/templates/ping.html index e5d3d4cc..20af1453 100644 --- a/frontend_multi_user/templates/ping.html +++ b/frontend_multi_user/templates/ping.html @@ -16,6 +16,7 @@ border: 1px solid #ddd; padding: 8px; text-align: left; + vertical-align: top; } th { background-color: #f2f2f2; @@ -23,28 +24,19 @@ tr:nth-child(even) { background-color: #f9f9f9; } - .status-success { - color: green; - } - .status-error { - color: red; - } - .status-pinging { - color: #666; - font-style: italic; - } + .status-success { color: green; } + .status-error { color: red; } + .status-pinging { color: #666; font-style: italic; } + .status-idle { color: #888; } .back-link { margin-bottom: 20px; display: inline-block; } - .loading { - color: #666; - font-style: italic; - } + .loading { color: #666; font-style: italic; } @keyframes ellipsis { - 0% { content: '.'; } - 33% { content: '..'; } - 66% { content: '...'; } + 0% { content: '.'; } + 33% { content: '..'; } + 66% { content: '...'; } 100% { content: '.'; } } .pinging::after { @@ -54,96 +46,166 @@ width: 1em; text-align: left; } - .server-status { - font-size: 0.8em; - font-weight: normal; - padding: 4px 8px; - border-radius: 4px; - margin-left: 10px; - display: inline-block; + .toolbar { + margin-bottom: 12px; } - .server-status.working { - background-color: #2196F3; - color: white; + button.ping-btn, + button.ping-all-btn { + cursor: pointer; + padding: 4px 10px; } - .server-status.done { - background-color: #4CAF50; - color: white; + button.ping-all-btn { + font-size: 1em; + padding: 8px 16px; } - .server-status.error { - background-color: #f44336; - color: white; + button:disabled { + cursor: not-allowed; + opacity: 0.6; }
← Back to Admin -| LLM Name | +Priority | +Action | Status | Response Time | Response |
|---|---|---|---|---|---|
| Loading results... | -|||||