From 5711f451c7af9b47a8dccf0c08a1da84a4ce72f0 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 5 Jul 2026 16:08:31 +0000 Subject: [PATCH] =?UTF-8?q?feat(console):=20=E8=AA=9E=E6=84=8F=E5=8D=87=20?= =?UTF-8?q?default(=E5=A4=A7=E7=9C=BE=E5=8C=96)=20+=20proxy=20=E8=AA=9E?= =?UTF-8?q?=E6=84=8F=E6=9F=A5=E4=B8=8D=E6=B3=A8=E5=85=A5=20owner(self-host?= =?UTF-8?q?ed=20=E5=96=AE=E7=A7=9F=E6=88=B6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - console.ts: S.semantic false→true(會打字就按意義查,含 normalize);開關反映預設 - kbdb-proxy /kbdb/search: mode=semantic 不注入 owner_id(Vectorize 無 owner index+向量非owner=tenant→帶owner回0);單租戶全庫語意查正確 - : 多租戶語意 owner 隔離(建 Vectorize owner_id metadata index) - leo 拍板 X(先做 self-hosted,不糾結 SaaS) --- cypher-executor/src/routes/console.ts | 3 ++- cypher-executor/src/routes/kbdb-proxy.ts | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cypher-executor/src/routes/console.ts b/cypher-executor/src/routes/console.ts index a3a62b8..88caff6 100644 --- a/cypher-executor/src/routes/console.ts +++ b/cypher-executor/src/routes/console.ts @@ -488,7 +488,7 @@ function renderConsoleHtml(registryBase: string): string { tenant: '', total: null, // KBDB 總筆數(誠實 total) chip: '', // entry_type filter('' = 全部) - semantic: false, + semantic: true, // 大眾化 default:語意為主(leo 2026-07-05,會打字就查得到,含 normalize) cardId: '', graphCenter: '', wfCache: null, @@ -755,6 +755,7 @@ function renderConsoleHtml(registryBase: string): string { function initSearchOnce() { if (searchInited) { return; } searchInited = true; + $('se-sem').classList.toggle('on', S.semantic); // 開關反映預設(語意 default on) renderChips(); ensureTotal(); } diff --git a/cypher-executor/src/routes/kbdb-proxy.ts b/cypher-executor/src/routes/kbdb-proxy.ts index 8d12267..d6e2c6f 100644 --- a/cypher-executor/src/routes/kbdb-proxy.ts +++ b/cypher-executor/src/routes/kbdb-proxy.ts @@ -129,7 +129,11 @@ kbdbProxyRouter.get('/kbdb/search', async (c) => { const q = c.req.query('q'); if (!q) return c.json({ error: 'q 必填' }, 400); const { base, headers } = kbdbBase(c.env); - const params = new URLSearchParams({ q, owner_id: owner }); + const mode = c.req.query('mode'); + // self-hosted 單租戶:mode=semantic 暫不注入 owner_id(Vectorize 未建 owner_id metadata index, + // 且 embedded 向量非 owner=tenant → 帶 owner 一律回 0)。單租戶下全庫語意查即正確。 + // :多租戶時語意也要 owner 隔離(建 Vectorize owner_id metadata index + 向量帶 owner)。 + const params = new URLSearchParams(mode === 'semantic' ? { q } : { q, owner_id: owner }); for (const k of ['entry_type', 'source', 'mode']) { const v = c.req.query(k); if (v) params.set(k, v);