Loading...
Loading...
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模型切换".
npx skill4agent add huaweicloud/huaweicloud-skills huawei-cloud-openviking-embedding-switch⚠️ Single-purpose skill — all operations go through the job-env-manager REST API (). Never runhttp://127.0.0.1:8090directly on the host.openviking-server
ov.confembedding.denseEmbeddingRebuildRequiredErrorOpenViking Embedding Model Switch
├── Detect current config (Read ov.conf embedding.dense section)
├── Validate endpoint (Check llama-server /v1/embeddings)
├── Modify ov.conf (Update provider, model, api_base, dimension)
├── Delete vectordb index (If dimension changed: rm -rf vectordb/context)
├── Restart server (Kill + exec, NOT stop/start)
└── Verify (Health + PID + dimension + log check)┌─────────────────────────────────────────────────────┐
│ Host │
│ │
│ ┌─────────────┐ REST API ┌──────────────────┐ │
│ │ Agent │─────────────▶│ job-env-manager │ │
│ │ (this skill)│ │ :8090 │ │
│ └─────────────┘ └────────┬─────────┘ │
│ │ │
│ ┌──────────────────────────────┼──────┐ │
│ │ bwrap sandbox (openviking) │ │ │
│ │ ▼ │ │
│ │ ┌────────────────────────────────┐ │ │
│ │ │ openviking-server :1933 │ │ │
│ │ │ ├── ov.conf (embedding config)│ │ │
│ │ │ ├── vectordb/context/ │ │ │
│ │ │ └── viking/ (metadata) │ │ │
│ │ └────────────────────────────────┘ │ │
│ └──────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────┐ │
│ │ bwrap sandbox (llama) │ │
│ │ ┌────────────────────────────────┐ │ │
│ │ │ llama-server :18200 │ │ │
│ │ │ --embeddings --model bge-... │ │ │
│ │ └────────────────────────────────┘ │ │
│ └──────────────────────────────────────┘ │
│ │
│ Both sandboxes use --share-net, so 127.0.0.1 │
│ endpoints are mutually reachable. │
└─────────────────────────────────────────────────────┘Prerequisite check: job-env-manager runningbashcurl -s http://127.0.0.1:8090/api/v1/envs/openviking | python3 -c "import sys,json; print(json.load(sys.stdin)['state'])"
http://127.0.0.1:8090running127.0.0.1:{port}--embeddingsSANDBOX_DIR=$(curl -s http://127.0.0.1:8090/api/v1/envs/openviking \
| python3 -c "import sys,json; print(json.load(sys.stdin)['cwd'])")ov.confembedding.densecurl -s http://127.0.0.1:${LLAMA_PORT}/v1/embeddings \
-H "Content-Type: application/json" \
-d '{"model":"${MODEL_NAME}","input":"test"}' \
| python3 -c "import sys,json; d=json.load(sys.stdin); print(len(d['data'][0]['embedding']))"ov.confov.conf.bakembedding.dense| Field | Description |
|---|---|
| Embedding provider name |
| Model name (e.g., |
| API key for the endpoint (empty for local) |
| Endpoint URL (e.g., |
| Vector dimension (auto-corrected from endpoint) |
⚠️ Critical: If dimensions differ,is required. Otherwiserm -rf vectordb/contexton startup.EmbeddingRebuildRequiredError
⚠️ Pitfall:+POST /envs/openviking/stopre-runsstart, which overwritesstart.shwith TokenHub credentials. Do not use stop/start.ov.conf
kill $PIDkill -9.openviking.pidLOCKexec--max-time 15curl -s --max-time 15 -X POST http://127.0.0.1:8090/api/v1/envs/openviking/exec \
-H 'Content-Type: application/json' \
-d '{"cmd":["bash","-c","nohup /root/runtime/openviking/venv/bin/openviking-server --config /workspace/process_dir/ov.conf > /workspace/process_dir/openviking-server.log 2>&1 & sleep 2 && echo started"]}'GET /healthhealthy=truecollection_meta.jsonDimensionTraceback|ERROR.*Application startup failed|EmbeddingRebuildRequiredError|DataDirectoryLockedov.conf.bak| Parameter | Required | Description | Example |
|---|---|---|---|
| Yes | Embedding model name | |
| Yes | llama-server port | |
| Yes | Vector dimension (auto-corrected if wrong) | |
# Usage
bash scripts/switch-embedding-model.sh <model_name> <llama_port> <dimension>| Model | Dimension | Typical Use |
|---|---|---|
| 512 | Lightweight Chinese embedding |
| 1024 | High-quality Chinese embedding |
| 384 | Lightweight English embedding |
| 768 | General-purpose English embedding |
| 1024 | Qwen3 embedding (TokenHub default) |
# 1. Server healthy
curl -s http://127.0.0.1:1933/health \
| python3 -c "import sys,json; assert json.load(sys.stdin)['healthy']; print('OK')"
# 2. Collection dimension matches target
python3 -c "import json; d=json.load(open('${SANDBOX_DIR}/data/vectordb/context/collection_meta.json')); assert d['Dimension']==${TARGET_DIMENSION}; print('OK')"
# 3. No errors in log (precise pattern)
grep -ci "Traceback\|Application startup failed\|EmbeddingRebuildRequiredError\|DataDirectoryLocked" \
"${SANDBOX_DIR}/process_dir/openviking-server.log"
# Expected: 0openviking-serverstart.shov.confov.conf.bak| Document | Description |
|---|---|
| config-reference.md | ov.conf embedding section field reference |
| guardrails.md | Safety rules: sandbox execution, restart sequence, rollback |
| iam-policies.md | Equivalent access controls (no Huawei Cloud IAM needed) |
| verification-method.md | Step-by-step verification for each workflow |
| related-commands.md | Common job-env-manager and curl commands |
| acceptance-criteria.md | Acceptance criteria for a successful switch |
| troubleshooting.md | Troubleshooting for common failure scenarios |
| dataflow-diagram.md | Mermaid data flow diagram |
| demo/example-input.json | Example input for the switch workflow |