From f37952c3f683e75f7432bcc31d14c5af12c0436b Mon Sep 17 00:00:00 2001 From: hz4th_coder Date: Mon, 20 Jul 2026 00:41:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20v1.4.3=20-=20=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 自然语言默认提示文本使用多行textarea 2. 默认GPU/版本/模式使用实时下拉列表选择(非手动输入) 3. 新增 show_nl_section 设置控制前端是否显示自然语言区域 4. LLM系统提示词也使用textarea 5. 布尔类设置项使用是/否下拉选择 --- app.py | 6 +++++- db.py | 1 + static/index.html | 2 +- static/js/admin.js | 33 +++++++++++++++++++++++++++++++-- static/js/main.js | 5 +++++ 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 51049b0..f4737ab 100644 --- a/app.py +++ b/app.py @@ -626,8 +626,12 @@ def get_models_grouped(): def get_public_settings(): db = get_db() nl = db.execute("SELECT value FROM settings WHERE key = 'nl_default_text'").fetchone() + snl = db.execute("SELECT value FROM settings WHERE key = 'show_nl_section'").fetchone() db.close() - return jsonify({'nl_default_text': nl['value'] if nl else ''}) + return jsonify({ + 'nl_default_text': nl['value'] if nl else '', + 'show_nl_section': snl['value'] if snl else 'true', + }) # ----- Parse Natural Language ----- diff --git a/db.py b/db.py index b00be63..8e1813f 100644 --- a/db.py +++ b/db.py @@ -387,6 +387,7 @@ def insert_default_data(conn): c.execute("INSERT OR IGNORE INTO settings (key, value) VALUES (?, ?)", ("llm_api_key", "")) c.execute("INSERT OR IGNORE INTO settings (key, value) VALUES (?, ?)", ("llm_api_model", "")) c.execute("INSERT OR IGNORE INTO settings (key, value) VALUES (?, ?)", ("nl_default_text", "用自然语言描述你想要的配置,支持多行输入。\n例如:\n用RTX 4090跑Llama-3-70B,上下文8192\n温度0.7,开启flash attention\n端口设为8080")) + c.execute("INSERT OR IGNORE INTO settings (key, value) VALUES (?, ?)", ("show_nl_section", "true")) conn.commit() diff --git a/static/index.html b/static/index.html index 6b15d26..4a9a16b 100644 --- a/static/index.html +++ b/static/index.html @@ -102,7 +102,7 @@ -
+

💬 自然语言生成

diff --git a/static/js/admin.js b/static/js/admin.js index a7ea547..7b6a3cf 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -307,6 +307,7 @@ function renderSettings() { 'default_version': '默认版本', 'default_mode': '默认模式', 'default_quant': '默认量化版本', + 'show_nl_section': '显示自然语言区域 (true/false)', 'nl_default_text': '自然语言默认提示文本', 'llm_enabled': '启用LLM解析 (true/false)', 'llm_api_url': 'LLM API URL', @@ -314,12 +315,40 @@ function renderSettings() { 'llm_api_model': 'LLM 模型名', 'llm_system_prompt': 'LLM 系统提示词', }; + // Keys that use multi-line textarea + const textareaKeys = ['nl_default_text', 'llm_system_prompt']; + // Keys that use select with live data + const gpuSelectKeys = ['default_gpu']; + const versionSelectKeys = ['default_version']; + const modeSelectKeys = ['default_mode']; + // Keys that are boolean-like + const boolKeys = ['llm_enabled', 'show_nl_section']; + document.getElementById('settings-form').innerHTML = Object.entries(adminState.settings).map(([key, value]) => { const label = labels[key] || key; - const isLong = key === 'llm_system_prompt'; - if (isLong) { + // Textarea + if (textareaKeys.includes(key)) { return `
`; } + // Select with GPU list + if (gpuSelectKeys.includes(key)) { + const opts = adminState.gpus.map(g => ``).join(''); + return `
`; + } + // Select with version list + if (versionSelectKeys.includes(key)) { + const opts = adminState.versions.map(v => ``).join(''); + return `
`; + } + // Select with mode + if (modeSelectKeys.includes(key)) { + return `
`; + } + // Boolean + if (boolKeys.includes(key)) { + return `
`; + } + // Password or text const type = key === 'llm_api_key' ? 'password' : 'text'; return `
`; }).join(''); diff --git a/static/js/main.js b/static/js/main.js index 9f10a1f..11a9d80 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -29,6 +29,11 @@ async function loadNlDefaultText() { if (data.nl_default_text) { ta.placeholder = data.nl_default_text; } + // Show/hide natural language section + const nlSection = document.getElementById('nl-section'); + if (nlSection) { + nlSection.classList.toggle('hidden', data.show_nl_section !== 'true'); + } } // ===== Load Data =====