feat: RAG 本地知识库 - 向量存储、文档分块、语义检索、知识库管理面板

This commit is contained in:
developer
2026-04-04 22:46:29 +08:00
parent e15e102eec
commit 33d3122e93
8 changed files with 1107 additions and 0 deletions
+11
View File
@@ -12,6 +12,7 @@ import {
} from './chat-area.js';
import { showToast } from './toast.js';
import { checkConnection } from './header.js';
import { isRagEnabled, performRagRetrieval } from './kb-modal.js';
let chatInputEl, btnSendEl, fileInputEl, textFileInputEl, imagePreviewEl, filePreviewEl;
let pendingImages = [];
@@ -400,6 +401,16 @@ export async function sendMessage() {
...(numCtx && { options: { num_ctx: numCtx } })
};
// RAG 检索增强
if (isRagEnabled()) {
const ragResult = await performRagRetrieval(text);
if (ragResult && ragResult.ragPrompt) {
chatParams.system = chatParams.system
? chatParams.system + '\n\n' + ragResult.ragPrompt
: ragResult.ragPrompt;
}
}
await api.chatStream(chatParams, (chunk) => {
if (chunk.message) {
if (chunk.message.content) {