diff --git a/index.html b/index.html
index 16e81f0..09ea17a 100644
--- a/index.html
+++ b/index.html
@@ -193,6 +193,9 @@
tokens
常见值:2048 / 4096 / 8192 / 32768。值越大上下文越长,显存占用越高。
+
+
+ 低值更精确稳定,高值更有创意多样(0 = 确定性,2 = 最大随机)
diff --git a/js/app.js b/js/app.js
index d945f72..afd7236 100644
--- a/js/app.js
+++ b/js/app.js
@@ -142,19 +142,23 @@ async function init() {
await db.saveSetting('selectedModel', savedModel);
}
- // 8. 恢复系统提示词和上下文长度
+ // 8. 恢复系统提示词、上下文长度、温度
const systemPromptEnabled = await db.getSetting('systemPromptEnabled', false);
const systemPrompt = await db.getSetting('systemPrompt', '');
const numCtx = await db.getSetting('numCtx', 24576);
+ const temperature = await db.getSetting('temperature', 0.7);
state.set(KEYS.SYSTEM_PROMPT_ENABLED, systemPromptEnabled);
state.set(KEYS.SYSTEM_PROMPT, systemPrompt);
state.set(KEYS.NUM_CTX, numCtx);
+ state.set('temperature', temperature);
document.querySelector('#toggleSystemPrompt').checked = systemPromptEnabled;
document.querySelector('#inputSystemPrompt').disabled = !systemPromptEnabled;
document.querySelector('#inputSystemPrompt').value = systemPrompt;
document.querySelector('#inputNumCtx').value = numCtx;
+ document.querySelector('#inputTemperature').value = temperature;
+ document.querySelector('#tempValue').textContent = parseFloat(temperature).toFixed(1);
// 9. 聚焦输入框
document.querySelector('#chatInput')?.focus();
diff --git a/js/components/settings-modal.js b/js/components/settings-modal.js
index 2850296..d1a9a37 100644
--- a/js/components/settings-modal.js
+++ b/js/components/settings-modal.js
@@ -62,6 +62,21 @@ export function initSettingsModal() {
}, 500);
document.querySelector('#inputNumCtx').addEventListener('input', saveNumCtx);
+ // 温度滑块
+ const tempSlider = document.querySelector('#inputTemperature');
+ const tempDisplay = document.querySelector('#tempValue');
+ tempSlider.addEventListener('input', () => {
+ const val = parseFloat(tempSlider.value);
+ tempDisplay.textContent = val.toFixed(1);
+ });
+ const saveTemperature = debounce(async () => {
+ const db = state.get(KEYS.DB);
+ const val = parseFloat(tempSlider.value);
+ state.set('temperature', val);
+ if (db) await db.saveSetting('temperature', val);
+ }, 300);
+ tempSlider.addEventListener('change', saveTemperature);
+
// 释放显存
document.querySelector('#btnReleaseVRAM').addEventListener('click', async () => {
const api = state.get(KEYS.API);
diff --git a/js/preset-manager.js b/js/preset-manager.js
index d3f09e6..dc409c8 100644
--- a/js/preset-manager.js
+++ b/js/preset-manager.js
@@ -227,6 +227,12 @@ function syncPresetToUI(preset) {
const inputCtx = document.querySelector('#inputNumCtx');
if (inputCtx) inputCtx.value = preset.numCtx || 24576;
+ // Temperature
+ const tempSlider = document.querySelector('#inputTemperature');
+ const tempDisplay = document.querySelector('#tempValue');
+ if (tempSlider) tempSlider.value = preset.temperature ?? 0.7;
+ if (tempDisplay) tempDisplay.textContent = (preset.temperature ?? 0.7).toFixed(1);
+
// Think toggle
const thinkCheckbox = document.querySelector('#toggleThink');
if (thinkCheckbox) {