fix: 修正思考模式 - 使用thinking参数而非切换模型
This commit is contained in:
26
www/app.js
26
www/app.js
@@ -5,7 +5,6 @@ const CONFIG = {
|
|||||||
apiUrl: 'https://open.bigmodel.cn/api/paas/v4/chat/completions',
|
apiUrl: 'https://open.bigmodel.cn/api/paas/v4/chat/completions',
|
||||||
apiKey: '2259e33a1357460abe17919aaf81e73d.K44a8LPQTmFM5PKm',
|
apiKey: '2259e33a1357460abe17919aaf81e73d.K44a8LPQTmFM5PKm',
|
||||||
model: 'glm-4.5-air',
|
model: 'glm-4.5-air',
|
||||||
thinkingModel: 'glm-z1-flash', // 智谱思考模型
|
|
||||||
maxTokens: 2048
|
maxTokens: 2048
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -418,8 +417,19 @@ async function streamGenerate(userMsgIndex) {
|
|||||||
contentEl.innerHTML = '<span class="streaming-cursor">▌</span>';
|
contentEl.innerHTML = '<span class="streaming-cursor">▌</span>';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 根据开关选择模型
|
// 构建请求体 - 统一使用 glm-4.5-air,通过 thinking 参数控制
|
||||||
const model = enableThinking ? CONFIG.thinkingModel : CONFIG.model;
|
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, {
|
const response = await fetch(CONFIG.apiUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -427,15 +437,7 @@ async function streamGenerate(userMsgIndex) {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': `Bearer ${CONFIG.apiKey}`
|
'Authorization': `Bearer ${CONFIG.apiKey}`
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify(requestBody)
|
||||||
model: model,
|
|
||||||
messages: currentConversation.messages.slice(0, aiMessageIndex).map(m => ({
|
|
||||||
role: m.role,
|
|
||||||
content: m.content
|
|
||||||
})),
|
|
||||||
max_tokens: CONFIG.maxTokens,
|
|
||||||
stream: true
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
@@ -8,12 +8,12 @@
|
|||||||
<meta http-equiv="Pragma" content="no-cache">
|
<meta http-equiv="Pragma" content="no-cache">
|
||||||
<meta http-equiv="Expires" content="0">
|
<meta http-equiv="Expires" content="0">
|
||||||
<title>AI助手</title>
|
<title>AI助手</title>
|
||||||
<link rel="stylesheet" href="style.css?v=2.2.2">
|
<link rel="stylesheet" href="style.css?v=2.2.3">
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script src="marked.min.js?v=2.2.2"></script>
|
<script src="marked.min.js?v=2.2.3"></script>
|
||||||
<script src="app.js?v=2.2.2"></script>
|
<script src="app.js?v=2.2.3"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user