From 33d3122e93b3c90ccdea83235481bdfc9d80b893 Mon Sep 17 00:00:00 2001 From: developer Date: Sat, 4 Apr 2026 22:46:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20RAG=20=E6=9C=AC=E5=9C=B0=E7=9F=A5?= =?UTF-8?q?=E8=AF=86=E5=BA=93=20-=20=E5=90=91=E9=87=8F=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E3=80=81=E6=96=87=E6=A1=A3=E5=88=86=E5=9D=97=E3=80=81=E8=AF=AD?= =?UTF-8?q?=E4=B9=89=E6=A3=80=E7=B4=A2=E3=80=81=E7=9F=A5=E8=AF=86=E5=BA=93?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/style.css | 209 ++++++++++++++++++++++ index.html | 66 +++++++ js/app.js | 6 + js/components/input-area.js | 11 ++ js/components/kb-modal.js | 344 ++++++++++++++++++++++++++++++++++++ js/document-processor.js | 105 +++++++++++ js/rag.js | 202 +++++++++++++++++++++ js/vector-store.js | 164 +++++++++++++++++ 8 files changed, 1107 insertions(+) create mode 100644 js/components/kb-modal.js create mode 100644 js/document-processor.js create mode 100644 js/rag.js create mode 100644 js/vector-store.js diff --git a/css/style.css b/css/style.css index 3873808..d698550 100644 --- a/css/style.css +++ b/css/style.css @@ -1712,3 +1712,212 @@ body::before { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } } + +/* ═══════════════ 知识库管理 ═══════════════ */ + +.modal-lg { + max-width: 780px; + width: 95vw; +} + +.kb-layout { + display: flex; + gap: 16px; + min-height: 400px; +} + +.kb-sidebar { + width: 260px; + flex-shrink: 0; + display: flex; + flex-direction: column; + gap: 8px; +} + +.kb-new-collection { + display: flex; + gap: 6px; +} +.kb-new-collection .setting-input { + flex: 1; + margin-bottom: 0; + font-size: 13px; + padding: 6px 10px; +} + +.kb-collection-list { + flex: 1; + overflow-y: auto; + display: flex; + flex-direction: column; + gap: 4px; +} + +.kb-collection-item { + display: flex; + align-items: center; + justify-content: space-between; + padding: 10px 12px; + border-radius: 8px; + cursor: pointer; + transition: background 0.15s; + border: 1px solid transparent; +} +.kb-collection-item:hover { + background: rgba(255,255,255,0.04); +} +.kb-collection-item.active { + background: rgba(0,245,212,0.08); + border-color: rgba(0,245,212,0.2); +} + +.kb-col-info { + display: flex; + flex-direction: column; + gap: 2px; + min-width: 0; +} +.kb-col-name { + font-size: 13px; + font-weight: 500; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.kb-col-stats { + font-size: 11px; + color: var(--text-muted); +} + +.kb-col-delete { + opacity: 0; + transition: opacity 0.15s; +} +.kb-collection-item:hover .kb-col-delete { + opacity: 1; +} + +.kb-main { + flex: 1; + display: flex; + flex-direction: column; + gap: 10px; + min-width: 0; +} + +.kb-toolbar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; +} +.kb-toolbar-left { + display: flex; + align-items: center; + gap: 8px; +} +.kb-toolbar-right { + display: flex; + align-items: center; + gap: 6px; +} + +.kb-progress { + display: inline-flex; + align-items: center; + gap: 6px; + font-size: 12px; + color: var(--text-muted); +} + +.spinner { + display: inline-block; + width: 14px; + height: 14px; + border: 2px solid rgba(0,245,212,0.3); + border-top-color: var(--accent-cyan); + border-radius: 50%; + animation: spin 0.6s linear infinite; +} + +@keyframes spin { + to { transform: rotate(360deg); } +} + +.kb-embed-model { + display: flex; + align-items: center; + gap: 8px; +} +.kb-embed-model .model-select { + flex: 1; + padding: 5px 8px; + font-size: 12px; +} + +.kb-doc-list { + flex: 1; + overflow-y: auto; + display: flex; + flex-direction: column; + gap: 4px; +} + +.kb-doc-item { + display: flex; + align-items: center; + gap: 10px; + padding: 8px 12px; + border-radius: 8px; + transition: background 0.15s; +} +.kb-doc-item:hover { + background: rgba(255,255,255,0.04); +} + +.kb-doc-icon { + font-size: 18px; + flex-shrink: 0; +} +.kb-doc-info { + flex: 1; + display: flex; + flex-direction: column; + gap: 1px; + min-width: 0; +} +.kb-doc-name { + font-size: 13px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.kb-doc-meta { + font-size: 11px; + color: var(--text-muted); +} + +.kb-doc-delete { + opacity: 0; + transition: opacity 0.15s; +} +.kb-doc-item:hover .kb-doc-delete { + opacity: 1; +} + +/* RAG badge */ +.rag-badge { + background: rgba(123,47,247,0.15) !important; + color: #b388ff !important; + border-color: rgba(123,47,247,0.3) !important; +} + +/* 移动端响应式 */ +@media (max-width: 640px) { + .kb-layout { + flex-direction: column; + } + .kb-sidebar { + width: 100%; + } +} diff --git a/index.html b/index.html index 758f6bf..c06cb5c 100644 --- a/index.html +++ b/index.html @@ -32,6 +32,14 @@ + + + + + +