Switch OpenViking's embedding model to a local llama-server (or any OpenAI-compatible embedding endpoint) running inside a bwrap sandbox managed by job-env-manager. Handles the full lifecycle: detect current config, validate the target embedding endpoint, modify ov.conf, delete incompatible vectordb index when dimension changes, restart the openviking-server process in the sandbox, and verify the new collection dimension. Use this skill when the user wants to: (1) switch the OpenViking embedding model, (2) change the embedding dimension, (3) fix EmbeddingRebuildRequiredError after a dimension mismatch, (4) rebuild the vectordb index after an embedding model change, (5) use a local llama-server for OpenViking embeddings. Trigger words: "切换OpenViking embedding", "OpenViking embedding模型", "OpenViking向量化模型", "openviking embedding switch", "change openviking embedding model", "配置openviking embedding", "openviking llama embedding", "bge embedding openviking", "切换向量化模型", "OpenViking模型切换".
Switch the embedding model used by OpenViking to a local llama-server or any OpenAI-compatible endpoint, with proper vectordb index rebuild and sandbox-safe restart.
⚠️ Single-purpose skill — all operations go through the job-env-manager REST API (http://127.0.0.1:8090). Never run openviking-server directly on the host.
OpenViking is an AI context database that uses vector embeddings for semantic search. Its embedding model is configured in ov.conf under the embedding.dense section. When switching to a different embedding model (especially one with a different vector dimension), the existing vectordb index must be deleted and rebuilt — otherwise OpenViking raises EmbeddingRebuildRequiredError on startup.
OpenViking environment deployed and running (state = running)
llama-server running at 127.0.0.1:{port} with --embeddings flag
curl and python3 available on the host
No AK/SK or Huawei Cloud credentials required
IAM Permission Policies
This skill operates on local bwrap sandboxes via the job-env-manager REST API and does not access Huawei Cloud services — no Huawei Cloud IAM policies required. Equivalent access controls are listed in references/iam-policies.md.
Task 5: Restart openviking-server Inside the Sandbox
⚠️ Pitfall:POST /envs/openviking/stop + start re-runs start.sh, which overwrites ov.conf with TokenHub credentials. Do not use stop/start.
Instead:
Kill old process from host: find the PID by reverse-looking-up port 1933 (ss -tlnp / fuser), then kill $PID, and poll for port 1933 release (up to 10s). If SIGTERM doesn't release the port, escalate to kill -9. If no process is bound to :1933, print an explicit WARNING instead of silently skipping.
Clean up stale lock files: .openviking.pid and vectordb LOCK files.
Start new server via exec API with --max-time 15. Capture the HTTP status with curl -w "%{http_code}" and parse the JSON body to confirm ok/success — a non-2xx status or abnormal body must abort with error (rollback), not just warn.
Health check with retry loop (up to 30s): polls GET /health every second until healthy=true or timeout
PID change check: verifies a new server process is bound to port 1933 and its PID differs from the old one (found by port reverse lookup, not process-name glob) — detects port conflict false positives even when no old PID could be located
Collection dimension check: retries (up to 15s) until collection_meta.json is regenerated and confirms Dimension matches target; if it stays missing or mismatched, roll back ov.conf.bak and exit with error
Log error check: precise grep for Traceback|ERROR.*Application startup failed|EmbeddingRebuildRequiredError|DataDirectoryLocked (avoids false positives from "Retrying" info messages)
Rollback on failure: if exec API fails, health check fails, PID is unchanged/missing, or collection dimension mismatches, restores ov.conf.bak and exits with error