From 582661146b47a52b49d3a7f41aaf9c928d270a86 Mon Sep 17 00:00:00 2001 From: thzxx Date: Sat, 4 Apr 2026 23:22:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B5=8C=E5=85=A5=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E4=BB=85=E6=98=BE=E7=A4=BA=20embedding=20?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/components/kb-modal.js | 45 +++++++++++---------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/js/components/kb-modal.js b/js/components/kb-modal.js index 1bf518f..7f4a146 100644 --- a/js/components/kb-modal.js +++ b/js/components/kb-modal.js @@ -291,7 +291,7 @@ async function handleDocUpload(e) { } /** - * 填充嵌入模型下拉 + * 填充嵌入模型下拉(仅显示嵌入模型) */ async function populateEmbedModels() { const select = document.querySelector('#selectEmbedModel'); @@ -302,41 +302,22 @@ async function populateEmbedModels() { const data = await api.listModels(); select.innerHTML = ''; if (data.models) { - // 推荐的嵌入模型优先显示 - const embedKeywords = ['embed', 'nomic', 'mxbai', 'bge', 'e5', 'snowflake']; - const recommended = []; - const others = []; + const embedKeywords = ['embed', 'nomic', 'mxbai', 'bge', 'e5', 'snowflake', 'arctic']; + const embedModels = data.models.filter(m => + embedKeywords.some(kw => m.name.toLowerCase().includes(kw)) + ); - for (const m of data.models) { - const name = m.name.toLowerCase(); - if (embedKeywords.some(kw => name.includes(kw))) { - recommended.push(m); - } else { - others.push(m); - } - } - - if (recommended.length > 0) { - const optgroup = document.createElement('optgroup'); - optgroup.label = '推荐(嵌入模型)'; - recommended.forEach(m => { - const opt = document.createElement('option'); - opt.value = m.name; - opt.textContent = m.name; - optgroup.appendChild(opt); - }); - select.appendChild(optgroup); - } - - const optgroup2 = document.createElement('optgroup'); - optgroup2.label = '其他模型'; - others.forEach(m => { + embedModels.forEach(m => { const opt = document.createElement('option'); opt.value = m.name; - opt.textContent = m.name; - optgroup2.appendChild(opt); + const size = m.size ? ` (${formatSize(m.size)})` : ''; + opt.textContent = m.name + size; + select.appendChild(opt); }); - select.appendChild(optgroup2); + + if (embedModels.length === 0) { + select.innerHTML = ''; + } } } catch (err) { console.warn('[KB] 加载模型列表失败:', err);