Spaces:
Running
Running
更新 start.sh
Browse files
start.sh
CHANGED
|
@@ -3,17 +3,16 @@ set -euo pipefail
|
|
| 3 |
|
| 4 |
LITELLM_PID=""
|
| 5 |
|
| 6 |
-
# ── 0. Write openclaw.json
|
| 7 |
OPENCLAW_CONFIG_DIR="${HOME}/.openclaw"
|
| 8 |
-
OPENCLAW_CONFIG="${OPENCLAW_CONFIG_DIR}/openclaw.json"
|
| 9 |
mkdir -p "$OPENCLAW_CONFIG_DIR"
|
| 10 |
|
| 11 |
-
# Pin the gateway token so it never changes between restarts.
|
| 12 |
-
# Set OPENCLAW_GATEWAY_TOKEN in HF Space Secrets for a custom token.
|
| 13 |
-
# Access the UI via: https://your-space.hf.space/#token=<your-token>
|
| 14 |
GATEWAY_TOKEN="${OPENCLAW_GATEWAY_TOKEN:-openclaw-hf-default-token}"
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
{
|
| 18 |
"gateway": {
|
| 19 |
"bind": "lan",
|
|
@@ -26,11 +25,35 @@ cat > "$OPENCLAW_CONFIG" << OPENCLAW_JSON
|
|
| 26 |
"dangerouslyDisableDeviceAuth": true,
|
| 27 |
"dangerouslyAllowHostHeaderOriginFallback": true
|
| 28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
}
|
| 30 |
}
|
| 31 |
OPENCLAW_JSON
|
| 32 |
|
| 33 |
-
echo "[start.sh] openclaw.json written (token=${GATEWAY_TOKEN:0:8}...)"
|
| 34 |
echo "[start.sh] Access UI at: https://<your-space>.hf.space/#token=${GATEWAY_TOKEN}"
|
| 35 |
|
| 36 |
# ── 1. Check if LiteLLM should be enabled ─────────────────────────────────────
|
|
@@ -86,8 +109,5 @@ until curl -sf http://127.0.0.1:4000/health/liveliness > /dev/null 2>&1; do
|
|
| 86 |
done
|
| 87 |
echo "[start.sh] LiteLLM healthy after ${WAITED}s"
|
| 88 |
|
| 89 |
-
# ── 5. Start OpenClaw
|
| 90 |
-
exec
|
| 91 |
-
OPENAI_API_KEY=litellm-proxy \
|
| 92 |
-
OPENAI_BASE_URL=http://127.0.0.1:4000 \
|
| 93 |
-
openclaw gateway --port 7860 --allow-unconfigured
|
|
|
|
| 3 |
|
| 4 |
LITELLM_PID=""
|
| 5 |
|
| 6 |
+
# ── 0. Write openclaw.json ─────────────────────────────────────────────────────
|
| 7 |
OPENCLAW_CONFIG_DIR="${HOME}/.openclaw"
|
|
|
|
| 8 |
mkdir -p "$OPENCLAW_CONFIG_DIR"
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
GATEWAY_TOKEN="${OPENCLAW_GATEWAY_TOKEN:-openclaw-hf-default-token}"
|
| 11 |
|
| 12 |
+
# Register LiteLLM proxy as a custom provider directly in openclaw.json.
|
| 13 |
+
# apiKey goes in models.providers (not auth-profiles.json) for custom providers.
|
| 14 |
+
# agents.defaults.model points to litellm/default so OpenClaw stops trying Anthropic.
|
| 15 |
+
cat > "${OPENCLAW_CONFIG_DIR}/openclaw.json" << OPENCLAW_JSON
|
| 16 |
{
|
| 17 |
"gateway": {
|
| 18 |
"bind": "lan",
|
|
|
|
| 25 |
"dangerouslyDisableDeviceAuth": true,
|
| 26 |
"dangerouslyAllowHostHeaderOriginFallback": true
|
| 27 |
}
|
| 28 |
+
},
|
| 29 |
+
"models": {
|
| 30 |
+
"providers": {
|
| 31 |
+
"litellm": {
|
| 32 |
+
"baseUrl": "http://127.0.0.1:4000",
|
| 33 |
+
"apiKey": "litellm-proxy",
|
| 34 |
+
"api": "openai-responses",
|
| 35 |
+
"models": [
|
| 36 |
+
{
|
| 37 |
+
"id": "default",
|
| 38 |
+
"name": "LiteLLM Proxy (${LITELLM_MODEL:-custom})",
|
| 39 |
+
"contextWindow": 200000,
|
| 40 |
+
"maxTokens": 8192,
|
| 41 |
+
"input": ["text", "image"],
|
| 42 |
+
"reasoning": false
|
| 43 |
+
}
|
| 44 |
+
]
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
"agents": {
|
| 49 |
+
"defaults": {
|
| 50 |
+
"model": "litellm/default"
|
| 51 |
+
}
|
| 52 |
}
|
| 53 |
}
|
| 54 |
OPENCLAW_JSON
|
| 55 |
|
| 56 |
+
echo "[start.sh] openclaw.json written (provider=litellm, token=${GATEWAY_TOKEN:0:8}...)"
|
| 57 |
echo "[start.sh] Access UI at: https://<your-space>.hf.space/#token=${GATEWAY_TOKEN}"
|
| 58 |
|
| 59 |
# ── 1. Check if LiteLLM should be enabled ─────────────────────────────────────
|
|
|
|
| 109 |
done
|
| 110 |
echo "[start.sh] LiteLLM healthy after ${WAITED}s"
|
| 111 |
|
| 112 |
+
# ── 5. Start OpenClaw ─────────────────────────────────────────────────────────
|
| 113 |
+
exec openclaw gateway --port 7860 --allow-unconfigured
|
|
|
|
|
|
|
|
|