Skip to content

Commit 48e11be

Browse files
committed
server: OpenAI API and llama.cpp Web UI compatibility
- OpenAI-style /v1/models, /v1/chat/completions (SSE), error bodies, CORS - GET /props and enriched model rows for ggml Web UI - Session file persistence and optional TILES_BOOTSTRAP_* startup load - POST /models/load when TILES_MODEL_CACHE_PATH is set (Web UI load) - Chat SSE: timings (Web UI) and metrics (Tiles CLI memory mode) - Pytest coverage; TILES_SKIP_SESSION_PERSIST in tests - just webui-llamacpp via scripts/phase2_llamacpp_webui.sh Made-with: Cursor
1 parent 1b8be89 commit 48e11be

File tree

12 files changed

+1119
-158
lines changed

12 files changed

+1119
-158
lines changed

justfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ serve:
1515
server/.venv/bin/python3 -m server.main
1616
# uv run --project server python -m server.main
1717

18+
# Python server (OpenAI compat API tests; requires uv sync in server/)
19+
test-server:
20+
uv run --project server pytest server/tests/ -v
21+
22+
# llama.cpp SvelteKit UI (clone under ../llama.cpp by default); proxies to Tiles :6969
23+
webui-llamacpp:
24+
bash scripts/phase2_llamacpp_webui.sh
25+
1826
bundle:
1927
./scripts/bundler.sh
2028

scripts/phase2_llamacpp_webui.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
# Run ggml-org/llama.cpp SvelteKit web UI with the dev proxy pointed at the Tiles server.
3+
#
4+
# Prerequisites: Node.js (npm), git. Start Tiles separately (e.g. just serve on :6969).
5+
#
6+
# Environment:
7+
# LLAMA_CPP_ROOT Clone path (default: sibling of this repo: ../llama.cpp)
8+
# TILES_BACKEND Proxy target (default: http://127.0.0.1:6969)
9+
10+
set -euo pipefail
11+
12+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
13+
LLAMA_CPP="${LLAMA_CPP_ROOT:-$ROOT/../llama.cpp}"
14+
BACKEND="${TILES_BACKEND:-http://127.0.0.1:6969}"
15+
WEBUI="$LLAMA_CPP/tools/server/webui"
16+
VITE_CFG="$WEBUI/vite.config.ts"
17+
18+
if [ ! -d "$LLAMA_CPP" ]; then
19+
echo "Cloning llama.cpp -> $LLAMA_CPP"
20+
git clone --depth 1 https://github.com/ggml-org/llama.cpp "$LLAMA_CPP"
21+
fi
22+
23+
if [ ! -f "$VITE_CFG" ]; then
24+
echo "Expected file missing: $VITE_CFG"
25+
exit 1
26+
fi
27+
28+
if ! grep -qF "$BACKEND" "$VITE_CFG" 2>/dev/null; then
29+
echo "Patching $VITE_CFG to proxy API routes to $BACKEND"
30+
cp "$VITE_CFG" "${VITE_CFG}.tiles.bak"
31+
perl -pi -e "s|http://localhost:8080|${BACKEND}|g" "$VITE_CFG"
32+
fi
33+
34+
echo "Backend proxy: $BACKEND (run Tiles with just serve). Load model via POST /start, session file, TILES_BOOTSTRAP_*, or TILES_MODEL_CACHE_PATH + UI load."
35+
echo ""
36+
37+
cd "$WEBUI"
38+
if [ -f package-lock.json ]; then
39+
npm ci
40+
else
41+
npm install
42+
fi
43+
exec npm run dev

0 commit comments

Comments
 (0)