Subject-Emu-5259 commited on
Commit
81045b4
·
verified ·
1 Parent(s): 17814b8

sync: update run_service.sh

Browse files
Files changed (1) hide show
  1. run_service.sh +46 -0
run_service.sh ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # NeuralAI launcher — LOCAL-ONLY inference.
3
+ # LM Studio (llama.cpp) serves SmolLM2-360M on :1234 (OpenAI-compatible).
4
+ # NO external/ZO fallback: if the local model can't serve, the UI errors
5
+ # honestly instead of relaying to ZO.
6
+ set -u
7
+
8
+ # Public service URL: the keep-alive pinger hits this (real external ingress)
9
+ # so the ZO Computer sandbox is not idled/slept by the platform on Free tier.
10
+ export NEURALAI_PUBLIC_URL="https://neuralai-web-ui-deandrewharris.zocomputer.io"
11
+ export PATH="$HOME/.lmstudio/bin:$PATH"
12
+ LMS="$HOME/.lmstudio/bin/lms"
13
+ MODEL_KEY="smollm2-360m-instruct"
14
+ API_KEY="lm-studio"
15
+
16
+ echo "[launch] checking LM Studio on :1234"
17
+ if ! curl -s -o /dev/null --max-time 4 http://localhost:1234/v1/models 2>/dev/null; then
18
+ echo "[launch] starting LM Studio server..."
19
+ ( "$LMS" server start >/dev/null 2>&1 || true ) &
20
+ for i in $(seq 1 15); do
21
+ curl -s -o /dev/null --max-time 3 http://localhost:1234/v1/models 2>/dev/null && break
22
+ sleep 2
23
+ done
24
+ fi
25
+
26
+ echo "[launch] loading model $MODEL_KEY into LM Studio..."
27
+ "$LMS" load "$MODEL_KEY" --yes >/dev/null 2>&1 || true
28
+ for i in $(seq 1 30); do
29
+ curl -s --max-time 3 http://localhost:1234/v1/models 2>/dev/null | grep -q "$MODEL_KEY" && break
30
+ sleep 2
31
+ done
32
+
33
+ if curl -s --max-time 4 http://localhost:1234/v1/models 2>/dev/null | grep -q "$MODEL_KEY"; then
34
+ echo "[launch] LOCAL backend READY -> openai_compatible (:1234)"
35
+ else
36
+ echo "[launch] ERROR: local model not available on :1234 — UI will error (NO ZO fallback)"
37
+ fi
38
+
39
+ # Always local-only. No fallback to ZO.
40
+ export LLM_BACKEND="openai_compatible"
41
+ export LLM_API_URL="http://localhost:1234/v1"
42
+ export LLM_API_KEY="$API_KEY"
43
+ export LLM_MODEL="$MODEL_KEY"
44
+
45
+ echo "[launch] exec webui_service ($(date -u))"
46
+ exec python /home/workspace/Projects/NeuralAI/services/webui_service.py