From 44cca59ec6da3b9e4ce7a117f0bc81bb29de6e2c Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Sun, 26 Apr 2026 11:47:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E6=80=9D=E8=80=83?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=20-=20=E4=BD=BF=E7=94=A8thinking=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=80=8C=E9=9D=9E=E5=88=87=E6=8D=A2=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- www/app.js | 26 ++++++++++++++------------ www/index.html | 6 +++--- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/www/app.js b/www/app.js index 544c5bd..ccd5301 100644 --- a/www/app.js +++ b/www/app.js @@ -5,7 +5,6 @@ const CONFIG = { apiUrl: 'https://open.bigmodel.cn/api/paas/v4/chat/completions', apiKey: '2259e33a1357460abe17919aaf81e73d.K44a8LPQTmFM5PKm', model: 'glm-4.5-air', - thinkingModel: 'glm-z1-flash', // 智谱思考模型 maxTokens: 2048 }; @@ -418,8 +417,19 @@ async function streamGenerate(userMsgIndex) { contentEl.innerHTML = ''; try { - // 根据开关选择模型 - const model = enableThinking ? CONFIG.thinkingModel : CONFIG.model; + // 构建请求体 - 统一使用 glm-4.5-air,通过 thinking 参数控制 + const requestBody = { + model: CONFIG.model, + messages: currentConversation.messages.slice(0, aiMessageIndex).map(m => ({ + role: m.role, + content: m.content + })), + max_tokens: CONFIG.maxTokens, + stream: true, + thinking: { + type: enableThinking ? 'enabled' : 'disabled' + } + }; const response = await fetch(CONFIG.apiUrl, { method: 'POST', @@ -427,15 +437,7 @@ async function streamGenerate(userMsgIndex) { 'Content-Type': 'application/json', 'Authorization': `Bearer ${CONFIG.apiKey}` }, - body: JSON.stringify({ - model: model, - messages: currentConversation.messages.slice(0, aiMessageIndex).map(m => ({ - role: m.role, - content: m.content - })), - max_tokens: CONFIG.maxTokens, - stream: true - }) + body: JSON.stringify(requestBody) }); if (!response.ok) { diff --git a/www/index.html b/www/index.html index cce7968..11d4199 100644 --- a/www/index.html +++ b/www/index.html @@ -8,12 +8,12 @@ AI助手 - +
- - + + \ No newline at end of file