diff --git a/www/app.js b/www/app.js index 4ec0663..0b3154c 100644 --- a/www/app.js +++ b/www/app.js @@ -140,7 +140,13 @@ async function loadBackendConfig() { // 将后台 LLM 配置赋值到 CONFIG if (backendConfig.llm) { - CONFIG.apiUrl = backendConfig.llm.api_url; + // 自动拼接 /chat/completions(如果不是完整URL) + let apiUrl = backendConfig.llm.api_url; + if (apiUrl && !apiUrl.includes('/chat/completions')) { + // 确保URL以/结尾再拼接,或直接拼接 + apiUrl = apiUrl.endsWith('/') ? apiUrl + 'chat/completions' : apiUrl + '/chat/completions'; + } + CONFIG.apiUrl = apiUrl; CONFIG.apiKey = backendConfig.llm.api_key; CONFIG.model = backendConfig.llm.model; CONFIG.maxTokens = backendConfig.llm.max_tokens || 2048;