Use separate env vars for model chain
Browse files- README.md +9 -8
- guide.md +6 -4
- setup-hf-config.mjs +24 -8
README.md
CHANGED
|
@@ -27,9 +27,9 @@ This Space runs the [OpenClaw](https://github.com/openclaw/openclaw) gateway so
|
|
| 27 |
- **`OPENCODE_API_KEY`** — (optional) OpenCode Zen API key. OpenClaw reads this directly from the gateway environment for the `opencode` provider.
|
| 28 |
- **`SUPABASE_URL`** — (recommended) Supabase project URL for external state backup.
|
| 29 |
- **`SUPABASE_KEY`** — (recommended) Supabase service key or project API key with insert/update access to your sync table.
|
| 30 |
-
- **`
|
| 31 |
-
- **`
|
| 32 |
-
- **`
|
| 33 |
- **`OPENCLAW_GATEWAY_TRUSTED_PROXIES`** — (optional) Comma-separated proxy IPs (e.g. `10.20.31.87,10.20.26.157`). The startup script writes this into `gateway.trustedProxies`; set if you see “Proxy headers detected from untrusted address” or pairing/unauthorized. Use **Variables** if you prefer (IPs need not be secret).
|
| 34 |
- **`OPENCLAW_CONTROL_UI_ALLOWED_ORIGINS`** — (optional) Comma-separated origins (e.g. `https://your-space.hf.space`). Written to `gateway.controlUi.allowedOrigins` so only those origins can open the Control UI; useful to lock down to your Space URL.
|
| 35 |
- **`TELEGRAM_BOT_TOKEN`** — (optional) Telegram BotFather token. This is the only Telegram setting you need for a minimal setup.
|
|
@@ -60,8 +60,9 @@ SUPABASE_KEY=<your supabase service key>
|
|
| 60 |
TELEGRAM_BOT_TOKEN=<botfather token>
|
| 61 |
|
| 62 |
Variables
|
| 63 |
-
|
| 64 |
-
|
|
|
|
| 65 |
OPENCLAW_CONTROL_UI_ALLOWED_ORIGINS=https://your-space.hf.space
|
| 66 |
OPENCLAW_SUPABASE_TABLE=openclaw_state
|
| 67 |
OPENCLAW_SYNC_INTERVAL_MS=300000
|
|
@@ -143,9 +144,9 @@ The startup script `setup-hf-config.mjs` reads the following from **Secrets** or
|
|
| 143 |
|
| 144 |
| Env variable | Config path | Format |
|
| 145 |
|--------------|------------|--------|
|
| 146 |
-
| `
|
| 147 |
-
| `
|
| 148 |
-
| `
|
| 149 |
| `OPENCLAW_GATEWAY_TOKEN` | `gateway.auth.mode` + `gateway.auth.token` | Any string |
|
| 150 |
| `OPENCLAW_GATEWAY_PASSWORD` | `gateway.auth.mode` + `gateway.auth.password` | Any string (token wins if both set) |
|
| 151 |
| `OPENCLAW_GATEWAY_TRUSTED_PROXIES` | `gateway.trustedProxies` | Comma-separated IPs |
|
|
|
|
| 27 |
- **`OPENCODE_API_KEY`** — (optional) OpenCode Zen API key. OpenClaw reads this directly from the gateway environment for the `opencode` provider.
|
| 28 |
- **`SUPABASE_URL`** — (recommended) Supabase project URL for external state backup.
|
| 29 |
- **`SUPABASE_KEY`** — (recommended) Supabase service key or project API key with insert/update access to your sync table.
|
| 30 |
+
- **`OPENCLAW_MODEL_PRIMARY`** — (recommended) Primary model ref. This repo now defaults to `huggingface/Qwen/Qwen3-8B`.
|
| 31 |
+
- **`OPENCLAW_MODEL_FALLBACK_1`** — (recommended) First fallback model ref. Default is `huggingface/deepseek-ai/DeepSeek-R1`.
|
| 32 |
+
- **`OPENCLAW_MODEL_FALLBACK_2`** — (recommended) Second fallback model ref. Default is `gpt-codex`.
|
| 33 |
- **`OPENCLAW_GATEWAY_TRUSTED_PROXIES`** — (optional) Comma-separated proxy IPs (e.g. `10.20.31.87,10.20.26.157`). The startup script writes this into `gateway.trustedProxies`; set if you see “Proxy headers detected from untrusted address” or pairing/unauthorized. Use **Variables** if you prefer (IPs need not be secret).
|
| 34 |
- **`OPENCLAW_CONTROL_UI_ALLOWED_ORIGINS`** — (optional) Comma-separated origins (e.g. `https://your-space.hf.space`). Written to `gateway.controlUi.allowedOrigins` so only those origins can open the Control UI; useful to lock down to your Space URL.
|
| 35 |
- **`TELEGRAM_BOT_TOKEN`** — (optional) Telegram BotFather token. This is the only Telegram setting you need for a minimal setup.
|
|
|
|
| 60 |
TELEGRAM_BOT_TOKEN=<botfather token>
|
| 61 |
|
| 62 |
Variables
|
| 63 |
+
OPENCLAW_MODEL_PRIMARY=huggingface/Qwen/Qwen3-8B
|
| 64 |
+
OPENCLAW_MODEL_FALLBACK_1=huggingface/deepseek-ai/DeepSeek-R1
|
| 65 |
+
OPENCLAW_MODEL_FALLBACK_2=gpt-codex
|
| 66 |
OPENCLAW_CONTROL_UI_ALLOWED_ORIGINS=https://your-space.hf.space
|
| 67 |
OPENCLAW_SUPABASE_TABLE=openclaw_state
|
| 68 |
OPENCLAW_SYNC_INTERVAL_MS=300000
|
|
|
|
| 144 |
|
| 145 |
| Env variable | Config path | Format |
|
| 146 |
|--------------|------------|--------|
|
| 147 |
+
| `OPENCLAW_MODEL_PRIMARY` | `agents.defaults.model.primary` | Primary model ref string |
|
| 148 |
+
| `OPENCLAW_MODEL_FALLBACK_1` | `agents.defaults.model.fallbacks[0]` | First fallback model ref |
|
| 149 |
+
| `OPENCLAW_MODEL_FALLBACK_2` | `agents.defaults.model.fallbacks[1]` | Second fallback model ref |
|
| 150 |
| `OPENCLAW_GATEWAY_TOKEN` | `gateway.auth.mode` + `gateway.auth.token` | Any string |
|
| 151 |
| `OPENCLAW_GATEWAY_PASSWORD` | `gateway.auth.mode` + `gateway.auth.password` | Any string (token wins if both set) |
|
| 152 |
| `OPENCLAW_GATEWAY_TRUSTED_PROXIES` | `gateway.trustedProxies` | Comma-separated IPs |
|
guide.md
CHANGED
|
@@ -51,8 +51,9 @@ TELEGRAM_BOT_TOKEN=<你的 telegram bot token>
|
|
| 51 |
請加入:
|
| 52 |
|
| 53 |
```text
|
| 54 |
-
|
| 55 |
-
|
|
|
|
| 56 |
OPENCLAW_CONTROL_UI_ALLOWED_ORIGINS=https://你的-space-url.hf.space
|
| 57 |
OPENCLAW_SUPABASE_TABLE=openclaw_state
|
| 58 |
OPENCLAW_SYNC_INTERVAL_MS=300000
|
|
@@ -152,8 +153,9 @@ SUPABASE_KEY
|
|
| 152 |
### 必填 Variables
|
| 153 |
|
| 154 |
```text
|
| 155 |
-
|
| 156 |
-
|
|
|
|
| 157 |
```
|
| 158 |
|
| 159 |
### 建議 Variables
|
|
|
|
| 51 |
請加入:
|
| 52 |
|
| 53 |
```text
|
| 54 |
+
OPENCLAW_MODEL_PRIMARY=huggingface/Qwen/Qwen3-8B
|
| 55 |
+
OPENCLAW_MODEL_FALLBACK_1=huggingface/deepseek-ai/DeepSeek-R1
|
| 56 |
+
OPENCLAW_MODEL_FALLBACK_2=gpt-codex
|
| 57 |
OPENCLAW_CONTROL_UI_ALLOWED_ORIGINS=https://你的-space-url.hf.space
|
| 58 |
OPENCLAW_SUPABASE_TABLE=openclaw_state
|
| 59 |
OPENCLAW_SYNC_INTERVAL_MS=300000
|
|
|
|
| 153 |
### 必填 Variables
|
| 154 |
|
| 155 |
```text
|
| 156 |
+
OPENCLAW_MODEL_PRIMARY=huggingface/Qwen/Qwen3-8B
|
| 157 |
+
OPENCLAW_MODEL_FALLBACK_1=huggingface/deepseek-ai/DeepSeek-R1
|
| 158 |
+
OPENCLAW_MODEL_FALLBACK_2=gpt-codex
|
| 159 |
```
|
| 160 |
|
| 161 |
### 建議 Variables
|
setup-hf-config.mjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
| 2 |
/**
|
| 3 |
* One-time setup for OpenClaw on Hugging Face Spaces.
|
| 4 |
* Runs at container startup; writes or merges openclaw.json from env (Secrets/Variables):
|
| 5 |
-
* - agents.defaults.model.primary from
|
| 6 |
-
* - agents.defaults.model.fallbacks from
|
| 7 |
* - gateway.auth: OPENCLAW_GATEWAY_TOKEN (token) or OPENCLAW_GATEWAY_PASSWORD (password); token wins if both set.
|
| 8 |
* - gateway.controlUi.dangerouslyDisableDeviceAuth when auth is set (no device pairing in Spaces).
|
| 9 |
* - gateway.trustedProxies from OPENCLAW_GATEWAY_TRUSTED_PROXIES, or default HF proxy IPs so the UI works without extra config.
|
|
@@ -46,14 +46,28 @@ function parseBoolean(raw) {
|
|
| 46 |
return undefined;
|
| 47 |
}
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
const defaultModel =
|
| 50 |
-
process.env.
|
| 51 |
-
process.env.OPENCLAW_HF_DEFAULT_MODEL?.trim() ||
|
| 52 |
"huggingface/Qwen/Qwen3-8B";
|
| 53 |
-
const fallbackModels =
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
const gatewayToken = readGatewayToken();
|
| 58 |
const gatewayPassword = process.env.OPENCLAW_GATEWAY_PASSWORD?.trim();
|
| 59 |
const telegramBotToken = process.env.TELEGRAM_BOT_TOKEN?.trim();
|
|
@@ -170,6 +184,8 @@ const authKind = useTokenAuth ? "token" : usePasswordAuth ? "password" : "none";
|
|
| 170 |
const parts = [
|
| 171 |
`model=${defaultModel}`,
|
| 172 |
`fallbacks=${fallbackModels.length}`,
|
|
|
|
|
|
|
| 173 |
`token_present=${useTokenAuth ? "1" : "0"}`,
|
| 174 |
`password_present=${usePasswordAuth ? "1" : "0"}`,
|
| 175 |
`auth=${authKind}`,
|
|
|
|
| 2 |
/**
|
| 3 |
* One-time setup for OpenClaw on Hugging Face Spaces.
|
| 4 |
* Runs at container startup; writes or merges openclaw.json from env (Secrets/Variables):
|
| 5 |
+
* - agents.defaults.model.primary from OPENCLAW_MODEL_PRIMARY.
|
| 6 |
+
* - agents.defaults.model.fallbacks from OPENCLAW_MODEL_FALLBACK_1..N.
|
| 7 |
* - gateway.auth: OPENCLAW_GATEWAY_TOKEN (token) or OPENCLAW_GATEWAY_PASSWORD (password); token wins if both set.
|
| 8 |
* - gateway.controlUi.dangerouslyDisableDeviceAuth when auth is set (no device pairing in Spaces).
|
| 9 |
* - gateway.trustedProxies from OPENCLAW_GATEWAY_TRUSTED_PROXIES, or default HF proxy IPs so the UI works without extra config.
|
|
|
|
| 46 |
return undefined;
|
| 47 |
}
|
| 48 |
|
| 49 |
+
function readIndexedEnv(prefix) {
|
| 50 |
+
return Object.keys(process.env)
|
| 51 |
+
.filter((key) => key.startsWith(prefix))
|
| 52 |
+
.map((key) => {
|
| 53 |
+
const suffix = key.slice(prefix.length);
|
| 54 |
+
const index = Number.parseInt(suffix, 10);
|
| 55 |
+
return Number.isFinite(index) ? { key, index } : null;
|
| 56 |
+
})
|
| 57 |
+
.filter(Boolean)
|
| 58 |
+
.sort((a, b) => a.index - b.index)
|
| 59 |
+
.map(({ key }) => process.env[key]?.trim())
|
| 60 |
+
.filter(Boolean);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
const fallbackModelsFromIndexedEnv = readIndexedEnv("OPENCLAW_MODEL_FALLBACK_");
|
| 64 |
const defaultModel =
|
| 65 |
+
process.env.OPENCLAW_MODEL_PRIMARY?.trim() ||
|
|
|
|
| 66 |
"huggingface/Qwen/Qwen3-8B";
|
| 67 |
+
const fallbackModels =
|
| 68 |
+
fallbackModelsFromIndexedEnv.length > 0
|
| 69 |
+
? fallbackModelsFromIndexedEnv
|
| 70 |
+
: ["huggingface/deepseek-ai/DeepSeek-R1", "gpt-codex"];
|
| 71 |
const gatewayToken = readGatewayToken();
|
| 72 |
const gatewayPassword = process.env.OPENCLAW_GATEWAY_PASSWORD?.trim();
|
| 73 |
const telegramBotToken = process.env.TELEGRAM_BOT_TOKEN?.trim();
|
|
|
|
| 184 |
const parts = [
|
| 185 |
`model=${defaultModel}`,
|
| 186 |
`fallbacks=${fallbackModels.length}`,
|
| 187 |
+
`fallback_1=${fallbackModels[0] || "-"}`,
|
| 188 |
+
`fallback_2=${fallbackModels[1] || "-"}`,
|
| 189 |
`token_present=${useTokenAuth ? "1" : "0"}`,
|
| 190 |
`password_present=${usePasswordAuth ? "1" : "0"}`,
|
| 191 |
`auth=${authKind}`,
|