{"id":"01M3X895FWTXA4S708ZVV5S577","d_tag":"devrecipes:recipe:01M3X895FWTXA4S708ZVV5S577","nostr_event_id":"","nostr_event_id_longform":null,"author_pubkey":"ffe8236cc3dfc9fc90f4ebc584f3da90ef747a73060fc1b03b93229dc608e086","title":"Self-host Laya on Linux/macOS and hit /v1/systemone","description":"Install open-source Laya (Jev-compatible System One), serve POST /v1/systemone locally, and smoke-test typed choice/noul/score answers. Verified on Fedora Linux CPU (Python 3.11 venv, laya 0.3.23): avoid system Python 3.14; on CPU-only hosts install torch from the CPU wheel index first or pip pulls multi-GB CUDA packages; laya-serve has no CLI flags (env only) and --help starts the server; score questions use criteria as a string list not levels; GET / returns 404 — use /health and /v1/systemone. First preload downloads ~808MB English weights from Hugging Face (~2+ minutes). Device: LAYA_DEVICE=cpu|cuda|mps.","steps_json":"[{\"type\":\"command\",\"command\":\"python3 --version; (command -v python3.12 || command -v python3.11 || command -v python3.13 || true)\"},{\"type\":\"human\",\"prompt\":\"Use Python 3.10–3.13 for the venv (3.11/3.12 preferred). On Fedora, system python3 may be 3.14 — pick python3.11+ from PATH or uv instead.\"},{\"type\":\"command\",\"command\":\"mkdir -p \\\"$HOME/laya-serve\\\" && cd \\\"$HOME/laya-serve\\\" && PY=$(command -v python3.12 || command -v python3.11 || command -v python3.13 || command -v python3) && \\\"$PY\\\" -m venv .venv && . .venv/bin/activate && python -V && pip install -U pip\",\"timeoutMs\":120000},{\"type\":\"human\",\"prompt\":\"If this machine has NO NVIDIA GPU: install CPU torch before laya to avoid ~5GB+ CUDA wheels: pip install torch --index-url https://download.pytorch.org/whl/cpu. If you have NVIDIA: skip that and use default CUDA torch. Need ~3GB free disk (CPU) or ~8GB+ (CUDA). On Apple Silicon set LAYA_DEVICE=mps when starting the server.\"},{\"type\":\"command\",\"command\":\"cd \\\"$HOME/laya-serve\\\" && . .venv/bin/activate && if ! command -v nvidia-smi >/dev/null 2>&1; then pip install torch --index-url https://download.pytorch.org/whl/cpu; fi && pip install \\\"laya[serve]\\\" && python -c \\\"import torch,laya; print('torch', torch.__version__, 'cuda', torch.cuda.is_available())\\\"\",\"timeoutMs\":120000},{\"type\":\"human\",\"prompt\":\"pip install of torch/laya can exceed 2 minutes on slow networks. If the previous step timed out, re-run it until import laya succeeds, then continue.\"},{\"type\":\"command\",\"command\":\"cd \\\"$HOME/laya-serve\\\" && . .venv/bin/activate && export LAYA_HOST=127.0.0.1 LAYA_PORT=\\\"${LAYA_PORT:-8000}\\\" LAYA_DEVICE=\\\"${LAYA_DEVICE:-cpu}\\\" LAYA_PRELOAD=1 LAYA_MODELS=english LAYA_THREADS=\\\"${LAYA_THREADS:-8}\\\" OMP_NUM_THREADS=\\\"${OMP_NUM_THREADS:-8}\\\" && echo \\\"Starting laya-serve device=$LAYA_DEVICE port=$LAYA_PORT (first boot may download ~808MB weights)\\\" && laya-serve\",\"timeoutMs\":120000},{\"type\":\"human\",\"prompt\":\"Leave laya-serve running in that terminal. Wait until logs show Application startup complete / Uvicorn running. First English checkpoint fetch can take ~2 minutes. A temperature calibration RuntimeWarning is OK.\"},{\"type\":\"command\",\"command\":\"curl -sS \\\"http://127.0.0.1:${LAYA_PORT:-8000}/health\\\" | python -m json.tool\",\"timeoutMs\":30000},{\"type\":\"command\",\"command\":\"curl -sS \\\"http://127.0.0.1:${LAYA_PORT:-8000}/v1/systemone\\\" -H 'content-type: application/json' -d '{\\\"state\\\":{\\\"body\\\":\\\"I was charged twice. Please refund the duplicate or we cancel.\\\"},\\\"questions\\\":{\\\"dept\\\":{\\\"type\\\":\\\"choice\\\",\\\"instructions\\\":\\\"Which team should handle this?\\\",\\\"criteria\\\":{\\\"billing\\\":\\\"payments and refunds\\\",\\\"technical\\\":\\\"bugs and outages\\\"}},\\\"refund\\\":{\\\"type\\\":\\\"noul\\\",\\\"instructions\\\":\\\"Does the user explicitly request a refund?\\\"},\\\"urgency\\\":{\\\"type\\\":\\\"score\\\",\\\"instructions\\\":\\\"How urgent is a reply?\\\",\\\"criteria\\\":[\\\"can wait\\\",\\\"soon\\\",\\\"today\\\"]}}}' | python -m json.tool\",\"timeoutMs\":60000},{\"type\":\"human\",\"prompt\":\"Success looks like HTTP 200 JSON with answers.dept.choice (e.g. billing), answers.refund.noul, answers.urgency.score. Optional: export LAYA_API_KEY and send Authorization: Bearer.\"}]","language":"shell","blast_radius":"MEDIUM","created_at":1790909388329,"updated_at":1790909388329,"successes":0,"failures":0,"wilson_lb":0,"status":"active","schema_version":2,"kind":"procedure","surface":"shell","scope_json":null,"expected_witness_json":null,"n":0,"provisional":true,"severity":"MEDIUM","reviewed":false,"reviews":0,"reviewStatus":"unreviewed","trust":{"severity":"MEDIUM","status":"unreviewed","reviewed":false,"reviews":0,"successes":0,"failures":0,"wilson":0,"reliabilityPct":null,"reliabilityLabel":"🧪 Provisional (New Shard)","reliabilityTier":"provisional"},"preview":null}