8900 commited on
Update setup-hf-config.mjs
Browse files- setup-hf-config.mjs +13 -15
setup-hf-config.mjs
CHANGED
|
@@ -20,20 +20,17 @@ function parseList(val) {
|
|
| 20 |
return val.split(",").map(s => s.trim()).filter(Boolean);
|
| 21 |
}
|
| 22 |
|
| 23 |
-
// 默认模型
|
| 24 |
const defaultModel = (process.env.OPENCLAW_HF_DEFAULT_MODEL || "").trim() || "huggingface/deepseek-ai/DeepSeek-R1";
|
| 25 |
const gatewayToken = readGatewayToken();
|
| 26 |
const gatewayPassword = (process.env.OPENCLAW_GATEWAY_PASSWORD || "").trim();
|
| 27 |
|
| 28 |
const DEFAULT_HF_TRUSTED_PROXY_IPS = [
|
| 29 |
-
"10.16.4.123","10.16.7.92","10.16.18.232","10.16.34.155",
|
| 30 |
-
"10.
|
| 31 |
-
"10.20.31.87","10.20.0.1","172.17.0.1"
|
| 32 |
];
|
| 33 |
|
| 34 |
const trustedProxiesRaw = (process.env.OPENCLAW_GATEWAY_TRUSTED_PROXIES || "").trim();
|
| 35 |
const trustedProxies = trustedProxiesRaw ? parseList(trustedProxiesRaw) : DEFAULT_HF_TRUSTED_PROXY_IPS;
|
| 36 |
-
|
| 37 |
const allowedOrigins = parseList(process.env.OPENCLAW_CONTROL_UI_ALLOWED_ORIGINS || "");
|
| 38 |
|
| 39 |
let config = {};
|
|
@@ -51,13 +48,8 @@ const usePasswordAuth = gatewayPassword.length > 0 && !useTokenAuth;
|
|
| 51 |
|
| 52 |
if (useTokenAuth || usePasswordAuth) {
|
| 53 |
if (!config.gateway.auth) config.gateway.auth = {};
|
| 54 |
-
if (useTokenAuth) {
|
| 55 |
-
|
| 56 |
-
config.gateway.auth.token = gatewayToken;
|
| 57 |
-
} else {
|
| 58 |
-
config.gateway.auth.mode = "password";
|
| 59 |
-
config.gateway.auth.password = gatewayPassword;
|
| 60 |
-
}
|
| 61 |
}
|
| 62 |
|
| 63 |
if (!config.gateway.controlUi) config.gateway.controlUi = {};
|
|
@@ -65,15 +57,21 @@ config.gateway.controlUi.dangerouslyDisableDeviceAuth = true;
|
|
| 65 |
config.gateway.controlUi.allowInsecureAuth = true;
|
| 66 |
|
| 67 |
if (allowedOrigins.length > 0) config.gateway.controlUi.allowedOrigins = allowedOrigins;
|
| 68 |
-
|
| 69 |
config.gateway.trustedProxies = trustedProxies;
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
try {
|
| 72 |
fs.mkdirSync(stateDir, { recursive: true });
|
| 73 |
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
|
| 74 |
} catch (e) {
|
| 75 |
-
console.error("[openclaw-hf-setup] failed to write config:
|
| 76 |
-
process.exit(
|
| 77 |
}
|
| 78 |
|
| 79 |
const authKind = useTokenAuth ? "token" : (usePasswordAuth ? "password" : "none");
|
|
|
|
| 20 |
return val.split(",").map(s => s.trim()).filter(Boolean);
|
| 21 |
}
|
| 22 |
|
|
|
|
| 23 |
const defaultModel = (process.env.OPENCLAW_HF_DEFAULT_MODEL || "").trim() || "huggingface/deepseek-ai/DeepSeek-R1";
|
| 24 |
const gatewayToken = readGatewayToken();
|
| 25 |
const gatewayPassword = (process.env.OPENCLAW_GATEWAY_PASSWORD || "").trim();
|
| 26 |
|
| 27 |
const DEFAULT_HF_TRUSTED_PROXY_IPS = [
|
| 28 |
+
"10.16.4.123","10.16.7.92","10.16.18.232","10.16.34.155","10.16.43.133",
|
| 29 |
+
"10.20.1.9","10.20.1.222","10.20.26.157","10.20.31.87","10.20.0.1","172.17.0.1"
|
|
|
|
| 30 |
];
|
| 31 |
|
| 32 |
const trustedProxiesRaw = (process.env.OPENCLAW_GATEWAY_TRUSTED_PROXIES || "").trim();
|
| 33 |
const trustedProxies = trustedProxiesRaw ? parseList(trustedProxiesRaw) : DEFAULT_HF_TRUSTED_PROXY_IPS;
|
|
|
|
| 34 |
const allowedOrigins = parseList(process.env.OPENCLAW_CONTROL_UI_ALLOWED_ORIGINS || "");
|
| 35 |
|
| 36 |
let config = {};
|
|
|
|
| 48 |
|
| 49 |
if (useTokenAuth || usePasswordAuth) {
|
| 50 |
if (!config.gateway.auth) config.gateway.auth = {};
|
| 51 |
+
if (useTokenAuth) { config.gateway.auth.mode = "token"; config.gateway.auth.token = gatewayToken; }
|
| 52 |
+
else { config.gateway.auth.mode = "password"; config.gateway.auth.password = gatewayPassword; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
}
|
| 54 |
|
| 55 |
if (!config.gateway.controlUi) config.gateway.controlUi = {};
|
|
|
|
| 57 |
config.gateway.controlUi.allowInsecureAuth = true;
|
| 58 |
|
| 59 |
if (allowedOrigins.length > 0) config.gateway.controlUi.allowedOrigins = allowedOrigins;
|
|
|
|
| 60 |
config.gateway.trustedProxies = trustedProxies;
|
| 61 |
|
| 62 |
+
// 支持 Gemini/Groq/Telegram 等密钥自动写入
|
| 63 |
+
config.externalApis = {
|
| 64 |
+
gemini: process.env.GEMINI_API_KEY || null,
|
| 65 |
+
groq: process.env.GROQ_API_KEY || null,
|
| 66 |
+
telegram: process.env.TELEGRAM_BOT_TOKEN || null
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
try {
|
| 70 |
fs.mkdirSync(stateDir, { recursive: true });
|
| 71 |
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
|
| 72 |
} catch (e) {
|
| 73 |
+
console.error("[openclaw-hf-setup] failed to write config:", e.message);
|
| 74 |
+
process.exit(1);
|
| 75 |
}
|
| 76 |
|
| 77 |
const authKind = useTokenAuth ? "token" : (usePasswordAuth ? "password" : "none");
|