From eeaece5baeeef990008e677f5d76a13f9a5a896a Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Sun, 21 Dec 2025 00:30:55 -0300 Subject: [PATCH] chore(ai): return AI node/GPU facts and copy public endpoint --- backend/app.py | 13 +++++-------- frontend/src/views/AiView.vue | 9 ++++++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/backend/app.py b/backend/app.py index ed591d4..a79e2de 100644 --- a/backend/app.py +++ b/backend/app.py @@ -34,11 +34,9 @@ AI_CHAT_SYSTEM_PROMPT = os.getenv( "You are the Titan Lab assistant for bstein.dev. Be concise and helpful.", ) AI_CHAT_TIMEOUT_SEC = float(os.getenv("AI_CHAT_TIMEOUT_SEC", "20")) -AI_NODE_NAME = os.getenv("AI_NODE_NAME") or os.getenv("NODE_NAME") or "unknown" -try: - AI_NODE_GPU_MAP = json.loads(os.getenv("AI_NODE_GPU_MAP", "{}")) -except json.JSONDecodeError: - AI_NODE_GPU_MAP = {} +AI_NODE_NAME = os.getenv("AI_CHAT_NODE_NAME") or os.getenv("AI_NODE_NAME") or "ai-cluster" +AI_GPU_DESC = os.getenv("AI_CHAT_GPU_DESC") or "local GPU (dynamic)" +AI_PUBLIC_ENDPOINT = os.getenv("AI_PUBLIC_CHAT_ENDPOINT", "https://chat.ai.bstein.dev/api/ai/chat") _LAB_STATUS_CACHE: dict[str, Any] = {"ts": 0.0, "value": None} @@ -188,13 +186,12 @@ def ai_chat() -> Any: @app.route("/api/ai/info", methods=["GET"]) def ai_info() -> Any: - gpu_label = AI_NODE_GPU_MAP.get(AI_NODE_NAME, "local GPU (dynamic)") return jsonify( { "node": AI_NODE_NAME, - "gpu": gpu_label, + "gpu": AI_GPU_DESC, "model": AI_CHAT_MODEL, - "endpoint": "/api/ai/chat", + "endpoint": AI_PUBLIC_ENDPOINT or "/api/ai/chat", } ) diff --git a/frontend/src/views/AiView.vue b/frontend/src/views/AiView.vue index 05e080f..da8c76a 100644 --- a/frontend/src/views/AiView.vue +++ b/frontend/src/views/AiView.vue @@ -20,13 +20,13 @@ {{ meta.gpu }}
- Node + AI Node {{ meta.node }}
Endpoint
@@ -98,6 +98,7 @@ const meta = ref({ model: "loading...", gpu: "local GPU (dynamic)", node: "unknown", + endpoint: "", }); const messages = ref([ { @@ -128,6 +129,7 @@ async function fetchMeta() { model: data.model || meta.value.model, gpu: data.gpu || meta.value.gpu, node: data.node || meta.value.node, + endpoint: data.endpoint || meta.value.endpoint || apiHost, }; } catch { // swallow @@ -211,7 +213,8 @@ function handleKeydown(e) { } async function copyCurl() { - const curl = `curl -X POST ${new URL(API_URL, window.location.href).toString()} -H 'content-type: application/json' -d '{\"message\":\"hi\"}'`; + const target = meta.value.endpoint || new URL(API_URL, window.location.href).toString(); + const curl = `curl -X POST ${target} -H 'content-type: application/json' -d '{\"message\":\"hi\"}'`; try { await navigator.clipboard.writeText(curl); copied.value = true;